lint-filter

raw JSON →
1.7.3 verified Fri May 01 auth: no javascript maintenance

A CLI tool that filters lint output (e.g., ESLint checkstyle) to show only errors/warnings on lines changed relative to a git branch (default master). Useful for gradually adopting strict lint rules without breaking existing code. Version 1.7.3 is stable, released 2016-5-17. Supports external formatters, environment variable configuration, and a 'list-files' subcommand for faster linting. Alternative to eslint-nibble or incremental linting approaches.

error Error: Cannot find module 'bluebird'
cause Missing dependency bluebird (fixed in v1.0.1).
fix
Install lint-filter >=1.0.1 or manually install bluebird.
error lint-filter: command not found
cause Global install or npx not used.
fix
Run 'npx lint-filter' or install globally with 'npm install -g lint-filter'.
error Error: ENOENT: no such file or directory, open 'path/to/checkstyle-report.xml'
cause File path does not exist.
fix
Ensure the file exists or pipe input via stdin.
gotcha diff-so-fancy compatibility: lint-filter may not detect lines correctly if you use diff-so-fancy. Works since v1.6.2.
fix Upgrade to >=1.6.2 or avoid diff-so-fancy.
deprecated The 'require:' prefix for external formatters may not work as expected if the module path is relative.
fix Use an absolute path or install the module globally.
gotcha Only lines that are changed, not context lines, are considered (since v1.6.3). This might miss errors on lines adjacent to changes.
fix If you need context lines, consider writing a custom script or downgrade.
npm install lint-filter
yarn add lint-filter
pnpm add lint-filter

Shows how to install lint-filter, set up a minimal ESlint config, commit code, then see filtered lint output for only new lines.

npm install --save-dev lint-filter
echo '{"rules":{"no-console":"error"}}' > .eslintrc.json
# Create a file with lint errors
echo 'console.log("hello");' > test.js
git init && git add -A && git commit -m "init"
# Introduce a change
echo 'console.log("world");' >> test.js
# Run eslint with checkstyle and pipe to lint-filter
eslint . -f checkstyle | npx lint-filter