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.

Install Common Stylesheet Tooling
npm install --save-dev stylelint stylelint-config-standard-scss sass
💡 This command installs Sass and common Stylelint tooling for SCSS projects. A project may also install Prettier and an appropriate Stylelint configuration depending on its existing formatting workflow. Package compatibility and configuration requirements can change between tool versions. Configure the linter according to the installed versions and verify the setup with a real SCSS file.
Key Takeaways
  • 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.
Knowledge Check

What is the primary role of a stylesheet linter?