Replace deprecated ESLint context methods with v9 compatible alternatives #178
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.
This PR updates all ESLint rules to use the new context API methods introduced in ESLint v9, as outlined in the ESLint v9 migration guide.
Changes
All deprecated
contextmethods have been replaced with their modern equivalents:context.getSourceCode()→context.sourceCodecontext.getScope()→sourceCode.getScope(node)Previously, the codebase used fallback patterns for backward compatibility:
Now uses the direct ESLint v9 API:
Files Updated
Rules (6 files):
rules/detect-child-process.jsrules/detect-no-csrf-before-method-override.jsrules/detect-non-literal-fs-filename.jsrules/detect-non-literal-regexp.jsrules/detect-non-literal-require.jsrules/detect-unsafe-regex.jsTest utilities (2 files):
test/utils/import-utils.jstest/utils/is-static-expression.jsTesting
✅ All 221 existing tests pass
✅ All linters pass (ESLint, Markdownlint, eslint-doc-generator)
✅ No deprecated method calls remain in the codebase
This change ensures the plugin is fully compatible with ESLint v9 and removes reliance on deprecated APIs.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.