microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.7k stars 331 forks source link

Eslint server could not found config file. #1822

Open tzcodingjs opened 2 months ago

tzcodingjs commented 2 months ago

develop enviroment: vscode: 1.88.0 nodejs: 18.19.1 vscode-eslint: 2.4.4

When open project with vscode always show error:

issue

alfjesus commented 2 months ago

Upgrade your vscode-eslint to v3.0.5 (pre-release). This solved it for me 🙂. It seems that the current stable version can't handle eslint's new flat config file...

dbaeumer commented 2 months ago

That is correct. 2.4.4. has limited support for flat configs. @tzcodingjs do things work for you with 3.0.5 pre-release?

tzcodingjs commented 2 months ago

That is correct. 2.4.4. has limited support for flat configs. @tzcodingjs do things work for you with 3.0.5 pre-release?

3.0.5 it's not worked, but I rolling back to 2.2.6 everything is ok So odd.

tzcodingjs commented 2 months ago

Upgrade your vscode-eslint to v3.0.5 (pre-release). This solved it for me 🙂. It seems that the current stable version can't handle eslint's new flat config file...

Thanks! But it's not worked.

dbaeumer commented 2 months ago

That is strange. Can you provide me with a GitHub repository I can clone with a minimal setup that demos this.

tzcodingjs commented 2 months ago

That is strange. Can you provide me with a GitHub repository I can clone with a minimal setup that demos this.

This project https://github.com/Chanzhaoyu/chatgpt-web

dbaeumer commented 2 months ago

@tzcodingjs can you please provide me with a repository with a minimal setup. This looks like a normal development repository.

Hoody91 commented 2 months ago

Upgrade your vscode-eslint to v3.0.5 (pre-release). This solved it for me 🙂. It seems that the current stable version can't handle eslint's new flat config file...

This worked fine for me, although I did have to restart vscode multiple time before it started working.

ShravanSunder commented 2 months ago

I had this issue with eslint v9. rolling back to 8.5x fixed this for me. I'm not using flat config, but the old config. I had useFlatConfig in settings.json to false

dbaeumer commented 2 months ago

@ShravanSunder can you please provide me with a GitHub repository I can clone with a minimal setup that demos this.

I do have a test case for 9.0 with the old rc based config and the works for me: https://github.com/microsoft/vscode-eslint/blob/553e632fb4cf073fce1549fb6c3c1b5140a52ebb/playgrounds/9.0/rc/package.json#L1

So I would be interested to understand why this fails for you.

dotspencer commented 1 month ago

Downgrading to eslint version 8.57.0 resolved the issue for me

ShravanSunder commented 1 month ago

As of right now, eslint v9, old eslint config and vscode are incompatible.

dbaeumer commented 1 month ago

@ShravanSunder @dotspencer do you have a GitHub repository I can clone that demos thus.

And did you both use the pre-release version of ESLint (3.0.5)

sydneytan commented 1 month ago

Upgrade your vscode-eslint to v3.0.5 (pre-release). This solved it for me 🙂. It seems that the current stable version can't handle eslint's new flat config file...

it worked! thanks so much.

tayloraleach commented 2 weeks ago

I see the same error returning to a project that I have not opened in a while ...

image

I am not using the new flat config: "eslint": "^8.38.0"

What I have tried:

I do not have eslint installed globally and my project is not inside another project on my system

Absolutely maddening.

dbaeumer commented 2 weeks ago

@tayloraleach what happens when you run ESLint in the terminal from the node_modules folder. If that works, could you please provide me with a GitHub repository I can clone that demos what you are seeing.

spro commented 1 week ago

@dbaeumer here's a fresh repo created with npx create-next-app@13.3 which installs eslint@8.57.0 and has a minimal .eslintrc.json - https://github.com/spro/nextjs-13.5.6-eslint

I see the same issue as above. Downgrading to 2.4.4 does not work, but 2.2.6 is fine.

dbaeumer commented 1 week ago

@spro

Thanks for the repository. But it works for me:

Image

Any additional steps / setup?

spro commented 6 days ago

By comparing your output to mine I found the issue. I was seeing this:

[Info  - 1:24:33 PM] ESLint server is starting.
[Info  - 1:24:33 PM] ESLint server running in node v20.9.0
[Info  - 1:24:33 PM] ESLint server is running.
[Info  - 1:24:34 PM] ESLint library loaded from: /Users/sean/Projects/nextjs-13.5.6-eslint/node_modules/eslint/lib/unsupported-api.js
[Info  - 1:24:34 PM] ESLint version 8.57.0 supports flat config without experimental opt-in. The 'eslint.experimental.useFlatConfig' setting can be removed.
2024-06-28T20:24:34.008Z eslint:flat-eslint Searching for eslint.config.js
[Error - 1:24:34 PM] Calculating config file for file:///Users/sean/Projects/nextjs-13.5.6-eslint/pages/index.tsx) failed.
Error: Could not find config file.

I had been ignoring the warning "'eslint.experimental.useFlatConfig' setting can be removed" as I didn't think I had that set - it didn't show as checked in the preferences UI. But after looking again I found and removed it from my User-level settings.json.

dbaeumer commented 4 days ago

Good to hear you got it working.