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

renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this issue Aug 15, 2024
| datasource | package                           | from  | to    |
| ---------- | --------------------------------- | ----- | ----- |
| npm        | eslint-import-resolver-typescript | 3.5.1 | 3.6.1 |


##### [\`v3.6.1\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#361)

##### Patch Changes

-   [#241](import-js/eslint-import-resolver-typescript#241) [`cf5d67f`](import-js/eslint-import-resolver-typescript@cf5d67f) Thanks [@klippx](https://github.com/klippx)! - Fix CJS import to make it compatible with ESM projects
##### [\`v3.6.0\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#360)

##### Minor Changes

-   [#235](import-js/eslint-import-resolver-typescript#235) [`b5ea367`](import-js/eslint-import-resolver-typescript@b5ea367) Thanks [@SukkaW](https://github.com/SukkaW)! - refactor: drop `globby` and `synckit`
##### [\`v3.5.5\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#355)

##### Patch Changes

-   [`84b0649`](import-js/eslint-import-resolver-typescript@84b0649) Thanks [@JounQin](https://github.com/JounQin)! - fix: mark eslint-module-utils as dep
##### [\`v3.5.4\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#354)

##### Patch Changes

-   [`25f3920`](import-js/eslint-import-resolver-typescript@25f3920) Thanks [@JounQin](https://github.com/JounQin)! - fix: enhanced-resolve is commonjs only - close [#213](import-js/eslint-import-resolver-typescript#213)

-   [#219](import-js/eslint-import-resolver-typescript#219) [`0bf6ffb`](import-js/eslint-import-resolver-typescript@0bf6ffb) Thanks [@lsmurray](https://github.com/lsmurray)! - fix: check if cwd changed to bust mapper cache
##### [\`v3.5.3\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#353)

##### Patch Changes

-   [#206](import-js/eslint-import-resolver-typescript#206) [`6531bad`](import-js/eslint-import-resolver-typescript@6531bad) Thanks [@marvinhagemeister](https://github.com/marvinhagemeister)! - Only try to resolve a module directory when we know that the path is a directory. This can lead to a 15% speedup on projects with many files.
##### [\`v3.5.2\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#352)

##### Patch Changes

-   [#193](import-js/eslint-import-resolver-typescript#193) [`8756a26`](import-js/eslint-import-resolver-typescript@8756a26) Thanks [@Rialgar](https://github.com/Rialgar)! - chore(package): remove node 12 from engines field

-   [#187](import-js/eslint-import-resolver-typescript#187) [`7a91daf`](import-js/eslint-import-resolver-typescript@7a91daf) Thanks [@scott-ut](https://github.com/scott-ut)! - fix: resolve modules if folder contains a package.json file
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this issue Aug 15, 2024
| datasource | package                           | from  | to    |
| ---------- | --------------------------------- | ----- | ----- |
| npm        | eslint-import-resolver-typescript | 3.5.1 | 3.6.1 |


##### [\`v3.6.1\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#361)

##### Patch Changes

-   [#241](import-js/eslint-import-resolver-typescript#241) [`cf5d67f`](import-js/eslint-import-resolver-typescript@cf5d67f) Thanks [@klippx](https://github.com/klippx)! - Fix CJS import to make it compatible with ESM projects
##### [\`v3.6.0\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#360)

##### Minor Changes

-   [#235](import-js/eslint-import-resolver-typescript#235) [`b5ea367`](import-js/eslint-import-resolver-typescript@b5ea367) Thanks [@SukkaW](https://github.com/SukkaW)! - refactor: drop `globby` and `synckit`
##### [\`v3.5.5\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#355)

##### Patch Changes

-   [`84b0649`](import-js/eslint-import-resolver-typescript@84b0649) Thanks [@JounQin](https://github.com/JounQin)! - fix: mark eslint-module-utils as dep
##### [\`v3.5.4\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#354)

##### Patch Changes

-   [`25f3920`](import-js/eslint-import-resolver-typescript@25f3920) Thanks [@JounQin](https://github.com/JounQin)! - fix: enhanced-resolve is commonjs only - close [#213](import-js/eslint-import-resolver-typescript#213)

-   [#219](import-js/eslint-import-resolver-typescript#219) [`0bf6ffb`](import-js/eslint-import-resolver-typescript@0bf6ffb) Thanks [@lsmurray](https://github.com/lsmurray)! - fix: check if cwd changed to bust mapper cache
##### [\`v3.5.3\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#353)

##### Patch Changes

-   [#206](import-js/eslint-import-resolver-typescript#206) [`6531bad`](import-js/eslint-import-resolver-typescript@6531bad) Thanks [@marvinhagemeister](https://github.com/marvinhagemeister)! - Only try to resolve a module directory when we know that the path is a directory. This can lead to a 15% speedup on projects with many files.
##### [\`v3.5.2\`](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#352)

##### Patch Changes

-   [#193](import-js/eslint-import-resolver-typescript#193) [`8756a26`](import-js/eslint-import-resolver-typescript@8756a26) Thanks [@Rialgar](https://github.com/Rialgar)! - chore(package): remove node 12 from engines field

-   [#187](import-js/eslint-import-resolver-typescript#187) [`7a91daf`](import-js/eslint-import-resolver-typescript@7a91daf) Thanks [@scott-ut](https://github.com/scott-ut)! - fix: resolve modules if folder contains a package.json file
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this issue Aug 15, 2024
| datasource | package                           | from  | to    |
| ---------- | --------------------------------- | ----- | ----- |
| npm        | eslint-import-resolver-typescript | 3.5.1 | 3.6.1 |


## [v3.6.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#361)

##### Patch Changes

-   [#241](import-js/eslint-import-resolver-typescript#241) [`cf5d67f`](import-js/eslint-import-resolver-typescript@cf5d67f) Thanks [@klippx](https://github.com/klippx)! - Fix CJS import to make it compatible with ESM projects


## [v3.6.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#360)

##### Minor Changes

-   [#235](import-js/eslint-import-resolver-typescript#235) [`b5ea367`](import-js/eslint-import-resolver-typescript@b5ea367) Thanks [@SukkaW](https://github.com/SukkaW)! - refactor: drop `globby` and `synckit`


## [v3.5.5](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#355)

##### Patch Changes

-   [`84b0649`](import-js/eslint-import-resolver-typescript@84b0649) Thanks [@JounQin](https://github.com/JounQin)! - fix: mark eslint-module-utils as dep


## [v3.5.4](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#354)

##### Patch Changes

-   [`25f3920`](import-js/eslint-import-resolver-typescript@25f3920) Thanks [@JounQin](https://github.com/JounQin)! - fix: enhanced-resolve is commonjs only - close [#213](import-js/eslint-import-resolver-typescript#213)

-   [#219](import-js/eslint-import-resolver-typescript#219) [`0bf6ffb`](import-js/eslint-import-resolver-typescript@0bf6ffb) Thanks [@lsmurray](https://github.com/lsmurray)! - fix: check if cwd changed to bust mapper cache


## [v3.5.3](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#353)

##### Patch Changes

-   [#206](import-js/eslint-import-resolver-typescript#206) [`6531bad`](import-js/eslint-import-resolver-typescript@6531bad) Thanks [@marvinhagemeister](https://github.com/marvinhagemeister)! - Only try to resolve a module directory when we know that the path is a directory. This can lead to a 15% speedup on projects with many files.


## [v3.5.2](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#352)

##### Patch Changes

-   [#193](import-js/eslint-import-resolver-typescript#193) [`8756a26`](import-js/eslint-import-resolver-typescript@8756a26) Thanks [@Rialgar](https://github.com/Rialgar)! - chore(package): remove node 12 from engines field

-   [#187](import-js/eslint-import-resolver-typescript#187) [`7a91daf`](import-js/eslint-import-resolver-typescript@7a91daf) Thanks [@scott-ut](https://github.com/scott-ut)! - fix: resolve modules if folder contains a package.json file
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