grunt-lesshint
raw JSON → 2.0.0 verified Fri May 01 auth: no javascript maintenance
Lint LESSCSS files with Grunt. Version 2.0.0 requires Node >= 4.0.0 and Grunt ~0.4.5. This plugin integrates the lesshint linter into the Grunt build system, providing a task named 'lesshint' for checking LESS files. Options include force (continue on errors), reporter (custom error formatting), lesshintrc (configuration file), and allowWarnings (allow warnings without failure). Release history shows updates to lesshint v3.0.0 and support for custom reporters and allowing warnings. Less frequently updated; last release 2017.
Common errors
error Warning: Task "lesshint" not found. ↓
cause Forgot to call grunt.loadNpmTasks('grunt-lesshint');
fix
Add grunt.loadNpmTasks('grunt-lesshint'); in Gruntfile.
error Fatal error: lesshint is not a function ↓
cause Incompatible lesshint version or missing peer dep.
fix
npm install lesshint@3.0.0 --save-dev and ensure version matches plugin.
Warnings
gotcha Task 'lesshint' fails build on lint errors by default. ↓
fix Set 'force: true' in options to continue despite errors.
gotcha Requires Grunt ~0.4.5; incompatible with Grunt 1.x? ↓
fix Check package.json peerDependencies; use Grunt 0.4.5 or later but note v1.2.0+ compatible with Grunt 1.0.0.
deprecated Not updated since 2017; lesshint may have breaking changes. ↓
fix Consider migrating to standalone lesshint or an alternative linter.
Install
npm install grunt-lesshint yarn add grunt-lesshint pnpm add grunt-lesshint Imports
- grunt-lesshint task wrong
const lesshint = require('grunt-lesshint');correctgrunt.loadNpmTasks('grunt-lesshint'); - LesshintTaskConfig wrong
grunt.initConfig({ lesshint: { ... } }) is correct; no separate import for config type.correct// Define task in grunt.initConfig lesshint: { options: {}, your_target: { src: ['**/*.less'] } }
Quickstart
// Install: npm install grunt-lesshint --save-dev
// In Gruntfile:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-lesshint');
grunt.initConfig({
lesshint: {
options: {
force: true,
lesshintrc: true
},
all: {
src: ['src/**/*.less']
}
}
});
grunt.registerTask('default', ['lesshint']);
};