Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint v9 compatibility #78

Open
Tracked by #18093
karlhorky opened this issue Jan 6, 2024 · 5 comments · May be fixed by #79
Open
Tracked by #18093

ESLint v9 compatibility #78

karlhorky opened this issue Jan 6, 2024 · 5 comments · May be fixed by #79

Comments

@karlhorky
Copy link
Contributor

Currently, using eslint@9.0.0-alpha.0, 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:

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

@gund
Copy link
Owner

gund commented Jan 6, 2024

@karlhorky thanks for testing it with eslint v9!

Indeed there are some BC that have to be addressed in order to support v9.

If you like you are welcome to create a PR to fix this piece of code but it should be done in backwards compatible way just like they show in example, so we can keep supporting all previous eslint versions.

Also if you decide to make a PR it would be necessary to update CI workflows to test this rule against both eslint v8 and v9, just like we already do with previous versions. But if you are not comfortable doing it no worries, I can adjust it on your PR as well 😊

@gund gund linked a pull request Jan 8, 2024 that will close this issue
6 tasks
@gund
Copy link
Owner

gund commented Jan 8, 2024

Did some initial work on the v9 support but in general it's not possible to use it due to upstream dependencies not supporting it yet.

@stianjensen
Copy link
Contributor

typescript-eslint are at least preparing for it now, but this lib may need to also upgrade @typescript-eslint/utils to 7.x first.

https://typescript-eslint.io/blog/announcing-typescript-eslint-v7/

They are dropping support for older typescript, node and eslint versions in that major (but otherwise it is unchanged). I look into adding support here for 6.x and 7.x at the same time, but I'm not sure that can work nicely without being a breaking change, due to how npm resolution works. As long as this library itself wants to support older eslint and node versions than typescript-eslint 7.x I'm not sure we can just add 7.x to the list of supported versions next to 6.x?

@maranomynet
Copy link
Contributor

Another data point:
I'm upgrading my eslint@8.57 config to use "flat config" and the @ts-check flags this plugin being incorrectly typed.

@Shinigami92
Copy link

How is work going forward? This is blocking us from upgrading to eslint v9 and we cant already upgrade eslint-plugin-vitest >=0.5 due to this

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 a pull request may close this issue.

5 participants