notebook/lint-staged.config.js

28 lines
780 B
JavaScript
Raw Normal View History

2020-12-04 21:15:41 +08:00
const escape = require('shell-quote').quote;
const fs = require('fs');
const isWin = process.platform === 'win32';
const escapeFileNames = filenames =>
filenames
.filter(filename => fs.existsSync(filename))
.map(filename => `"${isWin ? filename : escape([filename])}"`)
.join(' ');
module.exports = {
'**/*{.css,.json,.md}': filenames => {
const escapedFileNames = escapeFileNames(filenames);
return [
`prettier --write ${escapedFileNames}`,
`git add -f ${escapedFileNames}`
];
},
'**/*{.ts,.tsx,.js,.jsx}': filenames => {
const escapedFileNames = escapeFileNames(filenames);
return [
`prettier --write ${escapedFileNames}`,
`eslint --fix ${escapedFileNames}`,
`git add -f ${escapedFileNames}`
];
}
};