eslint / rewrite

Monorepo for the new version of ESLint
Apache License 2.0
65 stars 4 forks source link

Bug: (Unable to resolve path to module '@eslint/compat.'.eslintimport/no-unresolved) #46

Closed zapzqc closed 3 weeks ago

zapzqc commented 3 weeks ago

Which packages are affected?

Environment

Node version: v18.20.3 pnpm version: 9.1.4 ESLint version: 9.4.0 Operating System: MacOS 11.5.2 VS Code

What did you do?

My project is written in JavaScript, and I would like to add ESLint to it.

What did you expect to happen?

import { fixupConfigRules } from '@eslint/compat'; This line should not be prompted with an error

What actually happened?

Unable to resolve path to module '@eslint/compat.'.eslintimport/no-unresolved

Link to Minimal Reproducible Example

https://stackblitz.com/edit/vitejs-vite-bm5pcp

Participation

Additional comments

image

When I added "main": "./dist/esm/index.js" to the package.json file under the node_modules/@eslint/compact directory, my editor stopped showing errors.

nzakas commented 3 weeks ago

The reproduction case you linked to does not show this error. Please provide a repro case where we can see the error in action and we can take a look.

Rec0iL99 commented 3 weeks ago

The reproduction case you linked to does not show this error. Please provide a repro case where we can see the error in action and we can take a look.

Hi @nzakas, I could reproduce this. This is related to the no-unresolved rule from eslint-plugin-import, but I'm not sure if it is because @eslint/compat does not have a main property in its package.json. The rule does not complain when there is a main property.

npx eslint .

/home/projects/vitejs-vite-bm5pcp/eslint.config.js
   3:34  error  Unable to resolve path to module '@eslint/compat'  import/no-unresolved
nzakas commented 3 weeks ago

Oh I see. There were no instructions on how to use the StackBlitz repro. I thought from the description that the error shows up immediately upon opening it. I didn't realize I had to manually run ESLint.

This seems more like a bug in eslint-plugin-import to me, but if adding main unblocks people, we can do that.

nzakas commented 3 weeks ago

Just a note that we should do this for all the packages, not just @eslint/compat.

nzakas commented 3 weeks ago

Working on this.