-
Notifications
You must be signed in to change notification settings - Fork 322
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
Enable Flat Config by default #1644
Comments
This might not be easy to enable by default since the ESLint server doesn't start on the workspace folder root. |
Flat config is enabled by default from ESLint v9.0.0 and the ".eslintrc.*" format seems to be removed in v10.0.0 |
Any ETA on that? It's pretty weird that it's considered as experimental feature. It should be default for sure since flat config is becoming standard. Extension should keep up with library :) |
const {shouldUseFlatConfig} = require("eslint/use-at-your-own-risk");
shouldUseFlatConfig(); |
@dbaeumer I think |
@nzakas the reason why I haven't switch yet is that I am under the impression that to get to the new Has this changed? What I would like to do is to import |
@dbaeumer the For the latest v8 and all of v9, Full details here: |
Reading the link from above brought me to the following conclusion:
From my experiences designing API, it would have been easier for API users, if the API would have added new names and removed old names instead if reusing names and changing the meaning. The first would have avoided checking the version since the pure existence of a name would introduce a behavior. In VS Code we usually use a function to load the API to which you can pass a parameter to determine if you want proposed API. If you opt into this they are put into the same namespace. @nzakas any change to revisit the rollout plan especially around the meaning change of ESLint -> FlatESLint. |
I appreciate the feedback, but at this point we are weeks away from a beta (three alpha releases have already been published), so revisiting the rollout plan really isn't in the cards. To clarify: the change to the behavior of
Can you give an example of this? I'm not opposed to adding something along these lines, but need to see it in action in order to evaluate. |
Actually I don't want to change the timing. I understand that this is not possible. I was more hoping for some sort of additional API to make this easier for API users that need to support 8.x, 9.x and 10.x Let me first explain what we do in VS Code and LSP to mitigate those changes. In general we do two things:
VS Code
ESLintFor ESLint it would be cool to have the following:
If proposed is false then the Something like this would allow to use the API without checking version to interpret names differently. Let me know if something like this would be possible? |
Because we are getting into API design, let's continue this conversation in the ESLint repo here: |
No need to load the
I'm afraid it won't be easy to add an additional API to already published versions of ESLint 8.x. But it could be added in v9 if it simplifies the upgrade to v10. |
The new API has been released in both the v8.x and v9.x branches: |
@dbaeumer with the new API provided by ESLint does that mean that a single VSCode workspace will be able to use both flat and eslintrc configs depending on what ESLint files exist in the current working directory when using ESLint 8? It appears that the current
|
@lubaker I haven't tried the new API so I can't tell yet :-) |
Based on the new API from @nzakas I created a new alpha version of the extension. It can be found here: https://github.com/microsoft/vscode-eslint/releases/tag/3.0.1-alpha.1 If you use 8.57.0 or above it should auto detect flat config. I also has a big change to move to pull diagnostics which gives us better validation scheduling and validating on focus change. To install it download the VSIX and execute the command Would be great to get some early feedback since most of my repositories are still using the old config style :-) |
This appears to work for me. I'm using ESLint 8.57.0 with your alpha and the "Use Flat Config" setting unchecked. In a directory with a flat config, it is linting using the flat configuration and in directories with the old config style, it lints using that config. 💯 |
Works OOTB in a "simple" repo. It doesn't in a monorepo (pnpm, eslint config per workspace).
|
@moeriki are you running into this design feature of the ESLint Flat Config, where it is recommended to use a single flat config in the root also in monorepos? Maybe also comment on the ESLint discussion over here? |
I see. It's an interesting discussion worth following, and I might try it out. But I don't feel like they mention a technical limitation. It looks more like a general new recommendation, that wasn't possible before with the RC config architecture. But it think it should still be up to the developer to decide what's best for them. |
@moeriki do you let eslint know about the working directories of your mono repository using the |
Flat Config loader seems to not work in Yarn+PnP environments. It will fail to import any requirement. Using version 3.0.1, but I've also tested it on latest version. Nodepath is set to
from eslint.config.js:
Edit: Found the mitigation. Rewriting the config into CommonJS seems to remedy the issue, there is something cursed happening with ESM Module Imports in the VSCode-land. |
I just created a npm which works in the extension (please ensure to use the alpha I posted here: #1644 (comment))
Does validation happen correctly for you in the terminal using |
Created a new alpha release here: https://github.com/microsoft/vscode-eslint/releases/tag/3.0.3-alpha.1 Has support for auto detecting flat config roots if no working directories are specified. This should make the conversion from rc -> flat easier. |
Trying out 3.0.3-alpha.1 in a rush monorepo. All projects have an eslint.config.js (I also tried esling.config.mjs) and have eslint v8.57 installed in their package.json. Forgive the lack of a full repro right now - I have some speculation that, if correct, probably doesn't require one. But if it doesn't pan out I'll try to whip one up. I'm getting the following error (abridged log becuase I'm manually scrubbing company and project names):
I noticed there's a Is it possible that this version of vscode-eslint is URL-encoding the path and attempting to resolve that in the file system, which causes the resolution to fail if it includes non-ascii characters? |
Disregard the last comment. I don't think it has anything to with encoded path resolution, and that's what I get for taking guesses at things I don't know anything about. I found some time today to create a reproduction repo that replicates the Rush monorepo setup I'm currently using in my project. You can find it at https://github.com/rdecoito/eslint-monorepo-repro, along with a README that explains reproduction steps. Let me know if you run into any problems but it should all be kosher. Here's the first handful of lines I see in the VSCode Output tab for ESLint (using 3.0.0-alpha.1):
The setup here is having the monorepo open as a single folder in VSCode and having each project in that repo declare its own eslint.config.js configuration. I know there's been some discussion in other issues about whether you should have a single config at the root of a monorepo or individual configs in each project, but I think the only correct answer is "either way should work." The paradigm my reproduction repo is following is that of independent projects, where you could pluck one of your monorepo projects out into its own repo with no file copy-pasting and very little editing. Thus, I think it's necessary to support this use case for flat configs. Thanks for all your hard work, Dirk! I really do love this extension and you're a real champion for everything you've done. |
New release here: https://github.com/microsoft/vscode-eslint/releases/tag/3.0.5-alpha.1 |
3.0.5 got released a a pre-release version in the marketplace. |
@dbaeumer Just installed the Thanks for the hard work on this. 👍 |
eslint v9 has been released: https://eslint.org/blog/2024/04/eslint-v9.0.0-released/ |
@dbaeumer is there a timeline for a beta or final release? |
I want to release a new version (not pre-release) beginning of next week. However there will still be a loose end with yarn pnp and mjs files. The details are here: yarnpkg/berry#6219 To make that work we need a new yarn version and VS Code being move to Electron 29 which will be the case with the next stable release. |
Flat Config is now considered complete:
eslint/eslint@7162d34
Seems it should no longer be masked behind
eslint.experimental.useFlatConfig
.The text was updated successfully, but these errors were encountered: