const quote = (file) => JSON.stringify(file); // 生成的声明文件(如 openapi.d.ts)被 ESLint 忽略,跳过 lint 只做格式化, // 避免 lint-staged 因 "File ignored" 警告而阻断提交。 const lintScripts = (filenames) => { const lintable = filenames.filter((file) => !file.endsWith('.d.ts')); const commands = []; if (lintable.length > 0) { commands.push(`eslint --fix --max-warnings=0 ${lintable.map(quote).join(' ')}`); } commands.push(`prettier --write ${filenames.map(quote).join(' ')}`); return commands; }; export default { '*.{ts,tsx,js,mjs,cjs}': lintScripts, '*.{json,md,css,scss,yml,yaml}': ['prettier --write'], };