Skip to content

Commit

Permalink
chore(lint-staged): use --relative
Browse files Browse the repository at this point in the history
  • Loading branch information
webdeveric committed Jul 27, 2024
1 parent dc75732 commit 447f9a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npx --no lint-staged -- --config "$(dirname "$0")/../lint-staged.config.mjs"
npx --no lint-staged -- --relative
16 changes: 1 addition & 15 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import { relative } from 'node:path';
import { cwd } from 'node:process';

/**
* @type {(filenames: string[]) => string[]>}
*/
const relativeFilenames = filenames => {
const root = cwd();

return filenames.map(file => relative(root, file));
};

/**
* @type {Record<string, string | (filenames: string[]) => string | string[] | Promise<string | string[]>}
*/
export default {
'*.{js,cjs,mjs,ts,cts,mts}': ['eslint --fix', 'prettier --write'],
'*.{json,md}': 'prettier --write',
'*': filenames => {
const files = relativeFilenames(filenames);

'*': (files) => {
return [
`cspell lint --no-progress --no-summary --no-must-find-files ${files.join(' ')}`,
`sh -c 'echo "${files.join('\n')}" | cspell --show-context stdin'`, // Spell check file names.
Expand Down

0 comments on commit 447f9a0

Please sign in to comment.