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
Change Request: expose shouldUseFlatConfig
(or a wrapper API that selects between the two formats automatically)
#17129
Comments
I'm not clear on the ask here: are you asking for a way to determine if flat config should be used? Or are you asking for a way to find the flat config file? There is already an open issue for adding a method to |
@nzakas not exactly the same, we don't need to find the flat config file, we need to know which config format is being used so that we can call the correct APIs (and remove options that aren't supported by the I think the ideal ask is to expose an API that behaves exactly as the CLI does -- meaning it would determine which config format is being used and would call |
I don't think we can do this and have it make sense. The CLI operates on a couple of different signals. If With the new let eslint = new FlatESLint(options);
if (!(await eslint.findConfigFile())) {
eslint = new ESLint(options);
} |
It's an improvement, and it's probably good enough. But it's still not perfect, as ideally tooling like Would you be opposed to exposing this kind of a wrapper API in If that's not feasible I'm sure it's fine to use |
@nzakas tbh if the logic is likely to change in the future that's a strong argument for exposing this API - that way, userland doesn't have to care what it's doing, only that it gives them a boolean. Currently, changing the rules will break tools that are attempting to mimic the rules - but with this API, changing the rules would Just Work for those tools. |
I think the idea is to remove the current |
sure, but it would still be convenient to have the implementation be |
@cprussin ah okay, this was the bit I really didn't quite understand. I don't use Jest, so I wasn't aware that this was how @mdjermanovic what do you think? |
that sounds good @nzakas |
Just to clarify, would you all prefer a |
I support
|
@mdjermanovic makes sense, fair enough. Done in #17169. Thanks folks! |
ESLint version
v8.38.0
What problem do you want to solve?
Currently, neither
findFlatConfigFile
norshouldUseFlatConfig
are exported. This makes it impossible for tools that use the API directly such asjest-runner-eslint
to support both config formats without manually reproducing the behavior in those functions.What do you think is the correct solution?
Ideally, it would be great if there were an API exposed (probably in unsupported-apis.js) that would wrap the
FlatESLint
andESLint
apis and select the right one automatically, behaving the same as the CLI.Short of that, exposing
shouldUseFlatConfig
orfindFlatConfigFile
is enough to prevent tools having to manually roll their own logic here.Participation
Additional comments
I'm happy to submit the fix for this, I'll just need guidance by those who would approve it on which, if either, approach would be acceptable.
The text was updated successfully, but these errors were encountered: