forked from EarnQuestOne/stellar_Earn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint-staged.config.js
More file actions
30 lines (26 loc) · 1013 Bytes
/
Copy pathlint-staged.config.js
File metadata and controls
30 lines (26 loc) · 1013 Bytes
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
const path = require('path');
const FRONTEND_DIR = 'FrontEnd/my-app';
const BACKEND_DIR = 'BackEnd';
function buildCommands(cwd, command, files) {
const relativeFiles = files.map((file) => path.relative(cwd, file));
if (relativeFiles.length === 0) {
return [];
}
return [`cd ${cwd} && npx ${command} ${relativeFiles.join(' ')}`];
}
/** @type {import('lint-staged').Configuration} */
module.exports = {
'FrontEnd/my-app/**/*.{js,jsx,ts,tsx,css,scss,md,json,yml,yaml}': (files) => [
...buildCommands(FRONTEND_DIR, 'prettier --write', files),
...buildCommands(FRONTEND_DIR, 'eslint --fix', files),
],
'BackEnd/{src,test}/**/*.ts': (files) => [
...buildCommands(BACKEND_DIR, 'prettier --write', files),
...buildCommands(BACKEND_DIR, 'eslint --fix', files),
],
'BackEnd/**/*.json': (files) =>
buildCommands(BACKEND_DIR, 'prettier --write', files),
'{scripts,tests}/**/*.{js,mjs,cjs,json,md,yml,yaml}': (files) => [
`npx prettier --write ${files.join(' ')}`,
],
};