-
Notifications
You must be signed in to change notification settings - Fork 101
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
Add Stylelint #45
Comments
Hey, thanks! For sure – 💯 I don't use this tool & so I completely forgot it was even an option. ... I think I'll add this as a new plugin (and |
Hey, so this needs to wait a bit. I lost most of the day playing with Stylelint because it:
I tried two approaches: A) Adding it as a PostCSS plugin directly This made most of SASS appear to work, although I'm not confident that it does because Option (B) shows significantly more errors & warnings per file. Also, each warning is printed twice in this mode. B) Using the The error formatting is correct, looks nice, but this mode is the most broken & inconsistent – see below. For (2), I have It will ignore In fact, nearly all non-CSS preprocessors have some kind of CSS-modules escape character. // less
&:root {
--blue: #1E88E5;
}
&:global(.penta) {
background-image: url(@assets/shapes/penta.svg);
} // sass
\:root
--blue: #1E88E5
\:global(.penta)
background-image: url(@assets/shapes/penta.svg) // stylus
:root
--blue #1E88E5
:global(.penta)
background-image url("@assets/shapes/penta.svg") All in all, I'd be happy to add this as an official plugin, but not in its current state. There are too many holes as is – or, at least, too many inconsistencies that PWA can't solve in a single package on the user's behalf. I'd much rather wait on a good addition than put out a semi-baked solution that only works some of the time. Unfortunately, I don't have the spare time right now to contribute towards these gaps, otherwise I most definitely would. |
Yeap. There is no way to support since:
Hm. We can fix
Off-topic: This is why you can use PostCSS for preprocessors too ;). It works perfectly with CSS Modules, since CSS Modules is just PostCSS plugin. |
Yeah, understood. I could live with putting a disclaimer for "no Stylelint with Stylus". Yes, SCSS/SASS expects And yeah, I see that attaching Here are the outputs from both approaches:
|
The best solution, for Webpack context, would be to have a This would solve the Stylus issue and prevent any inconsistencies that I've been experiencing. I think the only thing you lose is the ability to lint the spacing on the input files, although each preprocessor might be preserving the original spacing. |
Let’s create a issue in webpack stylelint loader. I think fixing the loader will fix all current problems. |
I am not sure.
Allso, are you sure that webpack loader is a best place for linter? I see there are 2 reasons for using linter:
Both cases are not really covered by webpack’s loader. Nobody really keeps webpack console in front on eyes to see a warning in the right time. Junior will see error only on CI server (and will blame theirself that everyone now see this mistake). I think the best way of using linter: text editor plugins and |
This is what the
Compare that to the ESLint approach:
ESLint is able to do this because they're working with a normalized syntax (JS) whereas Stylelint is attempting to ingest everything, but it (knowingly) can't. The more analogous example for ESLint would be linting your CoffeeScript files.
In all scenarios, you still get linter feedback per-save. The difference is just in when the linting happens. ¯_(ツ)_/¯ I know it's not great & not what you have in mind, but to me it seems like the only way to normalize the behavior is to normalize what Stylelint ingests. |
We have ESLint to lint JS. So we should have linter for CSS as well. The most popular CSS linter right now is Stylelint.
It also works with pure CSS, PostCSS extensions, SCSS, Less, even indented Sass and CSS-in-JS.
https://stylelint.io/
The text was updated successfully, but these errors were encountered: