@@ -10,7 +10,7 @@ import { createIFF } from './test/fixture.js';
1010describe ( 'createProject' , ( ) => {
1111 test ( 'creates project' , async ( ) => {
1212 const iff = await createIFF ( {
13- 'tsconfig.json' : '{}' ,
13+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
1414 } ) ;
1515 const project = createProject ( { project : iff . rootDir } ) ;
1616 expect ( project . config . dtsOutDir ) . toContain ( 'generated' ) ;
@@ -23,7 +23,7 @@ describe('createProject', () => {
2323 'throws ReadCSSModuleFileError when a CSS module file cannot be read' ,
2424 async ( ) => {
2525 const iff = await createIFF ( {
26- 'tsconfig.json' : '{}' ,
26+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
2727 'src/a.module.css' : '.a1 { color: red; }' ,
2828 } ) ;
2929 await chmod ( iff . paths [ 'src/a.module.css' ] , 0o200 ) ; // Remove read permission
@@ -50,7 +50,7 @@ test('isWildcardMatchedFile', async () => {
5050describe ( 'addFile' , ( ) => {
5151 test ( 'The diagnostics of the added file are reported, and .d.ts file is emitted' , async ( ) => {
5252 const iff = await createIFF ( {
53- 'tsconfig.json' : '{}' ,
53+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
5454 'src' : { } ,
5555 } ) ;
5656 const project = createProject ( { project : iff . rootDir } ) ;
@@ -90,7 +90,7 @@ describe('addFile', () => {
9090 // - The check stage cache for files that directly import the added file should be invalidated.
9191 // - The check stage cache for files that indirectly import the added file should also be invalidated.
9292 const iff = await createIFF ( {
93- 'tsconfig.json' : '{}' ,
93+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
9494 'src/b.module.css' : '@import "./a.module.css";' , // directly
9595 'src/c.module.css' : '@value a_1 from "./b.module.css";' , // indirectly
9696 } ) ;
@@ -134,7 +134,8 @@ describe('addFile', () => {
134134 "paths": {
135135 "@/a.module.css": ["src/a-1.module.css", "src/a-2.module.css"]
136136 }
137- }
137+ },
138+ "cmkOptions": { "enabled": true }
138139 }
139140 ` ,
140141 'src/a-2.module.css' : '@value a_2: red;' ,
@@ -165,7 +166,7 @@ describe('addFile', () => {
165166describe ( 'updateFile' , ( ) => {
166167 test ( 'The new diagnostics of the changed file are reported, and new .d.ts file is emitted' , async ( ) => {
167168 const iff = await createIFF ( {
168- 'tsconfig.json' : '{}' ,
169+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
169170 'src/a.module.css' : '' ,
170171 } ) ;
171172 const project = createProject ( { project : iff . rootDir } ) ;
@@ -226,7 +227,7 @@ describe('updateFile', () => {
226227 // - The check stage cache for files that directly import the changed file should be invalidated.
227228 // - The check stage cache for files that indirectly import the changed file should also be invalidated.
228229 const iff = await createIFF ( {
229- 'tsconfig.json' : '{}' ,
230+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
230231 'src/a.module.css' : '' ,
231232 'src/b.module.css' : dedent `
232233 @value a_1 from "./a.module.css";
@@ -268,7 +269,7 @@ describe('updateFile', () => {
268269describe ( 'removeFile' , ( ) => {
269270 test ( 'The diagnostics of the removed file are not reported, and .d.ts file is not emitted' , async ( ) => {
270271 const iff = await createIFF ( {
271- 'tsconfig.json' : '{}' ,
272+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
272273 'src/a.module.css' : '.a_1 {' ,
273274 } ) ;
274275 const project = createProject ( { project : iff . rootDir } ) ;
@@ -308,7 +309,7 @@ describe('removeFile', () => {
308309 // - The check stage cache for files that directly import the changed file should be invalidated.
309310 // - The check stage cache for files that indirectly import the changed file should also be invalidated.
310311 const iff = await createIFF ( {
311- 'tsconfig.json' : '{}' ,
312+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
312313 'src/a.module.css' : '@value a_1: red;' ,
313314 'src/b.module.css' : '@import "./a.module.css";' , // directly
314315 'src/c.module.css' : '@value a_1 from "./b.module.css";' , // indirectly
@@ -353,7 +354,8 @@ describe('removeFile', () => {
353354 "paths": {
354355 "@/a.module.css": ["src/a-1.module.css", "src/a-2.module.css"]
355356 }
356- }
357+ },
358+ "cmkOptions": { "enabled": true }
357359 }
358360 ` ,
359361 'src/a-1.module.css' : '@value a_1: red;' ,
@@ -385,16 +387,32 @@ describe('removeFile', () => {
385387describe ( 'getDiagnostics' , ( ) => {
386388 test ( 'returns empty array when no diagnostics' , async ( ) => {
387389 const iff = await createIFF ( {
388- 'tsconfig.json' : '{}' ,
390+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
389391 'src/a.module.css' : '.a_1 { color: red; }' ,
390392 } ) ;
391393 const project = createProject ( { project : iff . rootDir } ) ;
392394 const diagnostics = project . getDiagnostics ( ) ;
393395 expect ( diagnostics ) . toEqual ( [ ] ) ;
394396 } ) ;
397+ test ( 'returns warning when enabled is not specified' , async ( ) => {
398+ const iff = await createIFF ( {
399+ 'tsconfig.json' : '{}' ,
400+ 'src/a.module.css' : '.a_1 { color: red; }' ,
401+ } ) ;
402+ const project = createProject ( { project : iff . rootDir } ) ;
403+ const diagnostics = project . getDiagnostics ( ) ;
404+ expect ( formatDiagnostics ( diagnostics , iff . rootDir ) ) . toMatchInlineSnapshot ( `
405+ [
406+ {
407+ "category": "warning",
408+ "text": ""cmkOptions.enabled" will be required in a future version of css-modules-kit. Add \`"cmkOptions": { "enabled": true }\` to <rootDir>/tsconfig.json. See https://github.com/mizdra/css-modules-kit/issues/289 for details.",
409+ },
410+ ]
411+ ` ) ;
412+ } ) ;
395413 test ( 'returns project diagnostics' , async ( ) => {
396414 const iff = await createIFF ( {
397- 'tsconfig.json' : '{ "cmkOptions": { "dtsOutDir": 1 } }' ,
415+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true, " dtsOutDir": 1 } }' ,
398416 } ) ;
399417 const project = createProject ( { project : iff . rootDir } ) ;
400418 const diagnostics = project . getDiagnostics ( ) ;
@@ -413,7 +431,7 @@ describe('getDiagnostics', () => {
413431 } ) ;
414432 test ( 'returns syntactic diagnostics' , async ( ) => {
415433 const iff = await createIFF ( {
416- 'tsconfig.json' : '{}' ,
434+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
417435 'src/a.module.css' : '.a_1 {' ,
418436 'src/b.module.css' : '.a_2 { color }' ,
419437 } ) ;
@@ -447,7 +465,7 @@ describe('getDiagnostics', () => {
447465
448466 test ( 'returns semantic diagnostics' , async ( ) => {
449467 const iff = await createIFF ( {
450- 'tsconfig.json' : '{}' ,
468+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
451469 'src/a.module.css' : `@import './non-existent-1.module.css';` ,
452470 'src/b.module.css' : `@import './non-existent-2.module.css';` ,
453471 } ) ;
@@ -480,7 +498,7 @@ describe('getDiagnostics', () => {
480498 } ) ;
481499 test ( 'skips semantic diagnostics when project or syntactic diagnostics exist' , async ( ) => {
482500 const iff = await createIFF ( {
483- 'tsconfig.json' : '{ "cmkOptions": { "dtsOutDir": 1 } }' ,
501+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true, " dtsOutDir": 1 } }' ,
484502 'src/a.module.css' : '.a_1 {' ,
485503 'src/b.module.css' : `@import './non-existent.module.css';` ,
486504 } ) ;
@@ -510,7 +528,7 @@ describe('getDiagnostics', () => {
510528describe ( 'emitDtsFiles' , ( ) => {
511529 test ( 'emits .d.ts files' , async ( ) => {
512530 const iff = await createIFF ( {
513- 'tsconfig.json' : '{}' ,
531+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
514532 'src/a.module.css' : '.a1 { color: red; }' ,
515533 'src/b.module.css' : '.b1 { color: blue; }' ,
516534 } ) ;
@@ -535,7 +553,7 @@ describe('emitDtsFiles', () => {
535553 } ) ;
536554 test ( 'does not emit .d.ts files for files not matched by `pattern`' , async ( ) => {
537555 const iff = await createIFF ( {
538- 'tsconfig.json' : '{}' ,
556+ 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
539557 'src/a.module.css' : '.a1 { color: red; }' ,
540558 'src/b.css' : '.b1 { color: blue; }' ,
541559 } ) ;
0 commit comments