Summary
eslint-plugin-ember fails with ESLint 10 due to the removed context.getSourceCode() API.
Error
TypeError: Error while loading rule 'ember/avoid-leaking-state-in-ember-objects': context.getSourceCode is not a function
Occurred while linting /path/to/file.gts
at Object.create (/node_modules/eslint-plugin-ember/lib/rules/avoid-leaking-state-in-ember-objects.js:83:32)
Environment
- eslint-plugin-ember: 12.7.5
- eslint: 10.0.0
Details
ESLint 10 removed the deprecated context.getSourceCode() method. Rules should use context.sourceCode property instead.
See ESLint migration guide: https://eslint.org/docs/latest/use/migrate-to-10.0.0
Suggested Fix
Replace all occurrences of context.getSourceCode() with backward-compatible access:
// Before
const sourceCode = context.getSourceCode();
// After (works with ESLint 8, 9, and 10)
const sourceCode = context.sourceCode ?? context.getSourceCode();
// Or if dropping ESLint <9 support:
const sourceCode = context.sourceCode;
Affected files likely include any rule using getSourceCode() in lib/rules/.
Summary
eslint-plugin-emberfails with ESLint 10 due to the removedcontext.getSourceCode()API.Error
Environment
Details
ESLint 10 removed the deprecated
context.getSourceCode()method. Rules should usecontext.sourceCodeproperty instead.See ESLint migration guide: https://eslint.org/docs/latest/use/migrate-to-10.0.0
Suggested Fix
Replace all occurrences of
context.getSourceCode()with backward-compatible access:Affected files likely include any rule using
getSourceCode()inlib/rules/.