StyleLint
Installation
Section titled “Installation”See the official documentation.
npm i -D stylelintyarn add -D stylelintpnpm add -D stylelintbun add -d stylelintnpm i -D stylelint-a11y stylelint-config-standard stylelint-order stylelint-plugin-defensive-css stylelint-use-logical-specyarn add -D stylelint-a11y stylelint-config-standard stylelint-order stylelint-plugin-defensive-css stylelint-use-logical-specpnpm add -D stylelint-a11y stylelint-config-standard stylelint-order stylelint-plugin-defensive-css stylelint-use-logical-specbun add -d stylelint-a11y stylelint-config-standard stylelint-order stylelint-plugin-defensive-css stylelint-use-logical-specSettings
Section titled “Settings”These are basic .stylelintrc.json settings.
{ "$schema": "https://json.schemastore.org/stylelintrc.json", "extends": ["stylelint-config-standard"], "plugins": [ "stylelint-order", "stylelint-use-logical-spec", "stylelint-plugin-defensive-css" ], "rules": { "color-no-hex": true, "liberty/use-logical-spec": true, "plugin/use-defensive-css": [ true, { "accidental-hover": true, "background-repeat": true, "custom-property-fallbacks": true, "scroll-chaining": true } ] }, "reportNeedlessDisables": true, "reportInvalidScopeDisables": true}Create an ignore file (.stylelintignore) with the following:
builddistcoverageanalysisand here is a script to run stlintlint on your project:
# File: package.json
"style:lint": "pnpm run stylelint --cache './src/**/*.css'","style:lint:fix": "pnpm run style:lint --fix",