grunt-sass-lint
raw JSON → 0.2.4 verified Fri May 01 auth: no javascript deprecated
Grunt plugin for Node Sass Lint. Version 0.2.4 (latest as of 2021) is the final release; the package is unmaintained and sass-lint is deprecated in favor of stylelint. It allows linting .scss and .sass files with configurable rules, provides multiple formatters (stylish, junit, etc.), and integrates directly into Grunt workflows. However, both the plugin and its underlying linter are no longer active; stylelint with scss plugin is the recommended replacement.
Common errors
error Running "sasslint" task Fatal error: Unable to find a valid config file format. ↓
cause No .sass-lint.yml found and no configFile option set.
fix
Add configFile: '.sass-lint.yml' to the sasslint options.
error Warning: Task "sasslint" not found. Use --force to continue. ↓
cause grunt.loadNpmTasks('grunt-sass-lint') missing or package not installed.
fix
Run
npm install grunt-sass-lint --save-dev and add grunt.loadNpmTasks('grunt-sass-lint'); to Gruntfile. error Fatal error: Cannot find module 'sass-lint' ↓
cause sass-lint peer dependency not installed.
fix
Run
npm install sass-lint --save-dev alongside grunt-sass-lint. Warnings
deprecated sass-lint is deprecated; use stylelint with @stylelint/stylelint-scss instead. ↓
fix Migrate to stylelint and use stylelint-scss plugin for SCSS linting.
deprecated Grunt-sass-lint is no longer maintained; no updates since 2018. ↓
fix Move to a different task runner or use stylelint directly via CLI or Grunt-stylelint plugin.
gotcha configFile option falls back to .sass-lint.yml in project root or 'sasslintConfig' in package.json, but if none exist, the task fails silently. ↓
fix Always specify a configFile option or create a .sass-lint.yml file.
gotcha The 'target' property must be an array of file patterns; passing a string causes unexpected behavior. ↓
fix Always use an array: target: ['src/**/*.scss'].
breaking Node.js >=0.10.0 required; versions below 4.0 lack error handling for some sass-lint output. ↓
fix Use Node.js >=4.0.0 for reliable error reporting.
Install
npm install grunt-sass-lint yarn add grunt-sass-lint pnpm add grunt-sass-lint Imports
- grunt-sass-lint wrong
grunt.loadNpmTasks('grunt-sasslint');correctgrunt.loadNpmTasks('grunt-sass-lint'); - sasslint wrong
grunt.initConfig({ sasslint: { ... } });correctgrunt.initConfig({ sasslint: { ... } }); - options wrong
sasslint: { options: { configFile: '.sass-lint.yml' } }correctsasslint: { options: { configFile: '.sass-lint.yml', formatter: 'junit' }, target: ['src/**/*.scss'] }
Quickstart
module.exports = function(grunt) {
grunt.initConfig({
sasslint: {
options: {
configFile: '.sass-lint.yml',
formatter: 'stylish'
},
target: ['src/**/*.scss']
}
});
grunt.loadNpmTasks('grunt-sass-lint');
grunt.registerTask('default', ['sasslint']);
};