sass-lint-auto-fix
raw JSON → 0.21.2 verified Fri May 01 auth: no javascript maintenance
A CLI tool that automatically fixes common sass-lint issues by parsing Sass/SCSS into an AST and modifying nodes to conform to rules defined in .sass-lint.yml. Currently at v0.21.2 (August 2020) with no updates since. It complements sass-lint (not stylelint) and supports SCSS and Sass syntax. Key differentiators: resolves issues via gonzales-pe AST manipulation; supports custom config files and husky pre-commit hooks. Alternatives: stylelint with --fix, Prettier. Note: sass-lint is deprecated in favor of stylelint, making this tool also effectively deprecated.
Common errors
error Error: Cannot find module 'sass-lint' ↓
cause sass-lint is a peer dependency and must be installed separately.
fix
Run npm install --save-dev sass-lint
error Error: No files matched pattern: "**/*.s+(a|c)ss" ↓
cause The glob pattern does not match any files, or the pattern is incorrectly quoted.
fix
Ensure the pattern is correct and quoted. For example: sass-lint-auto-fix "src/**/*.scss"
error Error: Unsupported syntax - only scss and sass supported ↓
cause The input file has an extension other than .scss or .sass, e.g., .css.
fix
Only lint .scss and .sass files; convert .css to .scss or use a different tool.
error TypeError: Cannot read property 'remove' of undefined ↓
cause A bug in the rule resolver or an AST inconsistency; often occurs on edge cases with custom syntax.
fix
Upgrade to latest version (0.21.2) or isolate the file and disable the problematic resolver.
Warnings
deprecated sass-lint is deprecated; consider migrating to stylelint. sass-lint-auto-fix only works with sass-lint. ↓
fix Migrate to stylelint and use stylelint --fix or prettier for formatting.
breaking v0.21.0 changed config loading to use cosmiconfig; old config file paths may not work. ↓
fix Ensure your configuration file is named .sass-lint-auto-fix.[yml|yaml|json|js] or specify custom path with --config.
gotcha The tool may exit with code 0 even if fixes were applied; fixed in v0.21.2. ↓
fix Upgrade to v0.21.2 or later to get correct exit codes.
gotcha Some rules like indentation are not supported as resolvers; they remain as 0 in config. ↓
fix Check the list of supported resolvers in the default config; unsupported rules must be fixed manually.
deprecated The package has had no releases since 2020 and is considered unmaintained. ↓
fix Use alternatives like stylelint --fix, Prettier, or sass formatter.
Install
npm install sass-lint-auto-fix yarn add sass-lint-auto-fix pnpm add sass-lint-auto-fix Imports
- sassLintAutoFix wrong
import * as sassLintAutoFix from 'sass-lint-auto-fix'correctconst sassLintAutoFix = require('sass-lint-auto-fix') - CLI usage wrong
sass-lint-auto-fix "**/*.scss"correctnpx sass-lint-auto-fix "**/*.scss" - Configuration import (cosmiconfig) wrong
require('sass-lint-auto-fix').configcorrect// uses .sass-lint-auto-fix.yml automatically
Quickstart
// Install as dev dependency
npm install --save-dev sass-lint-auto-fix sass-lint
// Add to package.json
{
"scripts": {
"lint": "sass-lint -v",
"lint:fix": "sass-lint-auto-fix"
}
}
// Run
npm run lint:fix
// Or with npx (no install)
npx sass-lint-auto-fix "src/**/*.scss" --config-sass-lint .sass-lint.yml