-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow standard to be selected in composer.json #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/vendor/ | ||
/.idea/ | ||
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,9 +38,17 @@ It should just work when you `git commit`. | |||||
|
||||||
## Internals | ||||||
|
||||||
By default, of the 5 different WordPress coding standards (`WordPress-VIP`, `WordPress`, `WordPress-Extra`, `WordPress-Docs` and `WordPress-Core`), this one uses the `WordPress-Extra` one. | ||||||
|
||||||
If you need to change it, currently you need to edit the Sniff file. Contributions on how to make this dynamic are welcome (`.env` file, different sniffs for each and choosing the appropriate hooks). | ||||||
WPCS provides 5 different coding standards (`WordPress-VIP`, `WordPress`, | ||||||
`WordPress-Extra`, `WordPress-Docs` and `WordPress-Core`). By default this uses | ||||||
`WordPress-Extra`. If you want to use another one of the standards, you can | ||||||
specify it in your project's composer.json's `extra` key: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reorder for readability
Suggested change
|
||||||
```json | ||||||
"extra": { | ||||||
"php-composter-phpcs-wpcs": { | ||||||
"standard": "WordPress-VIP" | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
## Contributing | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -39,9 +39,15 @@ public function preCommit() | |||||
|
||||||
echo 'Running PHP CodeSniffer in ' . $this->root . PHP_EOL; | ||||||
$sniffer = new PHP_CodeSniffer_CLI(); | ||||||
@$config = $this->getExtraKey('php-composter-phpcs-wpcs', [ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please avoid the "shut-up" operator (
Suggested change
|
||||||
'standard' => 'WordPress-Extra' | ||||||
]); | ||||||
|
||||||
ob_start(); | ||||||
$numErrors = $sniffer->process(array('standard' => 'WordPress-Extra', 'files' => $files)); | ||||||
$numErrors = $sniffer->process([ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you think about merging the |
||||||
'standard' => $config['standard'], | ||||||
'files' => $files | ||||||
]); | ||||||
$output = ob_get_clean(); | ||||||
|
||||||
echo $output . PHP_EOL; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ignore should go into your global gitignore list, as it is not a direct artifact of the project, but rather a detail of your personal environment.