@@ -36,7 +36,7 @@ function prepareChecker(args?: Partial<CheckerArgs>): Checker {
3636}
3737
3838describe ( 'checkCSSModule' , ( ) => {
39- test ( 'report diagnostics for invalid name as js identifier' , async ( ) => {
39+ test ( 'do not report diagnostics for invalid name as js identifier when namedExports is false ' , async ( ) => {
4040 const iff = await createIFF ( {
4141 'a.module.css' : dedent `
4242 .a-1 { color: red; }
@@ -47,7 +47,22 @@ describe('checkCSSModule', () => {
4747 @value b-2: red;
4848 ` ,
4949 } ) ;
50- const check = prepareChecker ( ) ;
50+ const check = prepareChecker ( { config : fakeConfig ( { namedExports : false } ) } ) ;
51+ const diagnostics = check ( readAndParseCSSModule ( iff . paths [ 'a.module.css' ] ) ! ) ;
52+ expect ( diagnostics ) . toEqual ( [ ] ) ;
53+ } ) ;
54+ test ( 'report diagnostics for invalid name as js identifier when namedExports is true' , async ( ) => {
55+ const iff = await createIFF ( {
56+ 'a.module.css' : dedent `
57+ .a-1 { color: red; }
58+ @value b-1, b-2 as a-2 from './b.module.css';
59+ ` ,
60+ 'b.module.css' : dedent `
61+ @value b-1: red;
62+ @value b-2: red;
63+ ` ,
64+ } ) ;
65+ const check = prepareChecker ( { config : fakeConfig ( { namedExports : true } ) } ) ;
5166 const diagnostics = check ( readAndParseCSSModule ( iff . paths [ 'a.module.css' ] ) ! ) ;
5267 expect ( formatDiagnostics ( diagnostics , iff . rootDir ) ) . toMatchInlineSnapshot ( `
5368 [
@@ -59,7 +74,7 @@ describe('checkCSSModule', () => {
5974 "column": 2,
6075 "line": 1,
6176 },
62- "text": "css-modules-kit does not support invalid names as JavaScript identifiers.",
77+ "text": "css-modules-kit does not support invalid names as JavaScript identifiers when \`cmkOptions.namedExports\` is set to \`true\` .",
6378 },
6479 {
6580 "category": "error",
@@ -69,7 +84,7 @@ describe('checkCSSModule', () => {
6984 "column": 8,
7085 "line": 2,
7186 },
72- "text": "css-modules-kit does not support invalid names as JavaScript identifiers.",
87+ "text": "css-modules-kit does not support invalid names as JavaScript identifiers when \`cmkOptions.namedExports\` is set to \`true\` .",
7388 },
7489 {
7590 "category": "error",
@@ -79,7 +94,7 @@ describe('checkCSSModule', () => {
7994 "column": 13,
8095 "line": 2,
8196 },
82- "text": "css-modules-kit does not support invalid names as JavaScript identifiers.",
97+ "text": "css-modules-kit does not support invalid names as JavaScript identifiers when \`cmkOptions.namedExports\` is set to \`true\` .",
8398 },
8499 {
85100 "category": "error",
@@ -89,7 +104,7 @@ describe('checkCSSModule', () => {
89104 "column": 20,
90105 "line": 2,
91106 },
92- "text": "css-modules-kit does not support invalid names as JavaScript identifiers.",
107+ "text": "css-modules-kit does not support invalid names as JavaScript identifiers when \`cmkOptions.namedExports\` is set to \`true\` .",
93108 },
94109 ]
95110 ` ) ;
0 commit comments