Enable linting with phpcs-changed locally (#37465)

* Update phpcs-changed package to 2.10.2

* Add composer lint commands using phpcs-changed

* Add changlog file

* Update lint-staged script in package.json
This commit is contained in:
Corey McKrill 2023-04-14 12:01:16 -07:00 committed by GitHub
parent 3f23301f3f
commit f70d9452bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 11 deletions

View File

@ -1,7 +1,7 @@
{
"require-dev": {
"woocommerce/woocommerce-sniffs": "^0.1.3",
"sirbrillig/phpcs-changed": "^2.10"
"sirbrillig/phpcs-changed": "^2.10.2"
},
"config": {
"platform": {

View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4df582a159fa9e6987962ca1917bb00c",
"content-hash": "29a05e32698301ded5eeb893b4c22b90",
"packages": [],
"packages-dev": [
{
@ -258,16 +258,16 @@
},
{
"name": "sirbrillig/phpcs-changed",
"version": "v2.10.1",
"version": "v2.10.2",
"source": {
"type": "git",
"url": "https://github.com/sirbrillig/phpcs-changed.git",
"reference": "a5c3be6ec84395b168e7deadf8b167e50449e7a3"
"reference": "ba0432bc86ffdc31a6946117be6c2419b7e3e16d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sirbrillig/phpcs-changed/zipball/a5c3be6ec84395b168e7deadf8b167e50449e7a3",
"reference": "a5c3be6ec84395b168e7deadf8b167e50449e7a3",
"url": "https://api.github.com/repos/sirbrillig/phpcs-changed/zipball/ba0432bc86ffdc31a6946117be6c2419b7e3e16d",
"reference": "ba0432bc86ffdc31a6946117be6c2419b7e3e16d",
"shasum": ""
},
"require": {
@ -308,9 +308,9 @@
"description": "Run phpcs on files, but only report warnings/errors from lines which were changed.",
"support": {
"issues": "https://github.com/sirbrillig/phpcs-changed/issues",
"source": "https://github.com/sirbrillig/phpcs-changed/tree/v2.10.1"
"source": "https://github.com/sirbrillig/phpcs-changed/tree/v2.10.2"
},
"time": "2023-01-25T17:08:01+00:00"
"time": "2023-03-25T15:10:31+00:00"
},
{
"name": "squizlabs/php_codesniffer",

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Add composer scripts for linting with phpcs-changed

View File

@ -88,8 +88,11 @@
"phpcs": [
"phpcs -s -p"
],
"phpcs-pre-commit": [
"phpcs-changed --git -s"
"lint": [
"chg=$(git diff --relative --name-only -- '*.php'); [ -z $chg ] || phpcs-changed -s --git --git-unstaged $chg"
],
"lint-staged": [
"chg=$(git diff HEAD --relative --name-only -- '*.php'); [ -z $chg ] || phpcs-changed -s --git $chg"
],
"phpcbf": [
"phpcbf -p"

View File

@ -98,7 +98,7 @@
"lint-staged": {
"*.php": [
"php -d display_errors=1 -l",
"composer run-script phpcs-pre-commit"
"composer run-script lint-staged"
],
"!(*min).js": [
"eslint --fix"