ihordiachenko / eslint-plugin-chai-friendly

Makes eslint friendly towards Chai.js 'expect' and 'should' statements.
MIT License
53 stars 10 forks source link

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

Closed jpzwarte closed 4 months ago

jpzwarte commented 5 months ago
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 commented 5 months ago

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

crfrolik commented 5 months ago

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 commented 5 months ago

@ihordiachenko

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

MikeMcC399 commented 5 months ago

@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 commented 5 months ago

@ihordiachenko

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

MikeMcC399 commented 5 months ago

@ihordiachenko

ihordiachenko commented 4 months ago

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

MikeMcC399 commented 4 months ago

@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! 👍🏻