@@ -1180,6 +1180,126 @@ const tests = [
1180
1180
content: '';
1181
1181
}` ,
1182
1182
} ,
1183
+ {
1184
+ name : "should disable pure mode checks for entire file with no-check comment" ,
1185
+ options : { mode : "pure" } ,
1186
+ input : `/* cssmodules-pure-no-check */
1187
+ :global(.foo) { border: 1px solid #e2e8f0 }
1188
+ :global(.bar) { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) }
1189
+ :global(.baz) { background: #4299e1 }` ,
1190
+ expected : `/* cssmodules-pure-no-check */
1191
+ .foo { border: 1px solid #e2e8f0 }
1192
+ .bar { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) }
1193
+ .baz { background: #4299e1 }` ,
1194
+ } ,
1195
+ {
1196
+ name : "should disable pure mode checks for nested selectors" ,
1197
+ options : { mode : "pure" } ,
1198
+ input : `/* cssmodules-pure-no-check */
1199
+ :global(.foo) {
1200
+ &:hover { border-color: #cbd5e0 }
1201
+ & :global(.bar) { color: blue }
1202
+ }` ,
1203
+ expected : `/* cssmodules-pure-no-check */
1204
+ .foo {
1205
+ &:hover { border-color: #cbd5e0 }
1206
+ & .bar { color: blue }
1207
+ }` ,
1208
+ } ,
1209
+ {
1210
+ name : "should ignore no-check comment if not at root level" ,
1211
+ options : { mode : "pure" } ,
1212
+ input : `:global(.bar) { color: blue }
1213
+ /* cssmodules-pure-no-check */` ,
1214
+ error : / i s n o t p u r e / ,
1215
+ } ,
1216
+ {
1217
+ name : "should ignore no-check comment if not at root level #2" ,
1218
+ options : { mode : "pure" } ,
1219
+ input : `/* Some file description */
1220
+ .class { color: red; }
1221
+ /* cssmodules-pure-no-check */
1222
+ :global(.foo) { color: blue }` ,
1223
+ error : / i s n o t p u r e / ,
1224
+ } ,
1225
+ {
1226
+ name : "should allow other comments before no-check comment" ,
1227
+ options : { mode : "pure" } ,
1228
+ input : `/* Some file description */
1229
+ /* cssmodules-pure-no-check */
1230
+ :global(.foo) { color: blue }` ,
1231
+ expected : `/* Some file description */
1232
+ /* cssmodules-pure-no-check */
1233
+ .foo { color: blue }` ,
1234
+ } ,
1235
+ {
1236
+ name : "should disable pure mode checks for deep nested selectors" ,
1237
+ options : { mode : "pure" } ,
1238
+ input : `/* cssmodules-pure-no-check */
1239
+ :global(.foo) { max-width: 600px }
1240
+ :global(.bar) { background: #fafafa }
1241
+ :global(.baz) {
1242
+ :global(.foobar) {
1243
+ &::-webkit-scrollbar { width: 8px }
1244
+ }
1245
+ }` ,
1246
+ expected : `/* cssmodules-pure-no-check */
1247
+ .foo { max-width: 600px }
1248
+ .bar { background: #fafafa }
1249
+ .baz {
1250
+ .foobar {
1251
+ &::-webkit-scrollbar { width: 8px }
1252
+ }
1253
+ }` ,
1254
+ } ,
1255
+ {
1256
+ name : "should work with keyframes when no-check is enabled" ,
1257
+ options : { mode : "pure" } ,
1258
+ input : `/* cssmodules-pure-no-check */
1259
+ @keyframes :global(fadeIn) {
1260
+ from { opacity: 0 }
1261
+ to { opacity: 1 }
1262
+ }
1263
+ :global(.animate) { animation: global(fadeIn) 0.3s }` ,
1264
+ expected : `/* cssmodules-pure-no-check */
1265
+ @keyframes fadeIn {
1266
+ from { opacity: 0 }
1267
+ to { opacity: 1 }
1268
+ }
1269
+ .animate { animation: fadeIn 0.3s }` ,
1270
+ } ,
1271
+ {
1272
+ name : "should allow multiline no-check comment" ,
1273
+ options : { mode : "pure" } ,
1274
+ input : `/*
1275
+ cssmodules-pure-no-check
1276
+ */
1277
+ :global(.foo) { color: blue }` ,
1278
+ expected : `/*
1279
+ cssmodules-pure-no-check
1280
+ */
1281
+ .foo { color: blue }` ,
1282
+ } ,
1283
+ {
1284
+ name : "should allow additional text in no-check comment" ,
1285
+ options : { mode : "pure" } ,
1286
+ input : `/* cssmodules-pure-no-check - needed for styling third-party components */
1287
+ :global(.foo) { color: blue }` ,
1288
+ expected : `/* cssmodules-pure-no-check - needed for styling third-party components */
1289
+ .foo { color: blue }` ,
1290
+ } ,
1291
+ {
1292
+ name : "should work with media queries when no-check is enabled" ,
1293
+ options : { mode : "pure" } ,
1294
+ input : `/* cssmodules-pure-no-check */
1295
+ @media (max-width: 768px) {
1296
+ :global(.foo) { position: fixed }
1297
+ }` ,
1298
+ expected : `/* cssmodules-pure-no-check */
1299
+ @media (max-width: 768px) {
1300
+ .foo { position: fixed }
1301
+ }` ,
1302
+ } ,
1183
1303
{
1184
1304
name : "css nesting" ,
1185
1305
input : `
0 commit comments