Add CSS linting through stylelint

Include CSS linting by default for our CSS/SCSS files, originally
introduced in cockpit. The stylelint configuration is copied from
760a4628282e02fbcef3.
This commit is contained in:
Jelle van der Waa 2022-07-19 17:37:05 +02:00 committed by Martin Pitt
parent 0e2591ee93
commit ee366ca531
4 changed files with 78 additions and 2 deletions

View file

@ -73,6 +73,29 @@ Violations of some rules can be fixed automatically by:
Rules configuration can be found in the `.eslintrc.json` file.
## Running stylelint
Cockpit uses [Stylelint](https://stylelint.io/) to automatically check CSS code
style in `.css` and `scss` files.
The linter is executed within every build as a webpack preloader.
For developer convenience, the Stylelint can be started explicitly by:
$ npm run stylelint
Violations of some rules can be fixed automatically by:
$ npm run stylelint:fix
Rules configuration can be found in the `.stylelintrc.json` file.
During fast iterative development, you can also choose to not run stylelint.
This speeds up the build and avoids build failures due to e. g. ill-formatted
css or other issues:
$ make STYLELINT=0
# Running tests locally
Run `make check` to build an RPM, install it into a standard Cockpit test VM