Linting, Formatting, and Team Conventions
A consistent Sass codebase benefits from formatting rules, linting, predictable naming conventions, and documented architecture. These practices reduce stylistic disagreements and help identify likely errors before browser testing.
Stylelint is a widely used CSS linter that can be configured to validate SCSS through its SCSS syntax integration. Prettier can format supported SCSS files, while a project's build and test scripts enforce the intended workflow.
Linting and compilation solve different problems. A stylesheet can compile successfully and still contain duplicated declarations, inaccessible focus states, inconsistent token usage, or overly specific selectors.
Create a small set of team conventions for naming, nesting depth, token usage, file organization, and allowed global styles. Enforce the most valuable rules automatically.
npm install --save-dev stylelint stylelint-config-standard-scss sass- Compilation checks whether Sass can produce CSS.
- Linting checks code conventions and configured stylesheet rules.
- Formatting keeps source files consistent.
- Accessibility and visual testing remain necessary even when automated checks pass.
What is the primary role of a stylesheet linter?