@@ -1164,6 +1164,56 @@ describe("ESLint", () => {
1164
1164
} ) ;
1165
1165
} ) ;
1166
1166
1167
+ describe ( "Overlapping searches" , ( ) => {
1168
+ it ( "should not lint the same file multiple times when the file path was passed multiple times" , async ( ) => {
1169
+ const cwd = getFixturePath ( ) ;
1170
+
1171
+ eslint = new ESLint ( {
1172
+ cwd,
1173
+ overrideConfigFile : true
1174
+ } ) ;
1175
+
1176
+ const results = await eslint . lintFiles ( [ "files/foo.js" , "files/../files/foo.js" , "files/foo.js" ] ) ;
1177
+
1178
+ assert . strictEqual ( results . length , 1 ) ;
1179
+ assert . strictEqual ( results [ 0 ] . filePath , path . resolve ( cwd , "files/foo.js" ) ) ;
1180
+ assert . strictEqual ( results [ 0 ] . messages . length , 0 ) ;
1181
+ assert . strictEqual ( results [ 0 ] . suppressedMessages . length , 0 ) ;
1182
+ } ) ;
1183
+
1184
+ it ( "should not lint the same file multiple times when the file path and a pattern that matches the file were passed" , async ( ) => {
1185
+ const cwd = getFixturePath ( ) ;
1186
+
1187
+ eslint = new ESLint ( {
1188
+ cwd,
1189
+ overrideConfigFile : true
1190
+ } ) ;
1191
+
1192
+ const results = await eslint . lintFiles ( [ "files/foo.js" , "files/foo*" ] ) ;
1193
+
1194
+ assert . strictEqual ( results . length , 1 ) ;
1195
+ assert . strictEqual ( results [ 0 ] . filePath , path . resolve ( cwd , "files/foo.js" ) ) ;
1196
+ assert . strictEqual ( results [ 0 ] . messages . length , 0 ) ;
1197
+ assert . strictEqual ( results [ 0 ] . sup
BE45
pressedMessages . length , 0 ) ;
1198
+ } ) ;
1199
+
1200
+ it ( "should not lint the same file multiple times when multiple patterns that match the file were passed" , async ( ) => {
1201
+ const cwd = getFixturePath ( ) ;
1202
+
1203
+ eslint = new ESLint ( {
1204
+ cwd,
1205
+ overrideConfigFile : true
1206
+ } ) ;
1207
+
1208
+ const results = await eslint . lintFiles ( [ "files/f*.js" , "files/foo*" ] ) ;
1209
+
1210
+ assert . strictEqual ( results . length , 1 ) ;
1211
+ assert . strictEqual ( results [ 0 ] . filePath , path . resolve ( cwd , "files/foo.js" ) ) ;
1212
+ assert . strictEqual ( results [ 0 ] . messages . length , 0 ) ;
1213
+ assert . strictEqual ( results [ 0 ] . suppressedMessages . length , 0 ) ;
1214
+ } ) ;
1215
+ } ) ;
1216
+
1167
1217
describe ( "Invalid inputs" , ( ) => {
1168
1218
1169
1219
[
0 commit comments