feat: setup lint-staged when making a commit
parent
70b220400c
commit
4d60c63f84
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
yarn lint-staged
|
@ -0,0 +1,23 @@
|
||||
const ignoredFiles = ['package.json', 'yarn.lock', 'tsconfig.json', '.lintstagedrc.js'];
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const buildFormatCommand = filenames => {
|
||||
const results = filenames
|
||||
.map(f => path.relative(process.cwd(), f))
|
||||
.filter(f => !ignoredFiles.includes(f));
|
||||
|
||||
return results.length ? `prettier --list-different --write ${results.join(' ')}` : '';
|
||||
};
|
||||
|
||||
const buildLintCommand = filenames => {
|
||||
const results = filenames
|
||||
.map(f => path.relative(process.cwd(), f))
|
||||
.filter(f => !ignoredFiles.includes(f));
|
||||
|
||||
return results.length ? `eslint ${results.join(' ')}`: '';
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
'*.{css,js,json,scss,ts,tsx}': [buildFormatCommand, buildLintCommand],
|
||||
};
|
Loading…
Reference in New Issue