Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
add failing test for postcss config
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodldavis committed Nov 1, 2020
1 parent ccc459b commit f6e6480
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/fixtures/no-unknown-class/postcss-config/Component.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Component() {
return <div className="my-custom-component"></div>;
}
5 changes: 5 additions & 0 deletions tests/fixtures/no-unknown-class/postcss-config/components.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@layer components {
.my-custom-component {
@apply bg-green-100 text-black;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: ["postcss-import", "postcss-nested", "tailwindcss", "postcss-extend"],
};
5 changes: 5 additions & 0 deletions tests/fixtures/no-unknown-class/postcss-config/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "./components.css";

@tailwind base;
@tailwind utilities;
@tailwind components;
12 changes: 12 additions & 0 deletions tests/fixtures/no-unknown-class/postcss-config/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
future: {
// removeDeprecatedGapUtilities: true,
// purgeLayersByDefault: true,
},
purge: [],
theme: {
extend: {},
},
variants: {},
plugins: [],
};
21 changes: 20 additions & 1 deletion tests/lib/rules/no-unknown-class.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import fs from "fs";
import path from "path";

import { RuleTester } from "eslint";

import loadTestCases from "../../load-test-cases";
Expand All @@ -12,4 +15,20 @@ const tester = new RuleTester({
},
});

tester.run("no-unknown-class", rule, loadTestCases("no-unknown-class"));
function postcssConfigTestCase(): RuleTester.ValidTestCase {
const fixtureRoot = path.join(__dirname, "../../fixtures/no-unknown-class/postcss-config");

function read(filename: string): string {
return fs.readFileSync(path.join(fixtureRoot, filename), { encoding: "utf-8" });
}

return {
filename: "postcss-config",
code: read("Component.jsx"),
options: [{ config: { postcss: true }, stylesheet: path.join(fixtureRoot, "styles.css") }],
};
}

const cases = loadTestCases("no-unknown-class");
cases.valid.push(postcssConfigTestCase());
tester.run("no-unknown-class", rule, cases);

0 comments on commit f6e6480

Please sign in to comment.