Skip to content

build(npm): migrate ESLint to flat config and bump to v10 - #65

Merged
c-vigo merged 1 commit into
devfrom
chore/eslint-10-flat-config
Jul 14, 2026
Merged

c-vigo merged 1 commit into
devfrom
chore/eslint-10-flat-config

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Migrate ESLint to flat config + v10

Closes #64. Supersedes Renovate's #53, which could not work as a bump.

Why a bump wasn't enough

ESLint 9 made flat config the default; ESLint 10 removed the legacy .eslintrc
path entirely
, and ESLINT_USE_FLAT_CONFIG=false no longer opts back in:

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

There was a second blocker until recently: @[email protected] hard-crashed
under ESLint 10 (its bundled [email protected] yields a scope manager that ESLint 10's
SourceCode.finalize() rejects):

TypeError: scopeManager.addGlobals is not a function

#57 cleared that by bumping typescript-eslint to 8.64.0, whose peer range is
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0. So the plugin side was already ready; only the
config format was left.

What changed

  • .eslintrc.json → eslint.config.mjs. Faithful port, no intended behavior change:
    same base configs (eslint:recommended + typescript-eslint recommended), the same
    two rule overrides (no-explicit-any: warn, explicit-function-return-type: off), and
    the node/es6/jest envs re-expressed as languageOptions.globals (flat config has
    no env).
  • eslint 8.57 → 10.7.0.
  • @typescript-eslint/eslint-plugin + @typescript-eslint/parser → the typescript-eslint
    meta package. This is the canonical v8 flat-config entry point and composes the
    eslint-recommended rule-disables correctly, instead of us hand-wiring them. Both
    packages remain installed transitively.
  • Adds @eslint/js and globals (the flat-config equivalents of the extends and env
    keys that went away).

Node 24 satisfies ESLint 10's engines (^20.19.0 || ^22.13.0 || >=24).

Verification

  • npx eslint src — lints all 8 source files, rules firing correctly.
  • Negative control — injected const __probe: any = 1; let __unused = __probe; into
    src/commit.ts and confirmed ESLint caught it (prefer-const,
    @typescript-eslint/no-unused-vars, no-explicit-any), then reverted. The config is not
    silently linting nothing.
  • tsc clean · 84/84 tests pass · just precommit fully green.
  • dist/ untouched.

⚠️ Found while doing this: npm run lint has never linted the real source

Not introduced here, and not fixed here — filed separately.

The lint and format scripts use src/**/*.ts. npm runs scripts through sh, which has no
globstar, so ** degrades to * and the pattern collapses to src/*/*.ts:

$ sh -c 'echo src/**/*.ts'
src/__tests__/setup.ts

One file. src/commit.ts, src/commit-runner.ts, and src/retry.ts have never been
linted or formatted, and the "Lint & Format" CI job has been passing on that basis.

Running ESLint over the real tree surfaces 29 errors and 17 warnings across 8 files, and
prettier --list-different src reports all 8 files as unformatted. Most errors are
no-require-imports in test mocks (defensible in tests, needs a rule override). The only two
in production source are minor and neither is a correctness bug:

  • src/commit-runner.ts:177 — preserve-caught-error (no cause on a rethrow; new v10 rule)
  • src/commit.ts:85 — no-useless-assignment (dead initializer on bytesRead; harmless)

I deliberately kept that out of this PR: fixing the glob means triaging 46 findings and
reformatting the entire source, which has a different risk profile and would make both changes
unreviewable. This PR's ESLint 10 support is verified directly via npx eslint src regardless
of the script bug.

ESLint 9 made flat config the default; ESLint 10 removed the legacy `.eslintrc`
path entirely, and `ESLINT_USE_FLAT_CONFIG=false` no longer opts back in. So
eslint v10 cannot land as a dependency bump (Renovate's #53) — the config has to
move first.

Port `.eslintrc.json` to `eslint.config.mjs` with no intended behavior change:
same base configs (`eslint:recommended` + typescript-eslint `recommended`), the
same two rule overrides, and the node/es6/jest `env`s re-expressed as
`languageOptions.globals` (flat config has no `env`).

Replace `@typescript-eslint/eslint-plugin` + `@typescript-eslint/parser` with the
`typescript-eslint` meta package — the canonical v8 flat-config entry point, which
composes the `eslint-recommended` rule disables correctly rather than requiring us
to hand-wire them.

This is unblocked by #57, which bumped typescript-eslint to 8.64.0 (peer range
`eslint: ^8.57.0 || ^9.0.0 || ^10.0.0`). At 6.21.0 it hard-crashed under ESLint 10
with `TypeError: scopeManager.addGlobals is not a function`.

Verified: `npx eslint src` lints all 8 source files with rules firing (negative
control confirmed it catches an injected violation); tsc clean; 84/84 tests pass;
full prek suite green.

Note: `npm run lint` still only reaches one file, because the script's
`src/**/*.ts` glob is expanded by sh (no globstar) down to `src/*/*.ts`. That is a
pre-existing bug, not introduced here, and is left for a follow-up rather than
folded in — fixing it surfaces 29 errors and 17 warnings across the real source and
would reformat all 8 files, which does not belong in a config migration.

Refs: #64
@c-vigo
c-vigo merged commit 2595718 into dev Jul 14, 2026
9 checks passed
@c-vigo
c-vigo deleted the chore/eslint-10-flat-config branch July 14, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant