Skip to content

Commit 2dd9d74

Browse files
committed
improve(COURIER-1006): Husky updates
1 parent 0c28bd7 commit 2dd9d74

File tree

7 files changed

+91
-49
lines changed

7 files changed

+91
-49
lines changed

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx commitlint --edit $1

.husky/pre-commit

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
# Get staged PHP files
5+
STAGED_PHP_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.php$')
6+
7+
if [ -z "$STAGED_PHP_FILES" ]; then
8+
exit 0
9+
fi
10+
11+
# Run phpcbf on staged files
12+
./vendor/bin/phpcbf --standard=phpcs.xml.dist $STAGED_PHP_FILES
13+
14+
# Add the fixed files to the commit
15+
echo "$STAGED_PHP_FILES" | xargs git add

.php-cs-fixer.dist.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
'native_function_casing' => true,
2727
'native_function_invocation' => true,
2828
'native_type_declaration_casing' => true,
29-
'array_syntax' => ['syntax' => 'short'],
30-
'list_syntax' => ['syntax' => 'short'],
29+
'array_syntax' => [ 'syntax' => 'short' ],
30+
'list_syntax' => [ 'syntax' => 'short' ],
3131
]
3232
);
3333
$config->setFinder( $finder );

commitlint.config.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,38 @@
66
*
77
* Format Example
88
*
9-
* issue(MY-123): Add new feature
9+
* issue(COURIER-123): Add new feature
1010
*
11-
* or if you have no issue number you can utilize NO-JIRA or NO-TASK
11+
* or if you have no issue number you can utilize NO-TASK
1212
*/
1313
module.exports = {
14-
extends: ['@commitlint/config-conventional'],
14+
extends: ["@commitlint/config-conventional"],
1515
rules: {
16-
'type-enum': [2, 'always', ['improve', 'build','chore','ci','docs','feat','fix','perf','refactor','revert','style','test']],
17-
'subject-case': [1, 'always', ['sentence-case']],
16+
"type-enum": [
17+
2,
18+
"always",
19+
[
20+
"improve",
21+
"build",
22+
"chore",
23+
"ci",
24+
"docs",
25+
"feat",
26+
"fix",
27+
"perf",
28+
"refactor",
29+
"revert",
30+
"style",
31+
"test",
32+
],
33+
],
34+
"subject-case": [1, "always", ["sentence-case"]],
35+
},
36+
parserPreset: {
37+
parserOpts: {
38+
headerPattern:
39+
/^(improve|build|ci|feat|fix|docs|style|revert|perf|refactor|test|chore)\(((?:COURIER-\d+)|(?:NO-JIRA|NO-TASK)|(?:\#\d+))\):\s?([\w\d\s,\-]*)/,
40+
headerCorrespondence: ["type", "scope", "subject"],
41+
},
1842
},
19-
"parserPreset": {
20-
"parserOpts": {
21-
"headerPattern": /^(improve|build|ci|feat|fix|docs|style|revert|perf|refactor|test|chore)\(((?:[A-Z]+-\d+)|(?:NO-JIRA|NO-TASK)|(?:\#\d+))\):\s?([\w\d\s,\-]*)/,
22-
"headerCorrespondence": ["type", "scope", "subject"]
23-
}
24-
}
2543
};

courier-notices.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
require_once COURIER_NOTICES_PATH . 'vendor/autoload.php';
7070
}
7171

72-
// Load Strauss prefixed dependencies
72+
// Load Strauss prefixed dependencies.
7373
if ( file_exists( COURIER_NOTICES_PATH . 'vendor-prefixed/autoload.php' ) ) {
7474
require_once COURIER_NOTICES_PATH . 'vendor-prefixed/autoload.php';
7575
}
@@ -90,8 +90,10 @@
9090
function courier_notices_init() {
9191

9292
// Deprecated hook.
93-
_doing_it_wrong( 'before_courier_notices_init', 'Use courier_notices_before_init instead.', '1.7.0' );
94-
do_action( 'before_courier_notices_init' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
93+
if ( has_action( 'before_courier_notices_init' ) ) {
94+
_doing_it_wrong( 'before_courier_notices_init', 'Use courier_notices_before_init instead.', '1.7.0' );
95+
do_action( 'before_courier_notices_init' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
96+
}
9597

9698
do_action( 'courier_notices_before_init' );
9799

@@ -118,8 +120,10 @@ function () {
118120
}
119121

120122
// Deprecated hook.
121-
_doing_it_wrong( 'after_courier_notices_init', 'Use courier_notices_after_init instead.', '1.7.0' );
122-
do_action( 'after_courier_notices_init' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
123+
if ( has_action( 'after_courier_notices_init' ) ) {
124+
_doing_it_wrong( 'after_courier_notices_init', 'Use courier_notices_after_init instead.', '1.7.0' );
125+
do_action( 'after_courier_notices_init' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
126+
}
123127

124128
do_action( 'courier_notices_after_init' );
125129
}

package-lock.json

Lines changed: 30 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@
4545
"browserslist": [
4646
"defaults"
4747
],
48-
"private": true
48+
"private": true,
49+
"prepare": "husky || true"
4950
}

0 commit comments

Comments
 (0)