You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 as extensions (plural) in a config file. That's it.
This is what happens in reality:
All options are merged into a single object, basically {...configOptions, ...cliOptions}. It means that both singular and plural aliases are allowed everywhere.
The result is overridden by concatenating some default extensions with the original extensions option passed from CLI, which makes it the only working option.
And these are IMHO the problems of the current approach:
The priority of options is weird. It's basically this: 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.
Step 3 is probably a bug. I think it's meant to use the result of the first two steps instead of the original option. Can be easily fixed by changing the variable used.
It's not very well documented, so it's not entirely clear what the intended algorithm was and if it even needs fixing.
The text was updated successfully, but these errors were encountered:
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.xo/lib/options-manager.js
Lines 240 to 244 in 2e39794
xo/lib/options-manager.js
Line 216 in 2e39794
extensions
option passed from CLI, which makes it the only working option.xo/lib/options-manager.js
Line 246 in 2e39794
And 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.
The text was updated successfully, but these errors were encountered: