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

Support for upcoming ESLint FlatConfig #213

Closed
ScrapsPrograms opened this issue Feb 18, 2023 · 1 comment · Fixed by #220
Closed

Support for upcoming ESLint FlatConfig #213

ScrapsPrograms opened this issue Feb 18, 2023 · 1 comment · Fixed by #220

Comments

@ScrapsPrograms
Copy link

I've got a new project going, where I'm experimenting with the new FlatConfig option.

Trying to import eslint-import-resolver-typescript into the config file results in the following error:

Uncaught exception received.
file:///C:/Users/scrap/Reps/MiaTickets-API/node_modules/eslint-import-resolver-typescript/lib/index.js:5
import { CachedInputFileSystem, ResolverFactory, } from 'enhanced-resolve';
         ^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'CachedInputFileSystem' not found. The requested module 'enhanced-resolve' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'enhanced-resolve';
const { CachedInputFileSystem, ResolverFactory, } = pkg;

This seems to be due to enhanced-resolve being CommonJS. My project is written with ES Modules, essentially breaking this package.

As a temporary workaround, I've gone back to importing eslint-plugin-import, accepting the lack of type information.
To make this work, however, it's apparently needed to add this little line to the settings object:

"import/parsers": {
  "espree": [".js", ".cjs", ".mjs", ".jsx"],
  typescript: [importPlugin.configs.typescript.settings["import/parsers"].typescript]
}
@ScrapsPrograms
Copy link
Author

I've found this little line of code also helps a great deal, making my previous workaround suggestion of setting "espree" in the parsers option completely redundant..

image

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

Successfully merging a pull request may close this issue.

1 participant