Closed ObliviousHarmony closed 3 years ago
At first glance this sounds relatively trivial thanks to our Configuration
abstraction and its associated cache. We can start in the file's directory and traverse upwards until we find the root. When this doesn't work we can just fall back to the configuration options the user has set.
I honestly think it could be even easier than that:
Add a new value to the StandardType
enum, like Default
. Then, in the worker, only add the --standard
arg if request.options.standard !== 'Default'
. No need to check for the config file's existence...let phpcs do that.
It might make sense to also make this the default value if phpCodeSniffer.standard
is falsey (https://github.com/ObliviousHarmony/vscode-php-codesniffer/blob/main/src/configuration.ts#L106)
Hey @dhrrgn,
That's a pretty good idea. My thinking was we could kill two birds with one stone here by also inferring the phpcs
location, but either way that is a good suggestion.
Users should be able to automatically select the standard and executable using a configuration option that scans for
composer.json
and standard PHPCS ruleset files.Edit: After Dan's suggestion below it makes more sense for now to just have an option that passes no
standard
at all and allowphpcs
to decide what the default. While it would also be nice to automatically discover thephpcs
executable this is less important at the moment.