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

context.getAncestors is not a function with eslint 9.0.0 #32

Closed
Tracked by #65
jpzwarte opened this issue Apr 15, 2024 · 8 comments · Fixed by #33
Closed
Tracked by #65

context.getAncestors is not a function with eslint 9.0.0 #32

jpzwarte opened this issue Apr 15, 2024 · 8 comments · Fixed by #33

Comments

@jpzwarte
Copy link

jpzwarte commented Apr 15, 2024

Oops! Something went wrong! :(

ESLint: 9.0.0

TypeError: context.getAncestors is not a function
Occurred while linting /accordion/src/accordion.spec.ts:37
Rule: "chai-friendly/no-unused-expressions"
    at ExpressionStatement (/Users/jzwartepoorte/Projects/components/node_modules/eslint-plugin-chai-friendly/lib/rules/no-unused-expressions.js:262:50)

Works fine with eslint 8.57.0

Uses version 0.7.4 of the plugin.

@ihordiachenko
Copy link
Owner

Hi @jpzwarte! Will look into eslint 9 compatibility this week

@crfrolik
Copy link

Just encountered this. Is there a workaround?

Oops! Something went wrong! :(

ESLint: 9.1.1

TypeError: context.getAncestors is not a function
Occurred while linting [...]/test/common-helpers.ts:240
Rule: "chai-friendly/no-unused-expressions"
    at ExpressionStatement ([...]/test/node_modules/eslint-plugin-chai-friendly/lib/rules/no-unused-expressions.js:262:50)
    at ruleErrorHandler ([...]/test/node_modules/eslint/lib/linter/linter.js:1115:48)
    at [...]/test/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit ([...]/test/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector ([...]/test/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors ([...]/test/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode ([...]/test/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
    at runRules ([...]/test/node_modules/eslint/lib/linter/linter.js:1154:40)
    at Linter._verifyWithFlatConfigArrayAndWithoutProcessors ([...]/test/node_modules/eslint/lib/linter/linter.js:1880:31)

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented May 4, 2024

@ihordiachenko

https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/ gives a code example for updating
context.getAncestors() so that it is compatible with ESLint >= 9.0.0 and earlier versions.

@MikeMcC399
Copy link
Contributor

@crfrolik

Just encountered this. Is there a workaround?

Oops! Something went wrong! :(

ESLint: 9.1.1

TypeError: context.getAncestors is not a function

ESLint published the Blog post Introducing ESLint Compatibility Utilities yesterday announcing a new utility @eslint/compat to work around compatibility issues like this.

@MikeMcC399
Copy link
Contributor

@ihordiachenko

Would you like a PR to fix this issue or are you already planning to do it yourself?

@MikeMcC399
Copy link
Contributor

@ihordiachenko

@ihordiachenko
Copy link
Owner

@MikeMcC399 released in eslint-plugin-chai-friendly@0.8.0

@MikeMcC399
Copy link
Contributor

@ihordiachenko

released in eslint-plugin-chai-friendly@0.8.0

Thank you very much! I am just testing with Cypress and ESLint v9 flat configuration and it all looks good! 👍🏻

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.

4 participants