@@ -1003,3 +1003,219 @@ ruleTester.run(
1003
1003
] ,
1004
1004
}
1005
1005
) ;
1006
+
1007
+ ruleTester . run (
1008
+ "filename-naming-convention with option: [{ '**/*.js': 'CAMEL_CASE' }, { ignoreMiddleExtensions: true }]" ,
1009
+ rule ,
1010
+ {
1011
+ valid : [
1012
+ {
1013
+ code : "var foo = 'bar';" ,
1014
+ filename : 'src/utils/date.js' ,
1015
+ options : [
1016
+ { '**/*.js' : 'CAMEL_CASE' } ,
1017
+ { ignoreMiddleExtensions : true } ,
1018
+ ] ,
1019
+ } ,
1020
+ {
1021
+ code : "var foo = 'bar';" ,
1022
+ filename : 'src/utils/date.test.js' ,
1023
+ options : [
1024
+ { '**/*.js' : 'CAMEL_CASE' } ,
1025
+ { ignoreMiddleExtensions : true } ,
1026
+ ] ,
1027
+ } ,
1028
+ {
1029
+ code : "var foo = 'bar';" ,
1030
+ filename : 'src/utils/date.spec.js' ,
1031
+ options : [
1032
+ { '**/*.js' : 'CAMEL_CASE' } ,
1033
+ { ignoreMiddleExtensions : true } ,
1034
+ ] ,
1035
+ } ,
1036
+ {
1037
+ code : "var foo = 'bar';" ,
1038
+ filename : 'src/utils/date.spec.test.js' ,
1039
+ options : [
1040
+ { '**/*.js' : 'CAMEL_CASE' } ,
1041
+ { ignoreMiddleExtensions : true } ,
1042
+ ] ,
1043
+ } ,
1044
+ ] ,
1045
+
1046
+ invalid : [
1047
+ {
1048
+ code : "var foo = 'bar';" ,
1049
+ filename : 'src/utils/Date.js' ,
1050
+ options : [
1051
+ { '**/*.js' : 'CAMEL_CASE' } ,
1052
+ { ignoreMiddleExtensions : true } ,
1053
+ ] ,
1054
+ errors : [
1055
+ {
1056
+ message :
1057
+ 'The filename "src/utils/Date.js" does not match the "CAMEL_CASE" style' ,
1058
+ column : 1 ,
1059
+ line : 1 ,
1060
+ } ,
1061
+ ] ,
1062
+ } ,
1063
+ {
1064
+ code : "var foo = 'bar';" ,
1065
+ filename : 'src/utils/Date.test.js' ,
1066
+ options : [
1067
+ { '**/*.js' : 'CAMEL_CASE' } ,
1068
+ { ignoreMiddleExtensions : true } ,
1069
+ ] ,
1070
+ errors : [
1071
+ {
1072
+ message :
1073
+ 'The filename "src/utils/Date.test.js" does not match the "CAMEL_CASE" style' ,
1074
+ column : 1 ,
1075
+ line : 1 ,
1076
+ } ,
1077
+ ] ,
1078
+ } ,
1079
+ {
1080
+ code : "var foo = 'bar';" ,
1081
+ filename : 'src/utils/Date.spec.js' ,
1082
+ options : [
1083
+ { '**/*.js' : 'CAMEL_CASE' } ,
1084
+ { ignoreMiddleExtensions : true } ,
1085
+ ] ,
1086
+ errors : [
1087
+ {
1088
+ message :
1089
+ 'The filename "src/utils/Date.spec.js" does not match the "CAMEL_CASE" style' ,
1090
+ column : 1 ,
1091
+ line : 1 ,
1092
+ } ,
1093
+ ] ,
1094
+ } ,
1095
+ {
1096
+ code : "var foo = 'bar';" ,
1097
+ filename : 'src/utils/date_util.spec.js' ,
1098
+ options : [
1099
+ { '**/*.js' : 'CAMEL_CASE' } ,
1100
+ { ignoreMiddleExtensions : true } ,
1101
+ ] ,
1102
+ errors : [
1103
+ {
1104
+ message :
1105
+ 'The filename "src/utils/date_util.spec.js" does not match the "CAMEL_CASE" style' ,
1106
+ column : 1 ,
1107
+ line : 1 ,
1108
+ } ,
1109
+ ] ,
1110
+ } ,
1111
+ {
1112
+ code : "var foo = 'bar';" ,
1113
+ filename : 'src/utils/date_util.spec.test.js' ,
1114
+ options : [
1115
+ { '**/*.js' : 'CAMEL_CASE' } ,
1116
+ { ignoreMiddleExtensions : true } ,
1117
+ ] ,
1118
+ errors : [
1119
+ {
1120
+ message :
1121
+ 'The filename "src/utils/date_util.spec.test.js" does not match the "CAMEL_CASE" style' ,
1122
+ column : 1 ,
1123
+ line : 1 ,
1124
+ } ,
1125
+ ] ,
1126
+ } ,
1127
+ ] ,
1128
+ }
1129
+ ) ;
1130
+
1131
+ ruleTester . run (
1132
+ "filename-naming-convention with option: [{ '*.js': 'CAMEL_CASE', '*.jsx': 'CAMEL_CASE' }, { ignoreMiddleExtensions: false }]" ,
1133
+ rule ,
1134
+ {
1135
+ valid : [
1136
+ {
1137
+ code : "var foo = 'bar';" ,
1138
+ filename : 'src/components/login.jsx' ,
1139
+ options : [
1140
+ { '*.js' : 'CAMEL_CASE' , '*.jsx' : 'CAMEL_CASE' } ,
1141
+ { ignoreMiddleExtensions : false } ,
1142
+ ] ,
1143
+ } ,
1144
+ {
1145
+ code : "var foo = 'bar';" ,
1146
+ filename : 'src/utils/calculatePrice.js' ,
1147
+ options : [
1148
+ { '*.js' : 'CAMEL_CASE' , '*.jsx' : 'CAMEL_CASE' } ,
1149
+ { ignoreMiddleExtensions : false } ,
1150
+ ] ,
1151
+ } ,
1152
+ ] ,
1153
+
1154
+ invalid : [
1155
+ {
1156
+ code : "var foo = 'bar';" ,
1157
+ filename : 'src/utils/CalculatePrice.js' ,
1158
+ options : [
1159
+ { '*.js' : 'CAMEL_CASE' , '*.jsx' : 'CAMEL_CASE' } ,
1160
+ { ignoreMiddleExtensions : false } ,
1161
+ ] ,
1162
+ errors : [
1163
+ {
1164
+ message :
1165
+ 'The filename "CalculatePrice.js" does not match the "CAMEL_CASE" style' ,
1166
+ column : 1 ,
1167
+ line : 1 ,
1168
+ } ,
1169
+ ] ,
1170
+ } ,
1171
+ {
1172
+ code : "var foo = 'bar';" ,
1173
+ filename : 'src/utils/calculate_price.js' ,
1174
+ options : [
1175
+ { '*.js' : 'CAMEL_CASE' , '*.jsx' : 'CAMEL_CASE' } ,
1176
+ { ignoreMiddleExtensions : false } ,
1177
+ ] ,
1178
+ errors : [
1179
+ {
1180
+ message :
1181
+ 'The filename "calculate_price.js" does not match the "CAMEL_CASE" style' ,
1182
+ column : 1 ,
1183
+ line : 1 ,
1184
+ } ,
1185
+ ] ,
1186
+ } ,
1187
+ {
1188
+ code : "var foo = 'bar';" ,
1189
+ filename : 'src/utils/calculate-price.js' ,
1190
+ options : [
1191
+ { '*.js' : 'CAMEL_CASE' , '*.jsx' : 'CAMEL_CASE' } ,
1192
+ { ignoreMiddleExtensions : false } ,
1193
+ ] ,
1194
+ errors : [
1195
+ {
1196
+ message :
1197
+ 'The filename "calculate-price.js" does not match the "CAMEL_CASE" style' ,
1198
+ column : 1 ,
1199
+ line : 1 ,
1200
+ } ,
1201
+ ] ,
1202
+ } ,
1203
+ {
1204
+ code : "var foo = 'bar';" ,
1205
+ filename : 'src/utils/CALCULATE_PRICE.js' ,
1206
+ options : [
1207
+ { '*.js' : 'CAMEL_CASE' , '*.jsx' : 'CAMEL_CASE' } ,
1208
+ { ignoreMiddleExtensions : false } ,
1209
+ ] ,
1210
+ errors : [
1211
+ {
1212
+ message :
1213
+ 'The filename "CALCULATE_PRICE.js" does not match the "CAMEL_CASE" style' ,
1214
+ column : 1 ,
1215
+ line : 1 ,
1216
+ } ,
1217
+ ] ,
1218
+ } ,
1219
+ ] ,
1220
+ }
1221
+ ) ;
0 commit comments