fix: migrate to ESLint flat config format#6
fix: migrate to ESLint flat config format#6CodeMonkeyCybersecurity wants to merge 3 commits intomainfrom
Conversation
Root cause: Global ESLint config at ~/eslint.config.mjs was taking precedence over project's legacy .eslintrc.json, causing TypeScript plugin errors in this JavaScript project. Contributing factor: .eslintrc.json contained invalid JSON (// comments) Changes: - Created eslint.config.js (flat config format) - Deleted .eslintrc.json (broken JSON with comments) - Updated package.json scripts (removed deprecated --ext flag) - Simplified pre-commit hook (config validation + lint-staged) - Added @eslint/js and globals dependencies - Added ESLint config validation tests - Added CI workflow steps for config validation - Created ADR-001 and RUNBOOK-eslint-config documentation - Updated CANONICAL.md with issue tracking See docs/adr/ADR-001-eslint-config-format.md for full rationale. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Husky v10 will fail if shim lines present. Removed per husky deprecation warning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Updated @eslint/js to v9.39.2 with breaking changes: - Minimum Node.js version now 18.18.0+ (was 12.22.0+) - Added TypeScript type definitions (types/index.d.ts) - Updated README with new flat config examples using defineConfig() - Added meta object with name/version to package exports - Added new rules: no-unassigned-vars, no-useless-assignment, preserve-caught-error - Removed deprecated rules: line-comment-position, multiline-comment
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import { join } from 'path'; | ||
| import { execSync } from 'child_process'; | ||
|
|
||
| const PROJECT_ROOT = join(import.meta.dirname, '../..'); |
There was a problem hiding this comment.
Avoid import.meta.dirname in Node 18 test runtime
CI runs tests on Node 18 (.github/workflows/test.yml matrix includes 18.x), but import.meta.dirname is only available in newer Node releases; on Node 18 it is undefined, so join(import.meta.dirname, '../..') will throw before any assertions run. This will break the test:coverage job on Node 18 that picks up this new test. Use fileURLToPath(new URL('.', import.meta.url)) or similar to compute the directory, or raise the Node minimum if you intend to require 20+.
Useful? React with 👍 / 👎.
Summary
Fixes ESLint pre-commit hook failure caused by global TypeScript ESLint config taking precedence over project config.
Root Cause Analysis (5 Whys)
@typescript-eslint/no-unused-expressionserror~/eslint.config.mjsextendstypescript-eslinteslint.config.*) takes precedence over legacy format (.eslintrc.*).eslintrc.jsonwhich was also broken (JSON with comments)Changes
eslint.config.js(flat config format) - takes precedence over global configs.eslintrc.json(contained invalid JSON with // comments)package.jsonscripts (removed deprecated--extflag).husky/pre-commit(config validation + lint-staged only)@eslint/jsandglobalsdependenciesTesting Added
tests/config/eslint-config.test.js:CI Updates
Documentation
Test Plan
npm run lintruns without TypeScript plugin errorsnpm run test -- tests/config/eslint-config.test.jspasses (17 tests)--no-verify@typescript-eslinterrors in outputUNIX Rules Applied
🤖 Generated with Claude Code