@maniumek/suwgate 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint/index.d.ts +1 -0
- package/dist/eslint/index.js +20 -1
- package/dist/profiles/node.d.ts +1 -0
- package/dist/profiles/node.js +12 -4
- package/dist/profiles/verdict.js +4 -1
- package/package.json +3 -1
package/dist/eslint/index.d.ts
CHANGED
package/dist/eslint/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import js from "@eslint/js";
|
|
3
4
|
import { defineConfig, globalIgnores } from "eslint/config";
|
|
5
|
+
import betterTailwindcss from "eslint-plugin-better-tailwindcss";
|
|
4
6
|
import boundaries from "eslint-plugin-boundaries";
|
|
5
7
|
import tseslint from "typescript-eslint";
|
|
6
8
|
import { noComments } from "./noComments.js";
|
|
@@ -8,6 +10,7 @@ export { noComments };
|
|
|
8
10
|
const BOUNDARIES_PLUGIN = boundaries;
|
|
9
11
|
const CODE = ["**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts}"];
|
|
10
12
|
const SOURCES = ["src/**/*.{ts,tsx}"];
|
|
13
|
+
const TAILWIND_ENTRY_POINT = "src/index.css";
|
|
11
14
|
const BROWSER_STORAGE = ["localStorage", "sessionStorage", "indexedDB"];
|
|
12
15
|
const BROWSER_STORAGE_FIX = "Keep the state on the server, in the address or in React; browser storage is allowed only in the files that storage of app() names in eslint.config.js.";
|
|
13
16
|
const BOUNDARIES_FIX = "A feature of src/ imports only itself and the shared folders, a shared folder only itself (and the shared folders sharedImports of app() lets it), a file directly in src/ anything; a new folder of src/ goes into features or shared of app() in eslint.config.js.";
|
|
@@ -15,6 +18,22 @@ export const plugin = {
|
|
|
15
18
|
meta: { name: "@maniumek/suwgate" },
|
|
16
19
|
rules: { "no-comments": noComments },
|
|
17
20
|
};
|
|
21
|
+
function unknownTailwindClasses(options) {
|
|
22
|
+
const entryPoint = path.resolve(options.root, options.tailwindEntryPoint ?? TAILWIND_ENTRY_POINT);
|
|
23
|
+
if (!existsSync(entryPoint)) {
|
|
24
|
+
if (options.tailwindEntryPoint === undefined)
|
|
25
|
+
return [];
|
|
26
|
+
throw new Error(`tailwindEntryPoint of strict() or app() in eslint.config.js names ${entryPoint}, which does not exist: name the CSS file that imports tailwindcss, relative to root`);
|
|
27
|
+
}
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
files: CODE,
|
|
31
|
+
plugins: { "better-tailwindcss": betterTailwindcss },
|
|
32
|
+
settings: { "better-tailwindcss": { cwd: options.root, entryPoint } },
|
|
33
|
+
rules: { "better-tailwindcss/no-unknown-classes": "error" },
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
18
37
|
export function strict(options) {
|
|
19
38
|
return defineConfig(globalIgnores(["dist", ".artifacts", ...(options.ignores ?? [])]), js.configs.recommended, tseslint.configs.strictTypeChecked, tseslint.configs.stylisticTypeChecked, {
|
|
20
39
|
linterOptions: { noInlineConfig: true },
|
|
@@ -30,7 +49,7 @@ export function strict(options) {
|
|
|
30
49
|
files: CODE,
|
|
31
50
|
plugins: { suwgate: plugin },
|
|
32
51
|
rules: { "suwgate/no-comments": "error" },
|
|
33
|
-
}, {
|
|
52
|
+
}, unknownTailwindClasses(options), {
|
|
34
53
|
files: ["eslint.config.js", ...(options.untyped ?? [])],
|
|
35
54
|
extends: [tseslint.configs.disableTypeChecked],
|
|
36
55
|
});
|
package/dist/profiles/node.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Profile, Step, StepContext } from "../gate/contract.ts";
|
|
2
2
|
export declare const PNPM_INSTALL = "pnpm-install";
|
|
3
3
|
export declare function typecheck(context: StepContext): string;
|
|
4
|
+
export declare function lint(context: StepContext, profile: Profile): string;
|
|
4
5
|
export declare function unitTests(context: StepContext): string;
|
|
5
6
|
export declare function nodeSteps(profile: Profile): Step[];
|
package/dist/profiles/node.js
CHANGED
|
@@ -5,6 +5,7 @@ const VITEST_CONFIG = /^vitest\.config\.(ts|mts|js|mjs)$/;
|
|
|
5
5
|
const UNIT_PROJECT = /\bname:\s*["'`]unit["'`]|\bunitTests\(/;
|
|
6
6
|
const NOT_A_SOURCE = /\.(test|stories|e2e|visual|spec)\.[cm]?[jt]sx?$|\.d\.ts$/;
|
|
7
7
|
const ENFORCED_RULES = ["suwgate/no-comments", "boundaries/dependencies"];
|
|
8
|
+
const TAILWIND_RULE = "better-tailwindcss/no-unknown-classes";
|
|
8
9
|
export const PNPM_INSTALL = "pnpm-install";
|
|
9
10
|
function install(context) {
|
|
10
11
|
return has(context, "node_modules") ? null : "pnpm install --frozen-lockfile --silent";
|
|
@@ -16,12 +17,19 @@ export function typecheck(context) {
|
|
|
16
17
|
.map((file) => `pnpm exec tsc --noEmit -p ${file} && pnpm exec tsc --showConfig -p ${file} | ${verdictCommand(`tsconfig ${quoted(file)}`)}`)
|
|
17
18
|
.join(" && ");
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function usesTailwind(context) {
|
|
21
|
+
const manifest = JSON.parse(read(context, "package.json") ?? "{}");
|
|
22
|
+
return ["dependencies", "devDependencies"].some((section) => manifest[section]?.["tailwindcss"] !== undefined);
|
|
23
|
+
}
|
|
24
|
+
function enforcedRules(context, profile) {
|
|
25
|
+
return profile === "web" && usesTailwind(context) ? [...ENFORCED_RULES, TAILWIND_RULE] : ENFORCED_RULES;
|
|
26
|
+
}
|
|
27
|
+
export function lint(context, profile) {
|
|
20
28
|
const source = tracked(context, ["src/*.ts", "src/*.tsx"]).find((file) => !NOT_A_SOURCE.test(file));
|
|
21
29
|
const rules = source === undefined
|
|
22
30
|
? []
|
|
23
31
|
: [
|
|
24
|
-
`pnpm exec eslint --print-config ${quoted(source)} | ${verdictCommand(`eslint ${quoted(source)} ${
|
|
32
|
+
`pnpm exec eslint --print-config ${quoted(source)} | ${verdictCommand(`eslint ${quoted(source)} ${enforcedRules(context, profile).join(" ")}`)}`,
|
|
25
33
|
];
|
|
26
34
|
return [...rules, "pnpm exec eslint . --max-warnings 0"].join(" && ");
|
|
27
35
|
}
|
|
@@ -53,11 +61,11 @@ export function nodeSteps(profile) {
|
|
|
53
61
|
},
|
|
54
62
|
{
|
|
55
63
|
id: "lint",
|
|
56
|
-
title: "lint (eslint; eslint --print-config of a source file keeps no-comments and
|
|
64
|
+
title: "lint (eslint; eslint --print-config of a source file keeps no-comments, boundaries and, in a web app with Tailwind, no-unknown-classes at error)",
|
|
57
65
|
profile,
|
|
58
66
|
needs: ["pnpm"],
|
|
59
67
|
after,
|
|
60
|
-
run: lint,
|
|
68
|
+
run: (context) => lint(context, profile),
|
|
61
69
|
quick: (context) => withChanged(context, CODE, "pnpm exec eslint --no-warn-ignored --max-warnings 0"),
|
|
62
70
|
limitSeconds: 300,
|
|
63
71
|
},
|
package/dist/profiles/verdict.js
CHANGED
|
@@ -64,7 +64,10 @@ export function eslintVerdict(file, printed, rules) {
|
|
|
64
64
|
const off = rules.filter((rule) => severity(rule) !== 2 && severity(rule) !== "error");
|
|
65
65
|
if (off.length === 0)
|
|
66
66
|
return null;
|
|
67
|
-
|
|
67
|
+
const tailwind = off.includes("better-tailwindcss/no-unknown-classes")
|
|
68
|
+
? "; the Tailwind check reads the theme from src/index.css, or from the CSS file that tailwindEntryPoint of strict() or app() names"
|
|
69
|
+
: "";
|
|
70
|
+
return `${file}: eslint --print-config shows ${off.map((rule) => `${rule} ${JSON.stringify(severity(rule) ?? "off")}`).join(", ")}; it must be an error for every source file: build eslint.config.js on strict() or app() of @maniumek/suwgate/eslint and delete what turns it off${tailwind}`;
|
|
68
71
|
}
|
|
69
72
|
const STRICT_PRESET = new URL("./presets/tsconfig/strict.json", import.meta.url);
|
|
70
73
|
function presetOptions() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maniumek/suwgate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "One quality gate for every repository: suwgate check runs the steps of the repository's profiles and its guards, configured in suwgate.yml",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Manomenu",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"ajv": "8.20.0",
|
|
51
|
+
"eslint-plugin-better-tailwindcss": "4.11.0",
|
|
51
52
|
"yaml": "2.9.1"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
@@ -85,6 +86,7 @@
|
|
|
85
86
|
"knip": "^6.46.1",
|
|
86
87
|
"prettier": "^3.10.1",
|
|
87
88
|
"publint": "0.3.25",
|
|
89
|
+
"tailwindcss": "^4.3.5",
|
|
88
90
|
"typescript": "6.0.3",
|
|
89
91
|
"typescript-eslint": "^8.73.0",
|
|
90
92
|
"vitest": "5.1.1"
|