-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Move to flat config #702
Comments
This seems to tackle a lot of things I have recently run into. Looking forward to the integration. |
I wanted to start this effort. But I think first, we need to think about what it means for What does this mean for
|
Love the idea, some of that is also covered/discussed in: Such a change would also get the funding from: |
I've got a good start on this, I am going on vacation starting saturday for a couple of weeks, but I think I can get a draft PR for this before then, if not it should be in shortly when I get back. Some more thoughts we can discuss and how my initial implementation looks:
Some potential downsides/pitfalls:
New possibilities/features for xo:
|
The point of TypeScript is to have types. Same applies to linting. I'm not very interested in supporting use-cases for not using the type aware rules.
ESLint may support types built-in at some point: eslint/eslint#16557
I would be fine with using TypeScript for XO. That would be preferable over lots of JSDoc comments. |
I would love to see I've been using |
Just an update here... I have worked on this a bit and have a version which works ok. It doesn't quite cover all Unfortunately the initial results show that a large and complex ESLint flat config is quite a bit slower than what xo does now, even though we can cache the eslint instance, which is surprising. this implies that either:
It is likely a combination of both factors. Since I discovered that its a big downgrade in performance I haven't worked on it anymore, and I've lost my motivation for this effort... I think what I did was a good experiment, but now I think we maybe should take the path of least resistance with upgrade to flat config and use the current code base and just hook in the eslint compatibility libs and continue to use xo as it is. --- Not sure how the performance will look then. https://github.com/spence-s/flat-xo for anyone who would like to review or try out the code. |
This is put on a break until ESLint improves flat config performance: #707 (comment) |
Here are some other projects tackling this issue, for reference: |
This issue is now funded. |
Took a look at this repo again over the weekend. https://github.com/spence-s/flat-xo However, there are still some things to note. It seems these plugins do not yet support flat configs. (see eslint/eslint#18093)
Also, there is a ton of work to do for testing, many of xo's current tests are about parsing the old config type so those can't be ported over. Also the cli flags are changing so tests around those can't be ported either. Anyway - I am going to continue work in the flat-xo repo, I welcome anyone who wants to contribute there, and when I get some better tests and stability, we can figure out the best way to get the code in the new repo under xo namespace/cli and all that good stuff. If anyone wants to try to beat me to this I would encourage them to try, I think this thing is still a good while away from stability. |
|
Does this issue also cover the other config repositories? |
Ideally yes, but I assume that support will follow later. Other than IMO |
Making the first move |
I will start putting together a draft PR that ports https://github.com/spence-s/flat-xo to this repo, which will enable xo itself to use a flat config. Looks like it is mostly working as expected now with the exception There are a few other issues that need a discussion but those will be better had under the PR than this issue. |
Since I summarized my thoughts here: neostandard/neostandard#16 (comment) ( tldr is basically:
EDIT: Made a standalone issue about this: neostandard/neostandard#33 Will review @fisker's PR:s and come with suggestions from what we did |
Opened an issue in ESLint about officially supporting |
@sindresorhus @fisker How do you plan on integrating the TypeScript and React configs? I'm not sure that the direction taken in I'm currently a fan of https://github.com/antfu/eslint-config, which exposes a single global function which takes its own configuration. This is essentially the killer feature of If you take that approach, xo --prettier would be strictly equivalent to eslint . // eslint.config.mjs
import xo from 'eslint-config-xo'
export default xo({
prettier: true
}); so one can continue to choose to use |
@fregante This was my feedback here xojs/eslint-config-xo#86 (review), we're taking that approach in neostandard as well: export neostandard({
semi: true,
ts: true,
}); And currently having the CLI command generate such an output while discussing eslint/eslint#18800: neostandard --semi --ts > eslint.config.js Would love feedback to eslint/eslint#18800 from you as well 🙏 |
I haven't because it wouldn't be particularly positive. After the flat config is implemented, there's very little reason to ship a CLI tool and maintain its entire ecosystem (IDE tools, etc). Until now: "scripts": {
"test": "xo"
},
"devDependencies": {
"xo": "^0.59.0"
} After the flat config: "scripts": {
"test": "eslint . --config eslint-config-xo"
},
"devDependencies": {
"eslint": "^9.0.0",
"eslint-config-xo": "^0.59.0"
} The only piece missing is having the What are the pros of a |
I agree on this, its one of the things I brought up as a possible solution in eslint/eslint#18800:
The tricky part about only
Would be great if you could add your 👍 to that approach @fregante in that issue, as current feedback from ESLint is that its not something that should be solved in ESLint, leaving us all having to add |
Good point, then I think the best action would be: // eslint.config.mjs
export {default} from 'eslint-config-xo' And the usual: "scripts": {
"test": "eslint ."
},
"devDependencies": {
"eslint": "^9.0.0",
"eslint-config-xo": "^0.59.0"
} Which is arguably longer than what XO/standard allows today, but also worth the ability to use ESLint-native tools, like IDE plugins and other stuff like eslint-interactive. The amount of work this would save you personally is probably worth dropping the current CLI idea. A CLI tool would then just exist to set this up, as you suggested earlier:
If you need customizability, then a standard |
To answer myself: Pros
Cons
|
I personally agree with the eslint team and would like to continue maintaining the CLI and the extension. It's just work I enjoy and has lots of advantages. In addition, auto resolution of configs and plugins was basically the very worst part about eslint and even xo suffered from it, I don't think bringing that back in any form is good. XO cli basically originated from the limitations of the config and plugin auto-resolution being practically unshareable for multiple plugins. However, xo grew beyond that with a lot of different convenience things built in. Note the the flat-xo implementation I have been poking at is like 90% complete and standard linting works great with both vscode and the cli and it even is "self linting" at this point https://github.com/spence-s/flat-xo I will publish it as is under my scope (@spence-s/flat-xo) and write out some instructions for some beta testers who don't care about what's missing. So what's the hold up?
For config you can config for xo (using current xo cli and or vscode extension) xo.config.js export default [
// customizations
{
prettier: true,
semi: false.
rules: {...}
}
] Note that this config you can do things like turn prettier on and off for a subset of files, but I do see possible benefits of making the for using eslint directly, you'll miss out on any ability to automatically get type-aware linting and have it read your node engine (not sure the latter is even useful anymore anyway). But you can just eslint.config.js
and never use the CLI. Also another big benefit of CLI is that we don't want to force current cli user to start installing eslint as a separate dep. and finally, with the cli we can offer more config options such as allowing package.json to configure a subset of xo and not force users to create xo.config.js (not implemented in my package). @fregante and @voxpelli you both bring up some great discussions and it's true that the xo cli in my flat implementation is only a very thin wrapper around eslint, but I really like building the vscode extension so I will continue to maintain that even if I am the only user of it and the cli allows room for some more complex config gathering for prettier and typescript etc... that may be a little out of scope for a plain eslint config. |
@spence-s My hope was that we could find a solution for flat config based setups that could work for xo, (neo)standard and anyone else that wants to mimic that setup, without each of us having to build our own setup for CLI:s and editor extensions |
I hear you, and I agree to some extent, we've just already built those things, and I personally don't want to drop them 🤷🏻♂️ The xo vscode extension is pretty generic anyways. I've been debating pulling out the xo specific stuff and just making it a generic "eslint-lint-server" implementation that could use eslint or xo or any other tool that basically extends eslint lint results. It would also just be a standalone lint server that could work with any editor that supports LSP (most of them now). I just really haven't had a compelling reason to take the time to do that. If you'd be interested in something like that for neostandard, I'd be happy to work on it, work with you, and/or help where I can. And to the point being made by @nzakas on the eslint thread, the eslint vscode extension is actually maintained by microsoft, and not the eslint org, eslint has no control on that side of the things to implement the API you are asking for, you would need to approach that particular extension author for the implementation. |
The |
I'm not asking for any specific API, I'm asking for collaboration on solving a pattern / use case |
I just think we're at peak usability for users already and the pattern we are solving for is basically for the very few devs working on these tools right? I mean with flat config and a custom extension and a custom cli: The user gets :
Proposed solution I feel you are asking for would, at minimum, require users to install 2 deps (eslint + the config). Then install the eslint editor integration. Then they'd configure some new config (for shared configs, that hasn't been settled yet) to tell eslint to default to the shared config with some kind of options. That is the same amount of work they have to do if they want to use eslint toolchain anyway. I am just not sure how this makes things better for users. I see the benefit to us as devs, just using the eslint built in stuff and avoid writing clis/integrations. However, since we have all that stuff in place already, I just don't feel that motivated to solve the problem. Am I missing something? |
I'm apparently not making myself understood, not sure if its a language barrier or something, maybe a native speaker like @wesleytodd describes it better here? eslint/eslint#18800 (comment) |
@sindresorhus what's left here? It looks like the config is now flat:
I think this is the last step: |
That and also doing the XO changes. |
Closed eslint/eslint#18800 as I couldn’t get the point across and it just started to wear me down. If anyone in xo is still interested in collaborating with (neo)standard on the next gen solution for this, then reach out in eg neostandard/neostandard#205 or somewhere. Until then I’ll unsubscribe from this thread 🙏 |
+
https://eslint.org/blog/2022/08/new-config-system-part-2/
The change has been out for a while and it might be a good time to start exporting it. I believe this will solve a lot of config-related issues:
eslint-plugin-node
andeslint-plugin-n
rules #613Some notes around this in #428 (comment)
Upvote & Fund
The text was updated successfully, but these errors were encountered: