Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

processor for stylelint #106

Closed
lixiaoyan opened this issue Feb 3, 2017 · 15 comments
Closed

processor for stylelint #106

lixiaoyan opened this issue Feb 3, 2017 · 15 comments

Comments

@lixiaoyan
Copy link
Contributor

No description provided.

@giuseppeg
Copy link
Collaborator

giuseppeg commented Feb 4, 2017

I believe that you can get stylelint working if you use styled-jsx-postcss instead.

@rauchg I suppose that this is never going to happen in styled-jsx right? stylelint is based on PostCSS.

@thysultan
Copy link
Contributor

@giuseppeg what about https://csstree.github.io/docs/validator.html?... or when the transformer is updated to v1.0 stylis you could register a custom linter as a plugin.

@rauchg
Copy link
Member

rauchg commented Feb 19, 2017

It'd be cool to have support for linting, with stylis

@thysultan
Copy link
Contributor

@rauchg working on v1.2 that will have better support for creating a linter plugin, will create a basic linter plugin after that is out.

@thysultan
Copy link
Contributor

@rauchg This should now be possible with v1.2.0 relevant issue

@giuseppeg
Copy link
Collaborator

I think that this can be done as a plugin if/when #190 lands. Can we close it?

@rsternagel
Copy link

@lixiaoyan

Got it working!

On top of stylelint you need the "{at}mapbox/stylelint-processor-arbitrary-tags" processor and the "stylelint-config-css-modules" configuration (for allowing "global()"-syntax).

yarn add stylelint --dev
yarn add stylelint-config-standard --dev 
yarn add @mapbox/stylelint-processor-arbitrary-tags --dev
yarn add stylelint-config-css-modules --dev

XOR

npm i stylelint --save-dev
npm i stylelint-config-standard --save-dev
npm i @mapbox/stylelint-processor-arbitrary-tags --save-dev
npm i stylelint-config-css-modules --save-dev

.stylelintrc

{
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-css-modules"
  ],
  "processors": [
    [ "@mapbox/stylelint-processor-arbitrary-tags", {
            "startTag": "\\s*<style jsx>{`",
            "endTag": "\\s*`}<\/style>"
      }
    ]
  ],
  "rules": {
    "no-empty-source": null
  }
}

Now lint code:

./node_modules/.bin/stylelint "src/**/*.js"

Of cource, this can be done nicer with a npm script...

IMO it's worth adding to the "readme.md". :)

@dmitrika
Copy link

dmitrika commented Aug 5, 2017

@rauchg, @nkzawa, @giuseppegurgone

Can we use @rsternagel approach as the best one and add it to readme?
I was looking for linting support and found solution here, not in readme or wiki 🤓

@codeincontext
Copy link

@rsternagel Thank you for your example above. I get a CssSyntaxError in stylelint wherever I have an interpolated value in the styled-jsx string. eg: font-size: ${myVar};. Have you found a way to solve this?

@shallwefootball
Copy link

+1 error too

@flippidippi
Copy link

flippidippi commented Oct 9, 2017

I'm getting that error also. It works fine if I don't use interpolated values though.

@giuseppeg
Copy link
Collaborator

Fixed by #291

I made a test plugin https://github.com/giuseppeg/styled-jsx-plugin-stylelint it is a proof of concept but you guys can start from there (contribute and make it better)

@glrodasz
Copy link

Have you figured out how to use for <style> tags and for .css files at the same time?

@l-Leniac-l
Copy link

I've made a custom syntax for stylelint based on the styled-components one, and it is working quite well so far. The good part about using the custom syntax is using the --fix option.
Check it out: https://github.com/foobaragency/postcss-styled-jsx

@louislebrault
Copy link

louislebrault commented Jul 19, 2023

Maybe this issue deserves to be re-open, as no complete solution has been found yet ?

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

No branches or pull requests