Node.js-based linting tool for Sass and SCSS files with 75+ configurable rules and both CLI and programmatic APIs.
—
The sass-lint command-line interface provides comprehensive linting capabilities for Sass and SCSS files with extensive configuration options and output formatting.
Execute sass-lint with file patterns to analyze Sass/SCSS files.
sass-lint [options] <pattern>Parameters:
pattern (optional) - Glob pattern or file path to lint. If omitted, uses config file patternsConfigure sass-lint behavior through command-line options.
# Configuration
-c, --config [path] # Path to custom config file
-i, --ignore [pattern] # Pattern to ignore files (comma-separated for multiple)
# Output Control
-v, --verbose # Enable verbose output
-f, --format [format] # Output format (uses ESLint formatters)
-o, --output [output] # Write output to file path
# Behavior Control
-q, --no-exit # Do not exit with error code on failures
-s, --syntax [syntax] # Force syntax type (sass or scss)
--max-warnings [integer] # Maximum warnings before exit code 1Available Formats:
stylish (default) - Human-readable format with colorscompact - Compact single-line formatjson - JSON formatted outputjunit - JUnit XML formatcheckstyle - Checkstyle XML formattap - TAP (Test Anything Protocol) formatunix - Unix-style formatUsage Examples:
# Basic linting with verbose output
sass-lint '**/*.scss' -v
# Use custom config file
sass-lint -c .sass-lint.yml 'src/**/*.scss'
# Multiple ignore patterns
sass-lint -i 'vendor/**, node_modules/**' 'src/**/*.scss'
# JSON output to file
sass-lint -f json -o results.json 'src/**/*.scss'
# Force SCSS syntax and limit warnings
sass-lint -s scss --max-warnings 10 'src/**/*.css'
# No exit on errors (useful in CI)
sass-lint -q 'src/**/*.scss'sass-lint uses standard exit codes to indicate results.
# Exit Code Meanings
0 # Success - no errors found
1 # Failure - errors found or max warnings exceededCommand-line options override configuration file settings in this priority order:
.sass-lint.yml, .sasslintrc)sasslintConfig property# Single file
sass-lint styles.scss
# All SCSS files in directory
sass-lint '**/*.scss'
# Multiple patterns (space-separated)
sass-lint 'src/**/*.scss' 'components/**/*.sass'
# Specific directories
sass-lint 'src/' 'components/'
# Mixed file types
sass-lint '**/*.{scss,sass}'# CI/CD Integration
sass-lint '**/*.scss' -f json -o lint-results.json || exit 1
# Pre-commit Hook
sass-lint '**/*.scss' -q && echo "Sass lint passed"
# Build Script Integration
sass-lint 'src/**/*.scss' --max-warnings 0 -f compact
# Watch Mode (with external tools)
chokidar '**/*.scss' -c 'sass-lint {path}'# Common Exit Scenarios
sass-lint files... # Exit 1 if errors found
sass-lint -q files... # Never exit with error code
sass-lint --max-warnings 0 # Exit 1 if any warnings found
sass-lint --max-warnings 5 # Exit 1 if >5 warnings foundsass-lint automatically discovers configuration files in this order:
-c/--config option.sass-lint.yml in current directory or parent directories.sasslintrc in current directory or parent directoriessasslintConfig property in package.jsonStylish Format (Default):
src/components/button.scss
12:3 error Expected single space after ':' space-after-colon
15:1 warning Rule declaration should be followed by an empty line empty-line-between-blocks
✖ 2 problems (1 error, 1 warning)JSON Format:
[
{
"filePath": "src/components/button.scss",
"messages": [
{
"ruleId": "space-after-colon",
"severity": 2,
"message": "Expected single space after ':'",
"line": 12,
"column": 3
}
],
"errorCount": 1,
"warningCount": 0
}
]Compact Format:
src/components/button.scss: line 12, col 3, Error - Expected single space after ':' (space-after-colon)