juanca / stylelint-css-modules

Stylelint ruleset for CSS modules
10 stars 1 forks source link

Publish to stylelint plugins list #1

Closed juanca closed 4 years ago

juanca commented 6 years ago

Let's add a few more rules before doing a non-alpha release.

Ideas for other lint rules;

  1. Lint against conflicting property values through composition (given indeterminate ordering)
  2. Alphabetical class names
  3. Consolidate with stylelint-config-css-modules (?)
a7madgamal commented 5 years ago

I'm looking for a way to prevent undefined imported classes too :)

juanca commented 5 years ago

Feel free to use the alpha version of this plugin! Let me know how it goes -- I appreciate the feedback.

juanca commented 5 years ago

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.

JustFly1984 commented 4 years ago

@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.

juanca commented 4 years ago

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.