Skip to content

'TypeError: context.getAncestors is not a function' with ESLint v9 #2995

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

Closed
vpmedia opened this issue Apr 6, 2024 · 7 comments
Closed

'TypeError: context.getAncestors is not a function' with ESLint v9 #2995

vpmedia opened this issue Apr 6, 2024 · 7 comments

Comments

@vpmedia
Copy link

vpmedia commented Apr 6, 2024

After upgrading to ESLint v9 I'm getting the following exception:

TypeError: context.getAncestors is not a function
Occurred while linting PROJECT_DIR/eslint.config.js:1
Rule: "import/no-named-as-default"
    at importDeclaration (PROJECT_DIR/node_modules/eslint-plugin-import/lib/importDeclaration.js:2:27)
    at checkDefault (PROJECT_DIR/node_modules/eslint-plugin-import/lib/rules/no-named-as-default.js:21:62)
    at ruleErrorHandler (PROJECT_DIR/node_modules/eslint/lib/linter/linter.js:1145:48)
    at PROJECT_DIR/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (PROJECT_DIR/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (PROJECT_DIR/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (PROJECT_DIR/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (PROJECT_DIR/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
    at runRules (PROJECT_DIR/node_modules/eslint/lib/linter/linter.js:1184:40)

@RobinTail
Copy link

"eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8"

Compatibility issue: #2948

@sergeushenecz
Copy link

is it package will upgrade or no?

@ljharb
Copy link
Member

ljharb commented Apr 6, 2024

Just like with every eslint major, you basically always have to wait weeks or months to upgrade to it, until all the plugins and configs you depend on have had a chance to do so.

Closing as a duplicate of #2948. Thanks for the stack trace - that will help the effort to add compatibility.

@cameronmurphy
Copy link

I'm experiencing this exact stack trace with ESLint 9.11.0 and eslint-plugin-import 2.30.0 and I'm following the doco here

I can't comment on the broader ESLint v9 issue as it's locked.

@ljharb
Copy link
Member

ljharb commented Sep 23, 2024

@cameronmurphy the eslint 9 issue being still open means we don't support eslint 9 yet, so you simply can't use it with this plugin yet. Stick to eslint 8 for now.

hkamran80 added a commit to hkamran80/devtools that referenced this issue Oct 3, 2024
hkamran80 added a commit to hkamran80/devtools that referenced this issue Oct 3, 2024
* Remove `comma-dangle`

* Begin ESLint v9 rewrite, remove unused React config

* Switch to flat config

* Change `no-console` to `warn`

* Update package versions

* Update peer dependencies versions, move import to dependencies

* Mark as RC

* Disable `import/no-named-as-default`

See import-js/eslint-plugin-import#2995 and import-js/eslint-plugin-import#2556#issuecomment-2121423498

* Remove `plugins`

* Update `eslint-plugin-import`

In hindsight, I should have read the release notes and saw that the
PR wasn't released yet even though it was merged.

* Add typings

* Release version 2.0.0

* Add the types to `package.json`

* Add the ESLint configuration to the README
@Morriz
Copy link

Morriz commented Apr 1, 2025

and how about now-ish? hope hope

@ljharb
Copy link
Member

ljharb commented Apr 1, 2025

eslint 9 works with this plugin already. The only caveat is the no-unused-modules rule, which requires an empty .eslintrc at the root if you're using flat config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants