CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-sass-lint

Node.js-based linting tool for Sass and SCSS files with 75+ configurable rules and both CLI and programmatic APIs.

Pending
Overview
Eval results
Files

cli.mddocs/

CLI Usage

The sass-lint command-line interface provides comprehensive linting capabilities for Sass and SCSS files with extensive configuration options and output formatting.

Capabilities

Basic Command

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 patterns

Command Options

Configure 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 1

Available Formats:

  • stylish (default) - Human-readable format with colors
  • compact - Compact single-line format
  • json - JSON formatted output
  • junit - JUnit XML format
  • checkstyle - Checkstyle XML format
  • tap - TAP (Test Anything Protocol) format
  • unix - Unix-style format

Usage 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'

Exit Codes

sass-lint uses standard exit codes to indicate results.

# Exit Code Meanings
0  # Success - no errors found
1  # Failure - errors found or max warnings exceeded

Configuration Priority

Command-line options override configuration file settings in this priority order:

  1. Command-line options (highest priority)
  2. Configuration file (.sass-lint.yml, .sasslintrc)
  3. package.json sasslintConfig property
  4. Default configuration (lowest priority)

File Pattern Examples

# 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}'

Integration Examples

# 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}'

Error Handling

# 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 found

Configuration File Discovery

sass-lint automatically discovers configuration files in this order:

  1. Path specified by -c/--config option
  2. .sass-lint.yml in current directory or parent directories
  3. .sasslintrc in current directory or parent directories
  4. sasslintConfig property in package.json
  5. Default built-in configuration

Output Examples

Stylish 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)

Install with Tessl CLI

npx tessl i tessl/npm-sass-lint

docs

api.md

cli.md

configuration.md

index.md

rules.md

tile.json