@@ -2925,6 +2925,107 @@ describe("ESLint", () => {
2925
2925
} ) ;
2926
2926
} ) ;
2927
2927
2928
+ describe ( "Globbing based on configs with negated patterns and arrays in `files`" , ( ) => {
2929
+ // https://github.com/eslint/eslint/issues/19813
2930
+ it ( "should not include custom extensions when negated pattern is specified in `files`" , async ( ) => {
2931
+ eslint = new ESLint ( {
2932
+ flags,
2933
+ cwd : getFixturePath ( "file-extensions" ) ,
2934
+ overrideConfigFile : true ,
2935
+ overrideConfig : [
2936
+ {
2937
+ files : [ "!foo.js" ] ,
2938
+ } ,
2939
+ {
2940
+ files : [ "!foo.jsx" ] ,
2941
+ } ,
2942
+ {
2943
+ files : [ "!foo.ts" ] ,
2944
+ } ,
2945
+ {
2946
+ files : [ "!g.tsx" ] ,
2947
+ } ,
2948
+ ] ,
2949
+ } ) ;
2950
+ const results = await eslint . lintFiles ( [ "." ] ) ;
2951
+
2952
+ // should not include d.jsx, f.ts, and other extensions that are not linted by default
2953
+ assert . strictEqual ( results . length , 4 ) ;
2954
+ assert . deepStrictEqual (
2955
+ results . map ( ( { filePath } ) => path . basename ( filePath ) ) ,
2956
+ [ "a.js" , "b.mjs" , "c.cjs" , "eslint.config.js" ] ,
2957
+ ) ;
2958
+ } ) ;
2959
+
2960
+ it ( "should not include custom extensions when negated pattern is specified in an array in `files`" , async ( ) => {
2961
+ eslint = new ESLint ( {
2962
+ flags,
2963
+ cwd : getFixturePath ( "file-extensions" ) ,
2964
+ overrideConfigFile : true ,
2965
+ overrideConfig : [
2966
+ {
2967
+ files : [ [ "*" , "!foo.js" ] ] ,
2968
+ } ,
2969
+ {
2970
+ files : [ [ "!foo.js" , "*" ] ] ,
2971
+ } ,
2972
+ {
2973
+ files : [ [ "*" , "!foo.ts" ] ] ,
2974
+ } ,
2975
+ {
2976
+ files : [ [ "!foo.ts" , "*" ] ] ,
2977
+ } ,
2978
+ {
2979
+ files : [ [ "*" , "!g.tsx" ] ] ,
2980
+ } ,
2981
+ {
2982
+ files : [ [ "!g.tsx" , "*" ] ] ,
2983
+ } ,
2984
+ ] ,
2985
+ } ) ;
2986
+ const results = await eslint . lintFiles ( [ "." ] ) ;
2987
+
2988
+ // should not include d.jsx, f.ts, and other extensions that are not linted by default
2989
+ assert . strictEqual ( results . length , 4 ) ;
2990
+ assert . deepStrictEqual (
2991
+ results . map ( ( { filePath } ) => path . basename ( filePath ) ) ,
2992
+ [ "a.js" , "b.mjs" , "c.cjs" , "eslint.config.js" ] ,
2993
+ ) ;
2994
+ } ) ;
2995
+
2996
+ // https://github.com/eslint/eslint/issues/19814
2997
+ it ( "should include custom extensions when matched by a non-universal pattern specified in an array in `files`" , async ( ) => {
2998
+ eslint = new ESLint ( {
2999
+ flags,
3000
+ cwd : getFixturePath ( "file-extensions" , ".." ) ,
3001
+ overrideConfigFile : true ,
3002
+ overrideConfig : [
3003
+ {
3004
+ files : [ [ "**/*.jsx" , "file-extensions/*" ] ] ,
3005
+ } ,
3006
+ {
3007
+ files : [ [ "file-extensions/*" , "**/*.ts" ] ] ,
3008
+ } ,
3009
+ ] ,
3010
+ } ) ;
3011
+ const results = await eslint . lintFiles ( [ "file-extensions" ] ) ;
3012
+
3013
+ // should include d.jsx and f.ts, but not other extensions that are not linted by default
3014
+ assert . strictEqual ( results . length , 6 ) ;
3015
+ assert . deepStrictEqual (
3016
+ results . map ( ( { filePath } ) => path . basename ( filePath ) ) ,
3017
+ [
3018
+ "a.js" ,
3019
+ "b.mjs" ,
3020
+ "c.cjs" ,
3021
+ "d.jsx" ,
3022
+ "eslint.config.js" ,
3023
+ "f.ts" ,
3024
+ ] ,
3025
+ ) ;
3026
+ } ) ;
3027
+ } ) ;
3028
+
2928
3029
it ( "should report zero messages when given a '**' pattern with a .js and a .js2 file" , async ( ) => {
2929
3030
eslint = new ESLint ( {
2930
3031
flags,
0 commit comments