gulp-lesshint
raw JSON → 4.1.3 verified Fri May 01 auth: no javascript
Gulp plugin for linting .less files using lesshint. Current stable version is 4.1.3. It runs the lesshint linter on source files and provides reporter and failOnError functionality for Gulp pipelines. Key differentiators: integrates smoothly with Gulp, supports custom config path, maxWarnings, and multiple reporters. Compared to other Less linters (e.g., stylelint with less syntax), it is dedicated to Less and uses lesshint's own rules.
Common errors
error Error: Cannot find module 'gulp-lesshint' ↓
cause Package is not installed in node_modules.
fix
Run: npm install gulp-lesshint --save-dev
error TypeError: lesshint.reporter is not a function ↓
cause Module may be imported incorrectly (e.g., trying to use default import instead of require).
fix
Use: const lesshint = require('gulp-lesshint');
error Error: No reporter found for '<reporter-name>' ↓
cause The specified reporter name does not correspond to an installed package or invalid name.
fix
Install the reporter package: npm install lesshint-reporter-<name> --save-dev
error TypeError: lesshint.failOnError is not a function ↓
cause Using an older version of this plugin (<4.0.0) where failOnError may not exist.
fix
Update to the latest version: npm install gulp-lesshint@latest --save-dev
error Error: lesshint is not a function ↓
cause lesshint peer dependency not installed.
fix
Run: npm install lesshint --save-dev
Warnings
gotcha This package is a Gulp plugin and requires Node.js and Gulp. It is not a standalone linter. ↓
fix Ensure Gulp is installed and Gulp tasks are properly defined.
deprecated lesshint.reporter() without arguments still uses default 'lesshint-reporter-stylish' but may be deprecated in future versions. ↓
fix Explicitly pass 'stylish' or a custom reporter name.
breaking Version 4.x drops support for Node.js <10. ↓
fix Upgrade Node.js to version 10 or higher.
breaking lesshint.failOnError() no longer accepts arguments since v4. ↓
fix Remove any arguments passed to failOnError() call.
gotcha lesshint must be installed separately as a peer dependency; it is not bundled. ↓
fix Run: npm install lesshint --save-dev
Install
npm install xl-gulp-lesshint yarn add xl-gulp-lesshint pnpm add xl-gulp-lesshint Imports
- default (lesshint function) wrong
import lesshint from 'gulp-lesshint'; // This package does not export a default ESM export.correctconst lesshint = require('gulp-lesshint'); - lesshint.reporter wrong
.pipe(lesshint.reporter()) // Works, but uses default stylish. Accepts string or function.correct.pipe(lesshint.reporter('stylish')) - lesshint.failOnError wrong
nonecorrect.pipe(lesshint.failOnError())
Quickstart
const gulp = require('gulp');
const lesshint = require('gulp-lesshint');
function lint() {
return gulp.src('src/**/*.less')
.pipe(lesshint({ configPath: '.lesshintrc' }))
.pipe(lesshint.reporter('lesshint-reporter-stylish'))
.pipe(lesshint.failOnError());
}
exports.lint = lint;