-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
690850b
commit 71d9f0d
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {resolve, sep} from 'path'; | ||
|
||
export default { | ||
'*.{js,mjs,cjs,ts,mts,cts,vue}': 'eslint --cache --fix', | ||
|
||
/** | ||
* Run typechecking if any type-sensitive files or project dependencies was changed | ||
* @param {string[]} filenames | ||
* @return {string[]} | ||
*/ | ||
'{package-lock.json,packages/**/{*.ts,*.vue,tsconfig.json}}': ({filenames}) => { | ||
// if dependencies was changed run type checking for all packages | ||
if (filenames.some(f => f.endsWith('package-lock.json'))) { | ||
return ['pnpm run typecheck --if-present']; | ||
} | ||
|
||
// else run type checking for staged packages | ||
const fileNameToPackageName = filename => | ||
filename.replace(resolve(process.cwd(), 'packages') + sep, '').split(sep)[0]; | ||
return [...new Set(filenames.map(fileNameToPackageName))].map( | ||
p => `pnpm run typecheck:${p} --if-present`, | ||
); | ||
}, | ||
}; |