Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Stylelint throws on ts/tsx files not using styled-components #259

Closed
moimael opened this issue Mar 26, 2019 · 1 comment
Closed

Stylelint throws on ts/tsx files not using styled-components #259

moimael opened this issue Mar 26, 2019 · 1 comment

Comments

@moimael
Copy link

moimael commented Mar 26, 2019

Environment

## System:
 - OS: Linux 5.0 Fedora 29 (Workstation Edition) 29 (Workstation Edition)
 - CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
 - Memory: 3.78 GB / 15.43 GB
 - Container: Yes
 - Shell: 4.4.23 - /bin/bash
## Binaries:
 - Node: 10.15.3 - /usr/bin/node
 - Yarn: 1.10.1 - /usr/bin/yarn
 - npm: 6.9.0 - /usr/bin/npm
## npmPackages:
 - styled-components: 3.4.2 => 3.4.2 
 - stylelint: 9.10.1 => 9.10.1 
 - stylelint-config-recommended: 2.1.0 => 2.1.0 
 - stylelint-config-styled-components: 0.1.1 => 0.1.1 
 - stylelint-processor-styled-components: 1.5.2 => 1.5.2 

.stylelintrc

{
  "processors":[
    "stylelint-processor-styled-components"
  ],
  "extends":[
    "stylelint-config-recommended",
    "stylelint-config-styled-components"
  ]
}

Reproduction

Stylelint throws errors on Ts/Tsx files that don't use or import styled-components.

stylelint-errors

An example of one of the file that throws (the use-experiment.ts):

import { pathOr } from "ramda"
import { useReduxStore } from "./use-redux"

export const useExperiment = (experimentFlag: string): boolean => {
  const experimentList = <string[]>pathOr([], ["experiment", "list"], useReduxStore().getState())
  return experimentList.includes(experimentFlag)
}

Steps to reproduce

Not sure, just ran stylelint in my project

Expected Behavior

Shouldn't throw for files without styled-components

Actual Behavior

Throws styles errors on Ts/Tsx files only not related to styled-components.

@chinesedfan
Copy link
Member

You can custom plugins by option.parserPlugins now. An example is https://github.com/styled-components/stylelint-processor-styled-components/blob/master/test/options.test.js#L211. If disabled the jsx plugin, use-experiment.ts can be parsed successfully.

Of course, if someone can implement #231, that is much better.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants