Skip to content
Latchkey

ESLint "context.getScope is not a function" - Version Mismatch in CI

A plugin called context.getScope() (or a similar context method) that does not exist on the ESLint version you are running. ESLint moved several context APIs across majors, so a plugin built for a different ESLint version crashes with a TypeError.

What this error means

ESLint crashes mid-run with TypeError: context.getScope is not a function (or getAncestors/getDeclaredVariables), with a stack pointing into a plugin's rule. It is a version mismatch, not flake.

eslint
TypeError: context.getScope is not a function
    at create (/app/node_modules/eslint-plugin-foo/lib/rules/bar.js:14:31)
    at Object.create (/app/node_modules/eslint/lib/linter/linter.js:...)

Common causes

Plugin built for a different ESLint major

ESLint 9 moved context.getScope() and related methods onto sourceCode. A plugin written for ESLint 8 (or vice versa) calls the old/new API that does not exist on the installed version.

Mismatched/duplicate ESLint versions

A tool pins one ESLint while a plugin resolves against another, so the plugin runs against a context from an incompatible ESLint copy.

How to fix it

Align the plugin with your ESLint major

Install the plugin release that supports your ESLint version (and dedupe ESLint).

Terminal
npm install eslint-plugin-foo@latest
npm ls eslint   # confirm a single, matching eslint version

Pin compatible versions together

  1. Upgrade ESLint and its plugins as a set, not piecemeal.
  2. Check each plugin's supported ESLint range before bumping ESLint.
  3. Deduplicate ESLint so plugins run against one version (npm dedupe).

How to prevent it

  • Upgrade ESLint and plugins together, checking supported ranges.
  • Keep a single ESLint version in the tree (npm ls eslint).
  • Pin majors so an ESLint upgrade is a deliberate, tested change.

Frequently asked questions

What causes ""context.getScope is not a function""?
ESLint 9 moved context.getScope() and related methods onto sourceCode. A plugin written for ESLint 8 (or vice versa) calls the old/new API that does not exist on the installed version.
How do I fix "context.getScope is not a function"?
Install the plugin release that supports your ESLint version (and dedupe ESLint).

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card