Skip to content

Cover ESLint 10 token/comment and file-listing compat fallbacks#1

Merged
ljharb merged 2 commits into
rasmi:eslint-updatefrom
captaindonald:codecov-coverage-fix
Jun 27, 2026
Merged

Cover ESLint 10 token/comment and file-listing compat fallbacks#1
ljharb merged 2 commits into
rasmi:eslint-updatefrom
captaindonald:codecov-coverage-fix

Conversation

@captaindonald

@captaindonald captaindonald commented Jun 27, 2026

Copy link
Copy Markdown

Targets eslint-update so it folds into import-js#3230.

codecov/patch on import-js#3230 is red on a couple of the new v10 shims. Each getTokenOrComment{After,Before} helper in order feature-detects, and the sourceCode.getTokenOrComment* arm only runs pre-v8, so on the eslint version codecov reports from, only the v10 fallback arm gets hit. The ERR_PACKAGE_PATH_NOT_EXPORTED branch in listFilesToProcess isn't exercised at all.

I pulled the two getTokenOrComment{Before,After} shims out of order into src/core/getTokenOrComment.js and tested both arms with stub sourceCodes, so they're covered without leaning on the eslint-old matrix. They can't stay on the rule as named exports — rules are required and used directly, which only works while the file has a single default export. The ERR_PACKAGE_PATH_NOT_EXPORTED case is added to the existing listFilesToProcess fallback test next to MODULE_NOT_FOUND.

The order change is a straight move; its rule tests pass/fail identically before and after.

Move the `getTokenOrComment{Before,After}` feature-detection shims out of
the rule and into `src/core/getTokenOrComment.js` so both the legacy and
the `getToken{Before,After}({ includeComments: true })` branches can be
unit-tested directly. They cannot be exported from the rule module: the
plugin loads rules via `require`, which only yields the rule object while
the file has a single default export.
…fallbacks

Exercise both branches of the `getTokenOrComment{Before,After}` shims, and
the `listFilesToProcess` fallback to `listFilesWithNodeFs` when the legacy
`glob-utils` module is no longer exported (`ERR_PACKAGE_PATH_NOT_EXPORTED`,
eslint 10) in addition to the existing `MODULE_NOT_FOUND` case.
@ljharb
ljharb merged commit 02dc734 into rasmi:eslint-update Jun 27, 2026
2 checks passed
@captaindonald
captaindonald deleted the codecov-coverage-fix branch June 29, 2026 16:19
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.

2 participants