@@ -70,7 +70,7 @@ describe('lint-staged', () => {
70
70
)
71
71
72
72
test (
73
- 'supports staged deleted files' ,
73
+ 'supports staged deleted files processed by linter ' ,
74
74
withGitIntegration ( async ( { appendFile, cwd, execGit } ) => {
75
75
const globalConsoleTemp = console
76
76
console = makeConsoleMock ( )
@@ -91,6 +91,42 @@ describe('lint-staged', () => {
91
91
} )
92
92
93
93
expect ( passed ) . toEqual ( true )
94
+ expect ( console . printHistory ( ) ) . not . toMatch ( 'No files matching the pattern were found:' )
95
+
96
+ console = globalConsoleTemp
97
+ } )
98
+ )
99
+
100
+ test (
101
+ 'supports staged deleted files not processed by linter' ,
102
+ withGitIntegration ( async ( { appendFile, cwd, execGit } ) => {
103
+ const globalConsoleTemp = console
104
+ console = makeConsoleMock ( )
105
+
106
+ // Stage and commit file
107
+ await appendFile ( 'test.txt' , 'text contents' )
108
+ await execGit ( [ 'add' , 'test.txt' ] )
109
+ await execGit ( [ 'commit' , '-m' , 'test' ] )
110
+
111
+ // Staged deleted file not subject to linter processing
112
+ await execGit ( [ 'rm' , 'test.txt' ] )
113
+
114
+ // Run lint-staged with `--diff-filter=D` to include only deleted files.
115
+ const passed = await lintStaged ( {
116
+ config : {
117
+ '*.js' : 'prettier --list-different' ,
118
+ '*' : ( ) => [
119
+ /* despite empty array, this triggers processing of all files */
120
+ ] ,
121
+ } ,
122
+ cwd,
123
+ diffFilter : 'D' ,
124
+ } )
125
+
126
+ expect ( passed ) . toEqual ( true )
127
+ expect ( console . printHistory ( ) ) . toMatch ( 'Running tasks for staged files...' )
128
+ expect ( console . printHistory ( ) ) . not . toMatch ( 'fatal: pathspec' )
129
+ expect ( console . printHistory ( ) ) . not . toMatch ( 'did not match any files' )
94
130
95
131
console = globalConsoleTemp
96
132
} )
0 commit comments