Bug: Parse error when using FlatCompat in new flat config #17953
Labels
3rd party plugin
This is an issue related to a 3rd party plugin, config, or parser
bug
ESLint is working incorrectly
repro:needed
Environment
Node version: 18.19.0
npm version: 9.5.1
Local ESLint version: 8.56.0
Global ESLint version: n/a
Operating System: macos
What parser are you using?
Default (Espree)
What did you do?
Configuration
What did you expect to happen?
eslint-config-airbnb-base
internally useseslint-plugin-import
. When using theFlatCompat
utility to useeslint-config-airbnb-base
in my new flat config format, I'm getting the following error, which I'm not getting with the old eslint configuration format:I found this confusing, because it does work in the old config format. But it seems like with the new config format, each config object that you export in the array thats exported in
eslint.config.js
, requires their ownparserPath
orlanguageOptions.parser
, is that assumption correct? Previously we configured the parser in one place, and when extending that, it applied to everything else. (as far as my understanding goes)I tried to look into the code a little bit to see whats happening, and it seems like the
FlatCompat
utility creates the following object foreslint-plugin-import
specifically:Note that there's no
parserPath
orlanguageOptions.parser
present. There is alanguageOptions.parser
present in other objects of the config, however, but as mentioned above, it seems like that's not getting applied to other objects in the exported flat config array.When I looked into the code, I saw that the error is thrown in
eslint-module-utils
:And in the
getParserPath
I see the following:Judging on the comment, it seems like it should have defaulted to eslints parser, but that is undefined:
I'm not too familiar with ESLint's internals, but this feels like it could potentially be a bug, so I figured I'd report it.
So two main questions are:
eslint.config.js
needs to configure their own parser options?eslint-plugin-import
?)What actually happened?
See explanation above
Link to Minimal Reproducible Example
https://stackblitz.com/edit/stackblitz-starters-g64xvt?file=eslint.config.js
Participation
Additional comments
Open the stackblitz and run
npm run lint
in the terminal to see the result:The text was updated successfully, but these errors were encountered: