Skip to content
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

Specifying version of phpcs, etc in hmlinter.yml can silently disable sniffing #146

Open
kadamwhite opened this issue Dec 10, 2020 · 2 comments
Labels

Comments

@kadamwhite
Copy link
Contributor

When you create a yaml file like this:

version: "latest"

phpcs:
  version: "1.1.1"

it's reasonable to expect that HM Linter will run as normal, and use 1.1.1 for PHPCS. What actually happens is that PHPCS uses 1.1.1, but is also marked as disabled so no sniffs are run.

The default configuration includes a nested property enabled: true (config.js):

const DEFAULT_CONFIG = {
	version: 'latest',
	phpcs: {
		enabled: true,
		version: 'inherit',
	},
	//...
};

The defaults are then merged in here:

		return {
			...DEFAULT_CONFIG,
			...config
		};

Because this merge clobbers any keys from the defaults in a non-recursive fashion, enabled is not set on the resulting configuration option and PHPCS does not run.

@kadamwhite kadamwhite added the bug label Dec 10, 2020
@kadamwhite
Copy link
Contributor Author

(This could be fixed either by recursively merging config, or else making enabled default to true if the property is missing)

@rmccue
Copy link
Member

rmccue commented Dec 10, 2020

(This could be fixed either by recursively merging config, or else making enabled default to true if the property is missing)

We'll need to recursively merge, as linters can be set as disabled by default (i.e. stylelint when introduced was disabled by default); you could argue that setting the version implicitly enables it though I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants