feat: improve lint staged performance

This commit is contained in:
nafees nazik
2024-03-08 16:26:47 +05:30
parent fd4ea3aca5
commit 8afe669978

View File

@ -1,7 +1,15 @@
const path = require('path');
const buildEslintCommand = (filenames) =>
`eslint --fix ${filenames.map((f) => path.relative(process.cwd(), f)).join(' ')} `;
const buildPrettierCommand = (filenames) =>
`prettier --write ${filenames.map((f) => path.relative(process.cwd(), f)).join(' ')} `;
/** @type {import('lint-staged').Config} */
module.exports = {
'**/*.{ts,tsx,cts,mts}': (files) => files.map((file) => `eslint --fix ${file}`),
'**/*.{js,jsx,cjs,mjs}': (files) => files.map((file) => `prettier --write ${file}`),
'**/*.{yml,mdx}': (files) => files.map((file) => `prettier --write ${file}`),
'**/*.{ts,tsx,cts,mts}': [buildEslintCommand],
'**/*.{js,jsx,cjs,mjs}': [buildPrettierCommand],
'**/*.{yml,mdx}': [buildPrettierCommand],
'**/*/package.json': 'npm run precommit',
};