Skip to content

Support for upcoming ESLint FlatConfig #213

Closed

Description

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]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions