forked from woocommerce/woocommerce-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint-staged.config.js
47 lines (40 loc) · 1.17 KB
/
lint-staged.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module.exports = {
'*.scss': [ 'pnpm run lint:css-fix' ],
'client/**/*.(t|j)s?(x)': [
'wp-scripts format-js',
'wp-scripts lint-js',
'pnpm run test-staged',
],
'packages/**/*.(t|j)s?(x)': ( packageFiles ) => {
const globalScripts = [
`wp-scripts format-js ${ packageFiles.join( ' ' ) }`,
`wp-scripts lint-js ${ packageFiles.join( ' ' ) }`,
];
const filesByPackage = packageFiles.reduce(
( packages, packageFile ) => {
const packageNameMatch = packageFile.match(
/\/packages\/([a-z0-9\-]+)\//
);
if ( ! packageNameMatch ) {
return packages;
}
const packageName = packageNameMatch[ 1 ];
if ( Array.isArray( packages[ packageName ] ) ) {
packages[ packageName ].push( packageFile );
} else {
packages[ packageName ] = [ packageFile ];
}
return packages;
},
{}
);
const workspaceScripts = Object.keys( filesByPackage ).map(
( packageName ) =>
`pnpm --filter @woocommerce/${ packageName } run test-staged -- ${ filesByPackage[
packageName
].join( ' ' ) }`
);
return globalScripts.concat( workspaceScripts );
},
'*.php': [ 'php -d display_errors=1 -l', 'composer run-script phpcs' ],
};