-
-
Notifications
You must be signed in to change notification settings - Fork 17
Change Request: support linting .scss files #90
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
Comments
Thanks for the suggestion. I'm not sure how to go about doing this for this plugin. Stylelint is built on PostCSS, so it's easy for them to work with PostCSS plugins. This plugin is based on CSSTree, which means there's no easy path to supporting PostCSS plugins. I'm not saying it's impossible, just that there would have to be a different as-yet-unknown approach. I'm not very familiar with the differences between CSS and SCSS, can you provide a high-level overview? And have you tried using the |
SCSS provides a handful of syntax/features on top of base CSS, such as:
ex: $primary-color: blue;
$secondary-color: white;
.button {
background-color: $primary-color;
color: $secondary-color;
&:hover {
background-color: darken($primary-color, 10%);
}
} Changing to
{
files: ["**/*.css", "**/*.scss"],
plugins: {
css,
},
language: "css/css",
languageOptions: {
tolerant: true,
},
rules: {
"css/prefer-logical-properties": "error",
},
}, |
Thanks for the examples. I'm not sure the best way to look at this. It could be a custom parser or maybe some changes to CSSTree. It will take me some time to investigate.
Thanks for pointing this out. It looks like this is an error in the types coming from the |
+1! I would like to completely abandon the stylelint solution, but without sass/scss support (and there is also stylus), it is problematic to do so. But I believe that eslint/css has a great future! |
@scripthunter7 I'm curious if, with your experience with CSSTree, if you think it's possible to extend it to parse SCSS? |
@nzakas Actually, CSS Tree is quite modular and also supports the fork option, so I wouldn’t rule out the possibility of adapting it for SCSS as well |
Okay, I think I have an idea of how to do this. Here's what I'm working on: You can follow along with the progress on the PR and give it a try. (Note: linting and type checking is currently failing. That's expected at this point.) |
Okay, I severely underestimated the amount of effort this would take. The syntax surface area of SCSS is pretty large and it will likely take me a long time to work through every piece of it. At this point, I'm looking for a company or person willing to sponsor development of an SCSS parser for this plugin. |
A way to shortcut this effort could be to not write your own parser for SCSS and instead pull in |
Thanks for the suggestion. That would eliminate some of the work. It's still going to be a lot of work because we need to translate the AST into a format that this plugin would understand. As I mentioned, SCSS syntax surface area is quite large and needing to define and test AST nodes that won't interfere with what this plugin does is a large effort. I don't have enough free time to do that and also the other work that ESLint requires. If someone else wants to take that on, I'd say go for it. For me, I can't afford to spend that much time on it without being paid. |
Another option could be using the Sass parser being built into |
Thanks for the suggestion, I'll take a look. At least my initial impression is that we'd still really need a CSSTree-based approach in order to use the CSSTree validation utilities, which otherwise wouldn't know about SCSS syntax. |
Marking it as accepted since there's an ongoing PR for this. |
I took another look at this and I think there's a way we can use Overall, I think this work needs to take place outside of this plugin. |
Environment
ESLint version:
@eslint/css version: 0.5.0
Node version: 22.14.0
npm version: 10.9.2
Operating System: Windows 11
What problem do you want to solve?
I'd love to be able to use
@eslint/css
but most of my project code using SCSS for styles. Can this library support.scss
files? All of the documentation only includes css.What do you think is the correct solution?
Stylelint supports scss via postcss and also can enable plugins like
postcss-angular
postcss-html
. It would be great if eslint supported this level of integration for scss as well.Participation
Additional comments
No response
The text was updated successfully, but these errors were encountered: