prettier / eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with Prettier.
MIT License
5.43k stars 255 forks source link

[CLI] Handle undefined computed config #288

Open silvenon opened 4 months ago

silvenon commented 4 months ago

This will mostly be a result of an unexpected ESLint config, but will represent an additional hurdle for anyone using your great CLI utility who's migrating to the flat config and learning the ropes.

For .js/.cjs/.mjs files eslint --print-config seems to always have a default configuration where rules exists, even when ESLint config is empty, but in case ESLint has not been successfully configured for TypeScript eslint --print-config index.ts will return undefined, so not even an empty object, which causes the CLI utility to fail.

This is not related to the flat config, it was also a thing that could happen before as well, but I only ran into it while migrating to the flat config because of a breaking change in glob matching.

Proposed solution

Initially I thought that the right thing to do is to tell the user that the config is a-ok and that it doesn't conflict with Prettier, but on second thought people shouldn't be checking files that have no ESLint configuration, so I still think that the error message is a good idea, but the one that describes what's actually wrong. This file has no ESLint configuration, or something like that.

What do you think?