ESLint "Cannot read config file (.eslintrc)" - Fix Bad Config in CI
ESLint found the config file but could not read or parse it - invalid JSON/JS, a syntax error, or a file it cannot open. Config loading fails before any file is linted.
What this error means
ESLint aborts with Cannot read config file: /app/.eslintrc.json and an underlying parse error (e.g. Unexpected token } in JSON). It is deterministic and tied to the config file itself.
Cannot read config file: /app/.eslintrc.json
Error: Unexpected token } in JSON at position 142
at JSON.parse (<anonymous>)Common causes
Malformed JSON/JS in the config
A trailing comma, missing quote, or stray token makes .eslintrc.json invalid JSON, or a syntax error breaks .eslintrc.js.
Comments in a strict JSON config
.eslintrc.json is parsed as strict JSON (no comments); a // or /* */ comment makes it unreadable. Use .eslintrc.cjs/.js if you need comments.
How to fix it
Fix the config syntax
- Open the config at the reported position and correct the JSON/JS syntax (trailing comma, missing quote).
- Validate JSON with
node -e "require('./.eslintrc.json')"or a JSON linter. - Move to
.eslintrc.cjsif you need comments or dynamic logic.
Validate the config in CI before linting
Print the resolved config to confirm it loads.
npx eslint --print-config src/index.ts > /dev/null && echo "config OK"How to prevent it
- Keep
.eslintrc.jsonvalid JSON (no comments, no trailing commas). - Use
.eslintrc.cjswhen you need comments or logic. - Validate the config with
eslint --print-configin CI.