Skip to content

Commit d93ac47

Browse files
committed
Ignore keys with newlines (this will solve all previous errors)
1 parent b476b8d commit d93ac47

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const camelCase = require("camelcase");
77
* @returns {string[]}
88
*/
99
const getCssModuleKeys = (content) => {
10-
const keyRegex = /"([^:")][^")]*)":/g;
10+
const keyRegex = /"([^"\n]+)":/g;
1111
let match;
1212
const cssModuleKeys = [];
1313

test/utils.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,13 @@ describe("getCssModuleKeys", () => {
7070
const actual = getCssModuleKeys(content);
7171
expect(actual).toEqual(["øæå", "+~@", "f\\'o\\'o"]);
7272
});
73+
74+
it("CSS module with newline in class names should be ignored", () => {
75+
const content = `.locals = {
76+
"line1
77+
line2": "twolinesdoesnotmakesense"
78+
};`;
79+
const actual = getCssModuleKeys(content);
80+
expect(actual).toEqual([]);
81+
});
7382
});

0 commit comments

Comments
 (0)