Skip to content

Conversation

Copy link

Copilot AI commented Oct 9, 2025

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 context methods have been replaced with their modern equivalents:

  • context.getSourceCode()context.sourceCode
  • context.getScope()sourceCode.getScope(node)

Previously, the codebase used fallback patterns for backward compatibility:

// Old approach with fallback
const sourceCode = context.sourceCode || context.getSourceCode();
const scope = sourceCode.getScope ? sourceCode.getScope(node) : context.getScope();

Now uses the direct ESLint v9 API:

// New ESLint v9 compatible approach
const sourceCode = context.sourceCode;
const scope = sourceCode.getScope(node);

Files Updated

Rules (6 files):

  • rules/detect-child-process.js
  • rules/detect-no-csrf-before-method-override.js
  • rules/detect-non-literal-fs-filename.js
  • rules/detect-non-literal-regexp.js
  • rules/detect-non-literal-require.js
  • rules/detect-unsafe-regex.js

Test utilities (2 files):

  • test/utils/import-utils.js
  • test/utils/is-static-expression.js

Testing

✅ 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

We need to update each rule that uses deprecated methods on context to use their replacements. See https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…lternatives

Co-authored-by: nzakas <38546+nzakas@users.noreply.github.com>
Copilot AI changed the title [WIP] Update rules to replace deprecated methods on context Replace deprecated ESLint context methods with v9 compatible alternatives Oct 9, 2025
Copilot finished work on behalf of nzakas October 9, 2025 20:58
Copilot AI requested a review from nzakas October 9, 2025 20:58
@nzakas
Copy link
Contributor

nzakas commented Oct 10, 2025

Looks like we already had handled these methods. opening a new PR for the newly removed methods in v10.

@nzakas nzakas closed this Oct 10, 2025
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