Open axtgr opened 4 years ago
Thanks for investigating this.
And these are IMHO the problems of the current approach:
Ideally, we should throw if the singular form is used in the config or plural is used in the CLI instead of just silently accepting it.
Today I was trying to use XO to lint Svelte files. It wasn't working, so I dug a little. Turns out, the
extension(s)
option doesn't work as I expected, and I think there is more than one issue with it.This is basically what the docs say about declaring file extensions: you can either pass one or more
extension
(singular) options via CLI, or specify an array asextensions
(plural) in a config file. That's it.This is what happens in reality:
{...configOptions, ...cliOptions}
. It means that both singular and plural aliases are allowed everywhere. https://github.com/xojs/xo/blob/2e39794d5ad4017ed2545d9a43691d4c4b0f7ade/lib/options-manager.js#L240-L244extensions
option passed from CLI, which makes it the only working option. https://github.com/xojs/xo/blob/2e39794d5ad4017ed2545d9a43691d4c4b0f7ade/lib/options-manager.js#L246And these are IMHO the problems of the current approach:
Plural CLI option
>Plural config option
>Singular CLI option
>Singular config option
I think CLI options should always override config options, which can be achieved by normalizing them separately before merging.