eslint-plugin-chai-friendly
eslint-plugin-chai-friendly copied to clipboard
`context.getAncestors is not a function` with eslint 9.0.0
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.
Hi @jpzwarte! Will look into eslint 9 compatibility this week
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)
@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.
@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.
@ihordiachenko
Would you like a PR to fix this issue or are you already planning to do it yourself?
@ihordiachenko
- I went ahead and submitted PR https://github.com/ihordiachenko/eslint-plugin-chai-friendly/pull/33 to resolve this issue.
@MikeMcC399 released in [email protected]
@ihordiachenko
released in
[email protected]
Thank you very much! I am just testing with Cypress and ESLint v9 flat configuration and it all looks good! 👍🏻