» npm install eslint-plugin-styled-components-a11y
Is there a favoured way to lint Styled Components?
Stylelint v14 and stylelint-processor-styled-components
reactjs - How to format css-in-js styles order using stylelint? - Stack Overflow
reactjs - Custom `stylelint` plugin for `styled-components` - Stack Overflow
» npm install stylelint-processor-styled-components
I got the OK from my higher-up to implement Styled-Components into a project at work, and despite a million personal projects I've never used them in production.
Anybody have any good tooling chains for linting that are production ready? I've found a few packages, but most only support 1 or 2 rules. I'm not looking to enforce any super strict standards such as strict alphabetical as we have our own SCSS structuring rules here that I'll using. Just low-level stuff.
I've also found a few ways to do this through stylelint but I've read some wonky reviews. Not sure if they've been ironed out.
Would love to hear how people are implementing these on the big stage. Thanks in advance!
EDIT:. Thanks everyone. Seems like StyleLint is the way to go. For anyone curious, these are what I went with:
stylelint stylelint-config-recommended stylelint-config-styled-components stylelint-custom-processor-styled-components stylelint-processor-styled-components
I've been toying with it this weekend and really like it. Using these with a .stylelintrc is making for a great development experience so far.
I think there is a way to do it now with https://github.com/styled-components/stylelint-processor-styled-components and as documentation states -
Combining with moduleName, importName and strict, you can tell the processor what kinds of tagged template literals to lint.
{
"processors": [["stylelint-processor-styled-components", {
"moduleName": "styled-components",
"importName": ["default", "for1080p"], <---- here
}
That stuff wasn’t tested by me, but I think it suppose to do the trick
The CSS-in-JS parser built into stylelint doesn't yet support interpolation tagging, and therefore can't know that the second widht: 300px; is a declaration.
Until that support is added, you can either:
- see how much mileage you get from the styled-components stylelint processor and its support for interpolation tagging
- use standard CSS constructs, rather than custom templates string, for things like
@media