10up / phpcs-composer

Official 10up PHPCS rules.
MIT License
48 stars 8 forks source link

Suggestion: use the DealerDirect Composer PHPCS plugin #15

Closed jrfnl closed 5 years ago

jrfnl commented 6 years ago

The dealerdirect/phpcodesniffer-composer-installer package - https://github.com/DealerDirect/phpcodesniffer-composer-installer - can take care of setting the PHPCS installed_paths config for you, rather than doing so using your own PHPCSConfig.php.

Generally speaking, a ruleset package like this would suggest the package and dependents should require --dev it. However, I imagine it will work just as well if this package would require it.

ChaosExAnima commented 5 years ago

Hey @jrfnl, thanks for the suggestion! The reason we're not using that is because we'd also like to set up the default ruleset, and the logic behind either one is pretty much identical.

jrfnl commented 5 years ago

The reason we're not using that is because we'd also like to set up the default ruleset...

@ChaosExAnima I'm not sure I understand your argument against this as that would still be quite simple to do using something like the below in the dependents.

  "scripts": {
    "config-cs": [
      "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
      "\"vendor/bin/phpcs\" --config-set default_standard 10up-Default"
    ],
    "post-install-cmd": @config-cs,
    "post-update-cmd": @config-cs
  }

... and the logic behind either one is pretty much identical.

Again, I'm not sure I understand. The logic behind setting the installed_paths correctly should be so much more complex as it has to look at an array and make sure all the right values are in it (quite apart from finding all the rulesets to add).

For the default_standard, the logic is simple: add the value if it doesn't exist or overwrite it if it does.

nicholasio commented 5 years ago

This might solve the issues in #9 and #10

sudar commented 5 years ago

@ChaosExAnima

If we change this package to use dealerdirect/phpcodesniffer-composer-installer like how @jrfnl is suggesting, then it will automatically fix both #9 and #10

I can also submit a PR if needed.

sudar commented 5 years ago

I have created a PR to use the DealerDirect Composer PHPCS plugin. See #16