Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions __tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { lint } from "../lib/testing";

describe("stylelint-config", () => {
it("stylelint runs with our config", () => {
return lint(".uppercase { text-transform: uppercase; }").then((data) => {
expect(data).not.toHaveErrored();
expect(data).toHaveResultsLength(1);
});
it("stylelint runs with our config", async () => {
return await lint(".uppercase { text-transform: uppercase; }").then(
(data) => {
expect(data).not.toHaveErrored();
expect(data).toHaveResultsLength(1);
}
);
});

it("produces zero warnings with valid css", () => {
return lint(`
it("produces zero warnings with valid css", async () => {
return await lint(`
.selector-x { width: 10%; }
.selector-y { width: 20%; }
.selector-z { width: 30%; }
Expand All @@ -23,8 +25,8 @@ describe("stylelint-config", () => {
});
});

it("generates two warnings with invalid css props", () => {
return lint(`
it("generates two warnings with invalid css props", async () => {
return await lint(`
.foo {
width: 10px;
top: .2em;
Expand All @@ -41,7 +43,7 @@ describe("stylelint-config", () => {
});
});

it("generates warnings with invalid BEM selectors", () => {
it("generates warnings with invalid BEM selectors", async () => {
return lint(`
.foo__bar__baz {
width: 10px;
Expand All @@ -59,4 +61,26 @@ describe("stylelint-config", () => {
expect(data).toHaveWarningsLength(3);
});
});

it("should disallow warning comments", async () => {
const addNewlinePatterns = (patterns) =>
patterns.flatMap((pattern) => [pattern, pattern.replace(/\s+/g, "\n")]);
const warningWords = ["TODO", "todo", "toDo", "FIXME", "fixme", "fiXme"];
const wrongPatterns = warningWords.flatMap((w) =>
addNewlinePatterns([
`/* ${w} foo */`,
`/* foo ${w} */`,
`/* foo ${w} bar */`,
])
);

for (const wrongPattern of wrongPatterns) {
await lint(wrongPattern).then((data) => {
expect(data).toHaveErrored();
expect(data).toHaveWarningsLength(1);
});
}

expect.assertions(wrongPatterns.length * 2);
});
});
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default {
"color-named": "always-where-possible",
"color-no-invalid-hex": true,
"comment-no-empty": null,
"comment-word-disallowed-list": ["/\\b(?:fixme|todo)\\b/i"],
"custom-property-pattern": null,
"declaration-block-no-duplicate-properties": [
true,
Expand Down