Skip to content

Commit e59daf7

Browse files
committed
chore(lint-staged): use --relative
1 parent a4c8e02 commit e59daf7

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npx --no lint-staged -- --config "$(dirname "$0")/../lint-staged.config.mjs"
1+
npx --no lint-staged -- --relative

lint-staged.config.mjs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
1-
import { relative } from 'node:path';
2-
import { cwd } from 'node:process';
3-
4-
/**
5-
* @type {(filenames: string[]) => string[]>}
6-
*/
7-
const relativeFilenames = filenames => {
8-
const root = cwd();
9-
10-
return filenames.map(file => relative(root, file));
11-
};
12-
131
/**
142
* @type {Record<string, string | (filenames: string[]) => string | string[] | Promise<string | string[]>}
153
*/
164
export default {
175
'*.{js,cjs,mjs,ts,cts,mts}': ['eslint --fix', 'prettier --write'],
186
'*.{json,md}': 'prettier --write',
19-
'*': filenames => {
20-
const files = relativeFilenames(filenames);
21-
22-
return [
23-
`cspell lint --no-progress --no-summary --no-must-find-files ${files.join(' ')}`,
24-
`sh -c 'echo "${files.join('\n')}" | cspell --show-context stdin'`, // Spell check file names.
25-
];
26-
},
7+
'*': (files) => [
8+
`cspell lint --no-progress --no-summary --no-must-find-files ${files.join(' ')}`,
9+
`sh -c 'echo "${files.join('\n')}" | cspell --show-context stdin'`, // Spell check file names.
10+
],
2711
};

0 commit comments

Comments
 (0)