Skip to content

chore(lint): eslint config comment inverts the "type": "module" rule, and ecmaVersion 2021 caps flat config's default #255

Description

@lv10

Follow-up from the review of #240 (merged), which migrated eslint 8 -> 9 and added a flat config. Two items in eslint.config.mjs, neither affecting current behaviour.

1. The comment inverts the rule it states

eslint.config.mjs currently opens with:

// Flat-config port of the previous .eslintrc. The .mjs extension is required:
// this package is "type": "module".

That is backwards. package.json does declare "type": "module", and that is precisely the case where the .mjs rename is not required — a plain eslint.config.js is already parsed as ESM, so eslint loads it as-is. .mjs is what a CommonJS package needs, in order to write an ESM config in a package whose .js files are CJS.

The reviewer verified this empirically: renaming the file to eslint.config.js and running eslint loaded it fine.

Fix: either rename to eslint.config.js and delete the comment, or keep .mjs (harmless, and eslint resolves it) and correct the comment to say it is a stylistic choice rather than a requirement. Leaving the inverted claim in place will mislead whoever ports the next repo by copying this file.

2. ecmaVersion: 2021 is now the only thing capping the parser

languageOptions: {
  ecmaVersion: 2021,
  sourceType: 'module',
  ...
}

2021 was carried over faithfully from the old .eslintrc, which is the right default for a migration PR — it preserves behaviour. But flat config defaults ecmaVersion to latest, so under .eslintrc the cap was one setting among the file's inherited defaults, and now it is an explicit and deliberate-looking restriction. Nothing in the repo needs post-2021 syntax today, so this is not breaking anything; it just means the next person to use, say, Array.prototype.at chaining or newer syntax hits a parse error for no reason.

Fix: drop the ecmaVersion line and let it default to latest. globals.es2021 in the same block can stay or move to globals.es2025 independently — it controls globals, not syntax.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions