eslint-plugin-deprecation icon indicating copy to clipboard operation
eslint-plugin-deprecation copied to clipboard

ESLint v9 compatibility

Open karlhorky opened this issue 1 year ago • 7 comments

Currently, using [email protected], eslint-plugin-deprecation fails with the following error:

An unexpected error occurred:
TypeError: context.getAncestors is not a function
Occurred while linting /Users/k/p/project/eslint.config.js:1
Rule: "deprecation/deprecation"
    at getParent (/Users/k/p/project/node_modules/eslint-plugin-deprecation/dist/rules/deprecation.js:86:31)
    at isDeclaration (/Users/k/p/project/node_modules/eslint-plugin-deprecation/dist/rules/deprecation.js:94:20)
    at identifierRule (/Users/k/p/project/node_modules/eslint-plugin-deprecation/dist/rules/deprecation.js:60:13)
    at ruleErrorHandler (/Users/k/p/project/node_modules/eslint/lib/linter/linter.js:1059:28)
    at /Users/k/p/project/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/k/p/project/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/k/p/project/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/Users/k/p/project/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/Users/k/p/project/node_modules/eslint/lib/linter/node-event-generator.js:340:14)

It looks like there's a blog post about preparing rules for ESLint v9 here:

  • https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/

From a quick look, it appears that context.sourceCode.getAncestors(node) should be used instead.

karlhorky avatar Jan 06 '24 07:01 karlhorky