eslint-watch
raw JSON → 8.0.0 verified Sat Apr 25 auth: no javascript
A command-line tool that wraps ESLint with file watching capabilities and improved CLI options. Current stable version is v8.0.0, requiring ESLint >=8 and Node >=12.22.0. Regularly releases new versions matching ESLint major releases. Key differentiator: standalone watcher without needing Webpack, Grunt, or other build tools. Provides watch modes, single-file linting on change, terminal clearing, ignore patterns for watching, and configurable watch delay. All standard ESLint options are forwarded unmodified.
Common errors
error Error: Cannot find module 'eslint' ↓
cause eslint is not installed as a dependency in the project.
fix
Run
npm install -D eslint in the project directory. error Error: Cannot find module 'eslint-watch' ↓
cause eslint-watch is not installed.
fix
Run
npm install -D eslint-watch (or global install) and ensure node_modules/.bin is in PATH. error esw: command not found ↓
cause eslint-watch is not installed globally or locally, or the bin path is not in PATH.
fix
Install locally (
npm install -D eslint-watch) and run via npx: npx esw Warnings
breaking Dropped support for Node.js 10 and ESLint <8 in v8.0.0 ↓
fix Upgrade to Node.js >=12.22.0, ^14.17.0, or >=16.0.0 and ESLint >=8
breaking Dropped support for Node.js 8 and ESLint <7 in v7.0.0 ↓
fix Upgrade to Node.js >=10.12.0 and ESLint >=7
deprecated --esw-version flag removed in v5.0.0; use --version or --versions instead ↓
fix Use --version to show eslint-watch version or --versions to show both ESLint and eslint-watch versions
gotcha Watch mode may double-lint if .eslintcache is not ignored by default (fixed in v6.0.1) ↓
fix Add .eslintcache to watch-ignore or upgrade to v6.0.1+
gotcha Default watch ignore pattern includes .git, node_modules, bower_components, and .eslintcache; custom ignores via --watch-ignore ↓
fix Use --watch-ignore flag to add additional ignore patterns as regex strings
Install
npm install eslint-watch yarn add eslint-watch pnpm add eslint-watch Imports
- esw (CLI command) wrong
eslint --watchcorrectnpx esw --watch - require('eslint-watch') wrong
import esw from 'eslint-watch';correctconst esw = require('eslint-watch'); - @types/eslint-watch wrong
npm install @types/eslint-watchcorrectnpm install -D @types/eslint-watch
Quickstart
npm init -y
npm install -D eslint eslint-watch
# create a .eslintrc.json:
echo '{"env": {"node": true, "es2020": true}, "extends": "eslint:recommended"}' > .eslintrc.json
# add a script to package.json:
node -e "const p=require('./package.json'); p.scripts.lint='esw . --watch'; require('fs').writeFileSync('./package.json', JSON.stringify(p,null,2))"
npm run lint