lesslint
raw JSON → 1.0.3 verified Fri May 01 auth: no javascript maintenance
A Less CSS linter for checking code quality and style consistency. Version 1.0.3 (stable, low release cadence). Integrates with Less syntax checking, offering rule-based validation. Differentiated by being one of few dedicated Less linters, though development is sparse compared to stylelint with Less plugins.
Common errors
error Error: Cannot find module 'less' ↓
cause Missing peer dependency 'less'.
fix
npm install less
error TypeError: lesslint.lint is not a function ↓
cause Using CJS require with ESM-only package.
fix
Change to import lesslint from 'lesslint'.
error SyntaxError: Unexpected token '.' (when importing) ↓
cause Package is ESM but project is CJS.
fix
Set "type": "module" in package.json or use dynamic import().
Warnings
gotcha lesslint requires the 'less' package as a peer dependency; not installing it leads to runtime errors. ↓
fix Run 'npm install less' alongside lesslint.
gotcha lesslint is ESM-only; CommonJS require will fail with Module 'lesslint' does not provide an export named 'default'. ↓
fix Use import instead of require, or set type: "module" in package.json.
deprecated The 'rules' export is deprecated as of 1.0.3; it may be removed in future versions. ↓
fix Access rules directly from linter instance or use custom configuration.
breaking Version 1.0.0 removed the synchronous lint() API; all methods are now async. ↓
fix Update code to use async/await or promises.
Install
npm install lesslint yarn add lesslint pnpm add lesslint Imports
- lesslint wrong
const lesslint = require('lesslint')correctimport lesslint from 'lesslint' - Linter wrong
import Linter from 'lesslint/Linter'correctimport { Linter } from 'lesslint' - rules wrong
const rules = require('lesslint').rulescorrectimport { rules } from 'lesslint' - less wrong
const less = require('less')correctimport less from 'less'
Quickstart
import lesslint from 'lesslint';
import less from 'less';
const code = `@color: red;\n.class { color: @color; }`;
lesslint.lint(code).then(result => {
console.log(result.messages);
}).catch(err => console.error(err));