Browserslist Lint
raw JSON → 0.4.0 verified Fri May 01 auth: no javascript
Linter for Browserslist configuration files. Checks target browser queries against popular mistakes like missing 'not dead', ignoring browser diversity, or listing already dead browsers. Stable version 0.4.0, released frequently alongside Browserslist ecosystem. Integrates with CI via CLI or npx. Differentiator: opinionated rules to avoid common footguns when defining browser targets, with online checking at browsersl.ist.
Common errors
error Error: The default export is not available. Use named exports like { lint } instead. ↓
cause Attempted default import after v0.3.0 removed default export.
fix
Change to: import { lint } from 'browserslist-lint'
error Error: The 'path' option must be a string or file descriptor. ↓
cause Passed a config object as 'path' option instead of file path.
fix
Provide the file path string, e.g., { path: '.browserslistrc' }
error Error: Cannot find module 'picocolors' ↓
cause Missing dependency picocolors, which is a peer dependency.
fix
Install peer dependency: npm install picocolors
Warnings
breaking Dropped support for Node.js 14, 16, and 18 in v0.4.0. Requires Node.js >=20. ↓
fix Upgrade Node.js to version 20 or higher.
gotcha Default export removed in v0.3.0 in favor of named exports. ↓
fix Use import { lint } from 'browserslist-lint' instead of default import.
gotcha The lint function expects a 'path' option as string, not a parsed config object. Passing a config object will throw an error. ↓
fix Provide the file path string; to lint a string, use the 'config' option instead.
Install
npm install browserslist-lint yarn add browserslist-lint pnpm add browserslist-lint Imports
- lint wrong
import lint from 'browserslist-lint'correctimport { lint } from 'browserslist-lint' - LintOptions wrong
import { Options } from 'browserslist-lint'correctimport { LintOptions } from 'browserslist-lint' - LintResult
import { LintResult } from 'browserslist-lint'
Quickstart
// install: npm install browserslist-lint
import { lint } from 'browserslist-lint';
async function main() {
try {
const result = await lint({
path: '.browserslistrc', // path to config file
ignoreMissing: false, // fail on 'not dead' missing
ignoreLimited: false, // fail on limited browser names
});
if (result.warnings.length > 0) {
console.log('Lint warnings:', result.warnings);
} else {
console.log('No issues found.');
}
} catch (err) {
console.error('Lint error:', err.message);
}
}
main();