@@ -970,6 +970,107 @@ describe("ConfigArray", () => {
970
970
assert . strictEqual ( config , undefined ) ;
971
971
} ) ;
972
972
973
+ // https://github.com/eslint/eslint/issues/18597
974
+ it ( "should correctly handle escaped characters in `files` patterns" , ( ) => {
975
+ configs = new ConfigArray (
976
+ [
977
+ {
978
+ files : [ "src/\\{a,b}.js" ] ,
979
+ defs : {
980
+ severity : "error" ,
981
+ } ,
982
+ } ,
983
+ ] ,
984
+ { basePath, schema } ,
985
+ ) ;
986
+
987
+ configs . normalizeSync ( ) ;
988
+
989
+ assert . strictEqual (
990
+ configs . getConfig ( path . resolve ( basePath , "src" , "a.js" ) ) ,
991
+ undefined ,
992
+ ) ;
993
+ assert . strictEqual (
994
+ configs . getConfig ( path . resolve ( basePath , "src" , "b.js" ) ) ,
995
+ undefined ,
996
+ ) ;
997
+ assert . strictEqual (
998
+ configs . getConfig ( path . resolve ( basePath , "src" , "{a,b}.js" ) )
999
+ . defs . severity ,
1000
+ "error" ,
1001
+ ) ;
1002
+ } ) ;
1003
+
1004
+ it ( "should correctly handle escaped characters in `ignores` patterns" , ( ) => {
1005
+ configs = new ConfigArray (
1006
+ [
1007
+ {
1008
+ files : [ "**/*.js" ] ,
1009
+ ignores : [ "src/\\{a,b}.js" ] ,
1010
+ defs : {
1011
+ severity : "error" ,
1012
+ } ,
1013
+ } ,
1014
+ ] ,
1015
+ { basePath, schema } ,
1016
+ ) ;
1017
+
1018
+ configs . normalizeSync ( ) ;
1019
+
1020
+ assert . strictEqual (
1021
+ configs . getConfig ( path . resolve ( basePath , "src" , "a.js" ) )
1022
+ . defs . severity ,
1023
+ "error" ,
1024
+ ) ;
1025
+ assert . strictEqual (
1026
+ configs . getConfig ( path . resolve ( basePath , "src" , "b.js" ) )
1027
+ . defs . severity ,
1028
+ "error" ,
1029
+ ) ;
1030
+ assert . strictEqual (
1031
+ configs . getConfig (
1032
+ path . resolve ( basePath , "src" , "{a,b}.js" ) ,
1033
+ ) ,
1034
+ undefined ,
1035
+ ) ;
1036
+ } ) ;
1037
+
1038
+ it ( "should correctly handle escaped characters in global `ignores` patterns" , ( ) => {
1039
+ configs = new ConfigArray (
1040
+ [
1041
+ {
1042
+ files : [ "**/*.js" ] ,
1043
+ defs : {
1044
+ severity : "error" ,
1045
+ } ,
1046
+ } ,
1047
+ {
1048
+ ignores : [ "src/\\{a,b}.js" ] ,
1049
+ } ,
1050
+ ] ,
1051
+ { basePath, schema } ,
1052
+ ) ;
1053
+
1054
+ configs . normalizeSync ( ) ;
1055
+
1056
+ assert . strictEqual (
1057
+ configs . getConfig ( path . resolve ( basePath , "src" , "a.js" ) )
1058
+ . defs . severity ,
1059
+ "error" ,
1060
+ ) ;
1061
+ assert . strictEqual (
1062
+ configs . getConfig ( path . resolve ( basePath , "src" , "b.js" ) )
1063
+ . defs . severity ,
1064
+ "error" ,
1065
+ ) ;
1066
+ assert . strictEqual (
1067
+ configs . getConfig (
1068
+ path . resolve ( basePath , "src" , "{a,b}.js" ) ,
1069
+ ) ,
1070
+ undefined ,
1071
+ ) ;
1072
+ } ) ;
1073
+
973
1074
// https://github.com/eslint/eslint/issues/17103
974
1075
describe ( "ignores patterns should be properly applied" , ( ) => {
975
1076
it ( "should return undefined when a filename matches an ignores pattern but not a files pattern" , ( ) => {
0 commit comments