stylelint - A mighty CSS linter that helps you avoid errors and enforce conventions.
stylelint-config-standard-scss - The standard shareable SCSS config for Stylelint.
stylelint-prettier - Runs Prettier as a Stylelint rule and reports differences as individual Stylelint issues.
postcss - added as an devDependency to fix the error shown on the screenshot below
Configuration:
Added basic linting rules for SCSS/CSS properties with package stylelint-config-standard-scss, you can find the full list of lining rules here
Integration:
Updated lint and lint-fix scripts in package.json to run Stylelint checks, updated lint-staged script so now stylelint checks on the pre-commit hook and during continuous integration pipeline
Ensured Stylelint is integrated with Prettier with the help of stylelint-prettier package.
Testing:
Tested the Stylelint setup by running it against our existing SCSS/CSS files.
Fixed all linting errors that arose to ensure the codebase complies with the new linting rules.
IDE Extension
If you use VS Code and want real-time validating style files with Stylelint, you can install the official Visual Studio Code extension for Stylelint. After installation, you must add SCSS validation because only CSS and PostCSS are Validated by Default. You can add this config to your VS Code config file.
Configured Stylelint package
stylelint
- A mighty CSS linter that helps you avoid errors and enforce conventions.stylelint-config-standard-scss
- The standard shareable SCSS config for Stylelint.stylelint-prettier
- Runs Prettier as a Stylelint rule and reports differences as individual Stylelint issues.postcss
- added as an devDependency to fix the error shown on the screenshot belowConfiguration:
stylelint-config-standard-scss
, you can find the full list of lining rules hereIntegration:
lint
andlint-fix
scripts in package.json to run Stylelint checks, updatedlint-staged
script so now stylelint checks on the pre-commit hook and during continuous integration pipelinePrettier
with the help ofstylelint-prettier
package.Testing:
IDE Extension
If you use VS Code and want real-time validating style files with Stylelint, you can install the official Visual Studio Code extension for Stylelint. After installation, you must add SCSS validation because only CSS and PostCSS are Validated by Default. You can add this config to your VS Code config file.