gulp-lesshint

raw JSON →
6.1.0 verified Fri May 01 auth: no javascript

Gulp plugin integrating lesshint, a linting tool for Less stylesheets. Version 6.1.0 (stable) is the latest release; development is active with periodic updates. Provides a stream-based pipeline for linting .less files with configurable rules, custom reporters, and fail-on-error/warning functionality. Alternatives include gulp-lesshint's direct integration vs standalone lesshint CLI, but this plugin offers seamless gulp integration without additional tooling.

error Error: Cannot find module 'lesshint'
cause lesshint not installed or not in node_modules
fix
npm install lesshint --save-dev
error TypeError: lesshint.reporter is not a function
cause Using lesshint.reporter before calling lesshint() or importing incorrectly
fix
Ensure you require('gulp-lesshint') and call lesshint() first: const lesshint = require('gulp-lesshint'); ... .pipe(lesshint()).pipe(lesshint.reporter('stylish'))
error Error: Config file not found: .lesshintrc
cause lesshint expects a configuration file but none exists in the project root
fix
Create a .lesshintrc file in project root or specify configPath option with absolute path.
gotcha failOnWarning() does not respect maxWarnings option; it fails on any warning regardless of count.
fix Use failOnError() for error-only failures, or implement custom logic to check warnings count vs maxWarnings after pipe.
deprecated Use of .lesshintrc.json filename deprecated in favor of .lesshintrc (no extension) in newer lesshint versions.
fix Rename config file to .lesshintrc or specify configPath option.
gotcha lesshint property on file object is undefined if lesshint() pipe is not used before accessing.
fix Ensure lesshint() is piped before reading file.lesshint.
breaking lesshint peer dependency changed from lesshint@^2 to lesshint@^3 in version 4.0.0; may cause incompatibility.
fix Update lesshint to version ^3.x; check for breaking rule changes.
npm install gulp-lesshint
yarn add gulp-lesshint
pnpm add gulp-lesshint

Defines a Gulp task that lints all .less files in src/, using a custom config, limiting warnings to 10, reporting with stylish reporter, and failing on errors.

const gulp = require('gulp');
const lesshint = require('gulp-lesshint');

exports.lint = () => {
    return gulp.src('./src/*.less')
        .pipe(lesshint({
            configPath: './.lesshintrc',
            maxWarnings: 10
        }))
        .pipe(lesshint.reporter('lesshint-reporter-stylish'))
        .pipe(lesshint.failOnError());
};