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: Improved debugging tools for flat configs #18039
Comments
Oops! It looks like we lost track of this issue. What do we want to do here? This issue will auto-close in 7 days without an update. |
@kecrily are you still triaging this? |
You mean on this issue? no |
Okay, thanks for letting us know. |
If I'm understanding this correctly, the ask here is for a way to pass a file on the command line and have it indicate which objects in the config array it matches? The first step is to define what is meant by "matches," as the config array matches in a bunch of different ways:
@bradzacher are you looking to get all of this information or just a subset? |
At the most basic form of this request I would want to get an array of booleans which tell me whether or not a "match" occurred. By that I mean true if the object passed one of your defined conditions and was used in the final config merge, false otherwise. With such a debug feature one could do like A more advanced form would be if eslint explicitly told you which of the 3 conditions it matched, if any. Eg instead of a boolean it printed "explicit match of pattern X" or "excluded match" or "implicit match due to no ignores/files". This form would (probably) save you from manually logging out the config to correlate things. You may still need to print it out if you've got a whole bunch of spreads or shared configs but it would be less required. |
I think we may have a better solution in the works: https://github.com/eslint/config-inspector 😄 |
@bradzacher have you tried the config inspector? ( Does that solve your use case? |
I have and I have been recommending it to users whenever they ask questions about flat configs in our discord - and a lot of people have found it has helped them self-service - which as been really good! I'd love it if it could show the final calculated config for the file as well - I believe right now it just shows the calculated rules. For @typescript-eslint the final calculated language options are very important in helping users understand their setup. |
For all intents and purposes - we can probably consider this closed and instead hop over to the config inspector repo for any further enhancements. |
ESLint version
v8.x
What problem do you want to solve?
I've been working on migrating a reasonably complex legacy config to a flat config.
I found that the migration path is fraught with danger due to changes in the
files
changes.In our config we had the following two patterns in our matches:
*.js
- i.e. "match all JS files"some/path/**/*.*t*
- i.e. "match all cts, mts, ts, tsx` files(1) breaks in flat configs - it would only match files in the directory alongside the config file. The correct form is
**/*.js
.(2) breaks in flat configs - it can cause matching on files like
.DS_Store
. The fix I used for this was to instead explicitly use.{ts,tsx,cts,mts}
.These problems are, of course, user config problems - migration problems. However it was really hard to debug this. Currently there are only one tool to debug flat configs -
--print-config
. However from what I found - this isn't much good for debugging.For example - if I ran
eslint --print-config some/path/.DS_Store
- it'll just print out a config - which tells me nothing - I already know that file is matching the config because it's crashing my lint run!Similarly if I ran
eslint --print-config some/path/foo.js
- again it'll just print a config and it won't tell me anything useful for debugging.Fixing my config was a lot of manual effort in which I manually imported and logged my config from a node process to confirm its contents (lots of spreads of shared configs), followed by trial and error - deleting sections and seeing what happened. It was manual and painful!
What do you think is the correct solution?
With flat configs being so much about composing configs together in an array with lots of
files
- IMO the really important thing for me now is understanding exactly which elements in that array matched a given file.For example if there was a command like
eslint --debug-config <path>
:Such a tool would have made debugging the patterns dead simple and it would have helped me understand how ESLint was matching things to resolve the final config for the file.
Participation
Additional comments
No response
The text was updated successfully, but these errors were encountered: