Closed juanca closed 4 years ago
I'm looking for a way to prevent undefined imported classes too :)
Feel free to use the alpha version of this plugin! Let me know how it goes -- I appreciate the feedback.
Just had another idea that might make this feature complete:
In the same vein as "CSS variables are well-defined" we should also lint against useless import statements.
For each @import
, we are either using a CSS variable defined in the file or composing from a class defined in the file.
@juanca @a7madgamal I solve issue with undefined classes with typescript, vscode plugin css-modules-typed and npm i -g css-modules-typed@0.5.1. newer versions sadly does not work with vscode plugin.
with this plugin .d.ts files autogenerated on save for any .module.css file with special comment on top.
So each time I remove some classname in css, and it is still imported somewhere else in the project, I got a warning on type-check. Also I setup husky
with lint-staged
with git hook precommit
, which runs type-check and eslint before each commit, and if there is missing classname - it does not commit.
We are using Gatsby.js as framework, and it has this amazing plugin gatsby-plugin-purge-css
it helps to identify all unused classnames in the project.
One more amazing tool for cleaning dead code - ts-prune
- it gives some false negatives, but in general works great to find all unused exports.
Tracking publishing issue @ https://github.com/stylelint/awesome-stylelint/issues/20
I just released major version 1 since we have decent test coverage and this plugin has only had a few bugs within the past 2 years -- I think it's pretty stable by now.
Let's add a few more rules before doing a non-alpha release.
Ideas for other lint rules;
stylelint-config-css-modules
(?)