Cover ESLint 10 token/comment and file-listing compat fallbacks#1
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Targets
eslint-updateso 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 inorderfeature-detects, and thesourceCode.getTokenOrComment*arm only runs pre-v8, so on the eslint version codecov reports from, only the v10 fallback arm gets hit. TheERR_PACKAGE_PATH_NOT_EXPORTEDbranch inlistFilesToProcessisn't exercised at all.I pulled the two
getTokenOrComment{Before,After}shims out oforderintosrc/core/getTokenOrComment.jsand tested both arms with stubsourceCodes, so they're covered without leaning on the eslint-old matrix. They can't stay on the rule as named exports — rules arerequired and used directly, which only works while the file has a single default export. TheERR_PACKAGE_PATH_NOT_EXPORTEDcase is added to the existinglistFilesToProcessfallback test next toMODULE_NOT_FOUND.The
orderchange is a straight move; its rule tests pass/fail identically before and after.