@@ -32,14 +32,24 @@ const eslintGlobalRulesForFix = [
3232 * Lint-staged command for running eslint in packages or apps.
3333 * @param {{cwd: string, files: string[], fix: boolean, fixType?: ('problem'|'suggestion'|'layout'|'directive')[], cache: boolean, rules?: string[], maxWarnings?: number} } params
3434 */
35- const getEslintFixCmd = ( { cwd, files, rules, fix, fixType, cache, maxWarnings } ) => {
35+ const getEslintFixCmd = ( {
36+ cwd,
37+ files,
38+ rules,
39+ fix,
40+ fixType,
41+ cache,
42+ maxWarnings,
43+ } ) => {
3644 const cliRules = [ ...( rules ?? [ ] ) , ...eslintGlobalRulesForFix ]
3745 . filter ( rule => rule . trim ( ) . length > 0 )
3846 . map ( r => `"${ r . trim ( ) } "` )
3947
4048 // For lint-staged it's safer to not apply the fix command if it changes the AST
4149 // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type
42- const cliFixType = [ ...( fixType ?? [ 'layout' ] ) ] . filter ( type => type . trim ( ) . length > 0 )
50+ const cliFixType = [ ...( fixType ?? [ 'layout' ] ) ] . filter (
51+ type => type . trim ( ) . length > 0
52+ )
4353
4454 const args = [
4555 cache ? '--cache' : '' ,
@@ -64,10 +74,17 @@ const getEslintFixCmd = ({ cwd, files, rules, fix, fixType, cache, maxWarnings }
6474 * @link https://github.com/okonet/lint-staged/issues/676
6575 *
6676 * @param {string[] } filenames
77+ * @param {string[] } [ignoreFilenames]
6778 * @returns {string } Return concatenated and escaped filenames
6879 */
69- const concatFilesForPrettier = filenames =>
70- filenames . map ( filename => `"${ isWin ? filename : escape ( [ filename ] ) } "` ) . join ( ' ' )
80+ const concatFilesForPrettier = ( filenames , ignoreFilenames = [ ] ) =>
81+ filenames
82+ . filter (
83+ filename =>
84+ ! ignoreFilenames . includes ( filename . split ( '/' ) . slice ( - 1 ) [ 0 ] || '' )
85+ )
86+ . map ( filename => `"${ isWin ? filename : escape ( [ filename ] ) } "` )
87+ . join ( ' ' )
7188
7289const concatFilesForStylelint = concatFilesForPrettier
7390
0 commit comments