-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlint-staged.js
More file actions
46 lines (39 loc) · 1.17 KB
/
Copy pathlint-staged.js
File metadata and controls
46 lines (39 loc) · 1.17 KB
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
/**
* Shared lint-staged configuration.
*
* Biome owns JS and JSON, stylelint owns SCSS, composer owns PHP.
*/
const micromatch = require('micromatch');
const DEFAULT_IGNORES = [
'!**/.*',
'!**/build/**/*',
'!**/core-plugin/**/*',
'!**/dist/**/*',
'!**/dist-zip/**/*',
'!**/templates/**/*',
'!**/vendor/**/*',
'!**/vendors/**/*',
];
/**
* Builds a lint-staged config.
*
* @param {Object} [options] Options.
* @param {string[]} [options.ignore] Extra glob patterns to skip, in
* micromatch negation form.
* @return {Object} A lint-staged configuration object.
*/
function createLintStagedConfig({ ignore = [] } = {}) {
const patterns = [...DEFAULT_IGNORES, ...ignore];
const run = (command) => (filenames) => {
const files = micromatch(filenames, patterns);
return files.length ? `${command} ${files.join(' ')}` : [];
};
return {
'**/*.php': run('composer run-script lint'),
'**/*.{css,scss}': run('stylelint --custom-syntax postcss-scss'),
'**/*.{js,jsx,json,jsonc}': run(
'biome check --write --no-errors-on-unmatched --files-ignore-unknown=true'
),
};
}
module.exports = { createLintStagedConfig };