@@ -32,14 +32,24 @@ const eslintGlobalRulesForFix = [
32
32
* Lint-staged command for running eslint in packages or apps.
33
33
* @param {{cwd: string, files: string[], fix: boolean, fixType?: ('problem'|'suggestion'|'layout'|'directive')[], cache: boolean, rules?: string[], maxWarnings?: number} } params
34
34
*/
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
+ } ) => {
36
44
const cliRules = [ ...( rules ?? [ ] ) , ...eslintGlobalRulesForFix ]
37
45
. filter ( rule => rule . trim ( ) . length > 0 )
38
46
. map ( r => `"${ r . trim ( ) } "` )
39
47
40
48
// For lint-staged it's safer to not apply the fix command if it changes the AST
41
49
// @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
+ )
43
53
44
54
const args = [
45
55
cache ? '--cache' : '' ,
@@ -64,10 +74,17 @@ const getEslintFixCmd = ({ cwd, files, rules, fix, fixType, cache, maxWarnings }
64
74
* @link https://github.com/okonet/lint-staged/issues/676
65
75
*
66
76
* @param {string[] } filenames
77
+ * @param {string[] } [ignoreFilenames]
67
78
* @returns {string } Return concatenated and escaped filenames
68
79
*/
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 ( ' ' )
71
88
72
89
const concatFilesForStylelint = concatFilesForPrettier
73
90
0 commit comments