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.

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
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
npm install eslint-watch
yarn add eslint-watch
pnpm add eslint-watch

Initialize a project, install dependencies, create basic config, and run eslint-watch in watch mode.

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