eslint-baseline
raw JSON → 0.4.0 verified Sat Apr 25 auth: no javascript
eslint-baseline (v0.4.0) is a tool to run ESLint with a baseline file, allowing legacy projects to adopt linting by ignoring existing errors. It creates a `.eslint-baseline.json` file storing known violations, and subsequent runs only report new errors. Key differentiators: hash-based error identification (improved location-based detection), simple CLI workflow, and explicit baseline update command. Released November 2024 with minor features; peer dependency on ESLint 8.x. In early development with unstable APIs.
Common errors
error Error: Cannot find module 'eslint' ↓
cause eslint is not installed or not in node_modules.
fix
Run
npm install --save-dev eslint (eslint is a peer dependency). error Error: Failed to load plugin 'xxx' declared in '.eslintrc' ↓
cause A required ESLint plugin is missing.
fix
Install the missing plugin, e.g.,
npm install --save-dev eslint-plugin-react. error Error: ESLint configuration is invalid: Unexpected top-level property "xxx" ↓
cause Invalid ESLint config file (e.g., .eslintrc.json).
fix
Check ESLint documentation for valid config properties; fix the config.
error Error: ENOENT: no such file or directory, open '.eslint-baseline.json' ↓
cause Baseline file not found; likely first run without --init or --update-baseline.
fix
Run
npx eslint-baseline --init or npx eslint-baseline --update-baseline. Warnings
breaking v0.3.0 introduced hash-based error identification; location-based baseline files from older versions are incompatible. ↓
fix Run eslint-baseline --update-baseline to regenerate baseline file.
deprecated Location-based error identification deprecated in favor of hash-based approach since v0.3.2. ↓
fix Update to latest version and regenerate baseline.
gotcha Editing files with existing errors may shift error locations, causing them to appear as new errors until baseline is updated. ↓
fix Run eslint-baseline --update-baseline after editing files to refresh baseline.
gotcha Programmatic API is not stable; breaking changes may occur without major version bump. ↓
fix Pin exact version and test updates.
Install
npm install eslint-baseline yarn add eslint-baseline pnpm add eslint-baseline Imports
- cli
npx eslint-baseline - default wrong
const eslintBaseline = require('eslint-baseline')correctimport eslintBaseline from 'eslint-baseline' - ESLintBaseline
import { ESLintBaseline } from 'eslint-baseline'
Quickstart
npm install --save-dev eslint eslint-baseline
npx eslint-baseline --init
echo "Add lint scripts to package.json:"
echo '"scripts": { "lint": "eslint-baseline .", "lint:update-baseline": "eslint-baseline --update-baseline ." }'
npm run lint
# Creates .eslint-baseline.json; subsequent runs only show new errors
npm run lint:update-baseline
# Updates baseline to include new errors