@kirill.konshin/lint 0.7.4 → 0.8.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.
Files changed (56) hide show
  1. package/README.md +160 -113
  2. package/dist/config.d.ts +103 -0
  3. package/dist/config.js +112 -0
  4. package/dist/configs/base.d.ts +1 -1
  5. package/dist/configs/nx.d.ts +1 -1
  6. package/dist/configs/nx.js +3 -8
  7. package/dist/configs/react.d.ts +3 -3
  8. package/dist/configs/react.js +6 -16
  9. package/dist/configs/storybook.d.ts +3 -3
  10. package/dist/configs/storybook.js +4 -9
  11. package/dist/configs/tailwind.d.ts +6 -25
  12. package/dist/configs/tailwind.js +3 -64
  13. package/dist/configs/testing.d.ts +1 -1
  14. package/dist/configs/testing.js +3 -15
  15. package/dist/configs/turbo.d.ts +2 -2
  16. package/dist/configs/turbo.js +4 -6
  17. package/dist/configs/typescriptTypeAware.d.ts +1 -1
  18. package/dist/gates.d.ts +72 -0
  19. package/dist/gates.js +132 -0
  20. package/dist/index.d.ts +15 -51
  21. package/dist/index.js +16 -14
  22. package/dist/lib.d.ts +1 -1
  23. package/dist/lib.js +1 -1
  24. package/dist/lintPrepare.d.ts +75 -28
  25. package/dist/lintPrepare.js +243 -35
  26. package/dist/testColocation.js +1 -1
  27. package/dist/vitePlus.d.ts +8 -18
  28. package/dist/vitePlus.js +40 -47
  29. package/package.json +7 -4
  30. package/rules/agent.md +1 -0
  31. package/rules/db.md +1 -0
  32. package/rules/expo.md +2 -0
  33. package/rules/mui.md +3 -1
  34. package/rules/nextjs.md +3 -3
  35. package/rules/react.md +4 -28
  36. package/rules/tailwind.md +3 -2
  37. package/rules/typescript.md +1 -1
  38. package/rules/vite.md +1 -1
  39. package/skills/lint-db/SKILL.md +11 -9
  40. package/skills/lint-electron/SKILL.md +3 -1
  41. package/skills/lint-github/SKILL.md +10 -2
  42. package/skills/lint-gitlab/SKILL.md +17 -2
  43. package/skills/lint-migrate/SKILL.md +17 -1
  44. package/skills/lint-mui/SKILL.md +15 -18
  45. package/skills/lint-nextjs/SKILL.md +30 -18
  46. package/skills/lint-npm-yarn/SKILL.md +16 -30
  47. package/skills/lint-repo/SKILL.md +6 -6
  48. package/skills/lint-tailwind/SKILL.md +8 -8
  49. package/skills/lint-webstorm/SKILL.md +1 -1
  50. package/skills/lint-worktree/SKILL.md +25 -9
  51. package/skills/spec-steward/SKILL.md +1 -1
  52. package/skills/spec-steward/references/contract.md +1 -1
  53. package/skills/spec-steward/references/wiring.md +1 -1
  54. package/skills/spec-tools/SKILL.md +2 -2
  55. package/skills/spec-tools/scripts/cli.js +2 -2
  56. package/skills/spec-verify/SKILL.md +1 -1
package/dist/config.js ADDED
@@ -0,0 +1,112 @@
1
+ import { findWorkspaceRoot, scanWorkspace } from "./lib.js";
2
+ import { tsExts } from "./exts.js";
3
+ import { existsSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ //#region src/config.ts
7
+ const LINT_CONFIG_FILE = "lint.config.ts";
8
+ /** `{ name: true }` for each name. */
9
+ const only = (...names) => Object.fromEntries(names.map((name) => [name, true]));
10
+ /**
11
+ * The base every resolved config starts from. Every project gets every skill below; `lint.config.ts` turns off what it
12
+ * does not need (`'expo/skills': false`).
13
+ *
14
+ * Remote sources follow the Core Pack https://skills.sh/p/DxVN7q53wGdAcZQt (synced by hand, see the repository's
15
+ * `curated-skills-update` skill), plus the official skills of the libraries the rules cover. Each source lists its
16
+ * skills: the repositories also hold their maintainers' internal skills. `ref` pins a full commit SHA.
17
+ */
18
+ const DEFAULT_LINT_CONFIG = { skills: {
19
+ "@kirill.konshin/lint": true,
20
+ "vercel-labs/agent-skills": {
21
+ ref: "063bee94c3f4df8453406c830b0a7df0f2860278",
22
+ skills: only("vercel-react-best-practices", "vercel-composition-patterns", "vercel-react-native-skills", "vercel-react-view-transitions", "web-design-guidelines")
23
+ },
24
+ "vercel/ai": {
25
+ ref: "682e2dd71456f14f9da33a1b983d1998c3a1184c",
26
+ skills: only("ai-sdk")
27
+ },
28
+ "shadcn-ui/ui": {
29
+ ref: "481d523374745e77d0cf9c53a4115ab5dd7c8481",
30
+ skills: only("shadcn")
31
+ },
32
+ "heroui-inc/heroui": {
33
+ ref: "31a6261590798d3c46f9cd0adf507653b3bc29ad",
34
+ skills: only("heroui-react", "heroui-native")
35
+ },
36
+ "mui/material-ui": {
37
+ ref: "f63c84ad6f3f8bd1d6f822bc6ed4ec738ec124b7",
38
+ skills: only("material-ui-nextjs", "material-ui-styling", "material-ui-theming")
39
+ },
40
+ "neondatabase/agent-skills": {
41
+ ref: "ccca3334a7542d3133134cc6926f2fafc6edeb1f",
42
+ skills: only("neon", "neon-postgres", "neon-postgres-branches", "neon-auth")
43
+ },
44
+ "vercel/next.js": {
45
+ ref: "cbf49db30a655ac17c92c2951885c4256db14b9e",
46
+ skills: only("next-bundle-optimizer", "next-cache-components-adoption", "next-cache-components-optimizer", "next-dev-loop", "next-partial-prefetching-adoption", "next-partial-prefetching-optimizer")
47
+ },
48
+ "reduxjs/redux-toolkit": {
49
+ ref: "0fd611cc79d44990ac9a040dec4d5cb446233440",
50
+ skills: only("build-modern-redux-apps/modern-redux", "build-modern-redux-apps/redux-dataflow", "evolve-and-diagnose-redux-apps/debug-redux-toolkit-apps", "evolve-and-diagnose-redux-apps/migrate-to-modern-redux", "manage-server-data/adopt-rtk-query", "manage-server-data/generate-rtk-query-from-openapi", "model-redux-state/build-slices-and-selectors", "model-redux-state/design-state-ownership", "orchestrate-side-effects/handle-side-effects")
51
+ },
52
+ "vercel/turborepo": {
53
+ ref: "8003ff0fe919160f68367cd08465b179410e0692",
54
+ skills: only("turborepo")
55
+ },
56
+ "nrwl/nx-ai-agents-config": {
57
+ ref: "525ce266e22ec54e006d630d3b560658e8c3001c",
58
+ skills: only("link-workspace-packages", "monitor-ci", "nx-cloud-api", "nx-cloud-cache-investigator", "nx-cloud-ci-failure-review", "nx-generate", "nx-import", "nx-plugins", "nx-run-tasks", "nx-workspace")
59
+ },
60
+ "expo/skills": {
61
+ ref: "d5caf7fdf8b4854351f05841a7e315ac87ad7d24",
62
+ skills: only("eas-app-stores", "eas-hosting", "eas-observe", "eas-simulator", "eas-update", "eas-update-insights", "eas-workflows", "expo-animation", "expo-app-clip", "expo-brownfield", "expo-data-fetching", "expo-design-system", "expo-dev-client", "expo-dom", "expo-examples", "expo-migrate-module", "expo-module", "expo-native-ui", "expo-overview", "expo-project-structure", "expo-router", "expo-ui", "expo-upgrade", "expo-web-to-native")
63
+ },
64
+ "microsoft/playwright-cli": {
65
+ ref: "b1a5903c5b633b8c9f843ad7b629c2a78437040c",
66
+ skills: only("playwright-cli")
67
+ }
68
+ } };
69
+ /** Type-checks `lint.config.ts`; returns the config as it is. */
70
+ function defineLintConfig(config) {
71
+ return config;
72
+ }
73
+ const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
74
+ /**
75
+ * Deep merge, `override` wins. Objects merge key by key, arrays and other values are replaced. A boolean over an
76
+ * options object keeps the options and sets `enabled` (`false` over `{ ref }` is `{ ref, enabled: false }`); an options
77
+ * object over a boolean replaces it (options imply `enabled: true`).
78
+ */
79
+ function mergeLintConfig(base, override) {
80
+ if (override === void 0) return base;
81
+ if (typeof override === "boolean" && isPlainObject(base)) return {
82
+ ...base,
83
+ enabled: override
84
+ };
85
+ if (!isPlainObject(base) || !isPlainObject(override)) return override;
86
+ const merged = { ...base };
87
+ for (const [key, value] of Object.entries(override)) merged[key] = mergeLintConfig(merged[key], value);
88
+ return merged;
89
+ }
90
+ const loaded = /* @__PURE__ */ new Map();
91
+ /**
92
+ * The `lint.config.ts` of the workspace root, `{}` when there is none. Only the root is read: a monorepo has one config,
93
+ * packages differ through the arguments of the entry points. Node loads the file natively (type stripping), so it must
94
+ * use only erasable TypeScript syntax. Cached per root.
95
+ */
96
+ function loadLintConfig(root = findWorkspaceRoot()) {
97
+ const cached = loaded.get(root);
98
+ if (cached) return cached;
99
+ const config = importLintConfig(join(root, LINT_CONFIG_FILE));
100
+ loaded.set(root, config);
101
+ return config;
102
+ }
103
+ async function importLintConfig(file) {
104
+ if (!existsSync(file)) return {};
105
+ return (await import(pathToFileURL(file).href)).default ?? {};
106
+ }
107
+ /** {@link DEFAULT_LINT_CONFIG}, then the root `lint.config.ts`, then `overrides`, merged deep. */
108
+ async function resolveLintConfig(overrides = {}, root = findWorkspaceRoot()) {
109
+ return mergeLintConfig(mergeLintConfig(DEFAULT_LINT_CONFIG, await loadLintConfig(root)), overrides);
110
+ }
111
+ //#endregion
112
+ export { DEFAULT_LINT_CONFIG, LINT_CONFIG_FILE, defineLintConfig, loadLintConfig, mergeLintConfig, resolveLintConfig, scanWorkspace, tsExts };
@@ -1,4 +1,4 @@
1
- import { DefaultIgnoreOptions } from "../index.js";
1
+ import { DefaultIgnoreOptions } from "../config.js";
2
2
  import { Linter } from "eslint";
3
3
  //#region src/configs/base.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { ToggleOptions } from "../index.js";
1
+ import { ToggleOptions } from "../config.js";
2
2
  import { Linter } from "eslint";
3
3
  //#region src/configs/nx.d.ts
4
4
  export declare const nxPlugin: typeof import("@nx/eslint-plugin") | null;
@@ -1,6 +1,5 @@
1
- import { hasNx, toolGate } from "../lib.js";
2
- import { resolve } from "node:path";
3
- import { existsSync } from "node:fs";
1
+ import { hasNx } from "../lib.js";
2
+ import { nxGate } from "../gates.js";
4
3
  import * as jsoncParser from "jsonc-eslint-parser";
5
4
  //#region src/configs/nx.ts
6
5
  const nxPlugin = hasNx ? (await import("@nx/eslint-plugin")).default : null;
@@ -16,11 +15,7 @@ const nxPlugin = hasNx ? (await import("@nx/eslint-plugin")).default : null;
16
15
  *
17
16
  */
18
17
  async function nxConfig(option, strict = false) {
19
- const { enabled } = toolGate(option, strict, {
20
- tool: "nx",
21
- has: hasNx,
22
- strictHas: strict && existsSync(resolve(process.cwd(), "nx.json"))
23
- });
18
+ const { enabled } = nxGate(option, strict);
24
19
  if (!enabled) return [];
25
20
  return [...(await import("@nx/eslint-plugin")).default.configs["flat/base"], {
26
21
  name: "@nx/dependency-checks",
@@ -1,4 +1,4 @@
1
- import { NextOptions } from "../index.js";
1
+ import { NextOptions } from "../config.js";
2
2
  import { Linter } from "eslint";
3
3
  //#region src/configs/react.d.ts
4
4
  export declare const nextPlugin: typeof import("@next/eslint-plugin-next") | null;
@@ -28,12 +28,12 @@ export declare function nextBaseConfig({ rootDir }?: NextOptions): Promise<Linte
28
28
  export declare function reactBaseConfig(): Linter.Config[];
29
29
  /**
30
30
  * Composite: {@link nextBaseConfig} when Next is enabled, the {@link reactBaseConfig} fallback
31
- * otherwise. Full evidence-based gate (see `toolGate` in lib.js), mirroring Tailwind: app-root
31
+ * otherwise. Full evidence-based gate (see `nextGate` in gates.js), mirroring Tailwind: app-root
32
32
  * evidence (see {@link findNextRoots} - `next.config.*`, a `package.json` depending on `next`, a
33
33
  * `src/app`/`src/pages` tree) marks a Next repo even when the `next` package is installed only in
34
34
  * a leaf app (invisible to `hasNext`) - and because `eslint-config-next` `require`s files INSIDE
35
35
  * the `next` package, `next` must be resolvable from the workspace root (hoisted); a leaf-only
36
- * install is a hard error with hoisting guidance (see `toolGate` in lib.js).
36
+ * install is a hard error with hoisting guidance (see `nextGate` in gates.js).
37
37
  *
38
38
  */
39
39
  export declare function nextConfig(option?: boolean | NextOptions, strict?: boolean): Promise<Linter.Config[]>;
@@ -1,7 +1,7 @@
1
+ import { GLOBAL_IGNORES, findNextRoots, hasNext } from "../lib.js";
1
2
  import { tsExts } from "../exts.js";
2
- import { GLOBAL_IGNORES, findNextRoots, findWorkspaceRoot, hasNext, toolGate } from "../lib.js";
3
- import { dirname, isAbsolute, join, resolve } from "node:path";
4
- import { globSync } from "glob";
3
+ import { nextGate } from "../gates.js";
4
+ import { dirname } from "node:path";
5
5
  import nextTs from "eslint-config-next/typescript";
6
6
  import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
7
7
  import reactPlugin from "eslint-plugin-react";
@@ -46,26 +46,16 @@ function reactBaseConfig() {
46
46
  }
47
47
  /**
48
48
  * Composite: {@link nextBaseConfig} when Next is enabled, the {@link reactBaseConfig} fallback
49
- * otherwise. Full evidence-based gate (see `toolGate` in lib.js), mirroring Tailwind: app-root
49
+ * otherwise. Full evidence-based gate (see `nextGate` in gates.js), mirroring Tailwind: app-root
50
50
  * evidence (see {@link findNextRoots} - `next.config.*`, a `package.json` depending on `next`, a
51
51
  * `src/app`/`src/pages` tree) marks a Next repo even when the `next` package is installed only in
52
52
  * a leaf app (invisible to `hasNext`) - and because `eslint-config-next` `require`s files INSIDE
53
53
  * the `next` package, `next` must be resolvable from the workspace root (hoisted); a leaf-only
54
- * install is a hard error with hoisting guidance (see `toolGate` in lib.js).
54
+ * install is a hard error with hoisting guidance (see `nextGate` in gates.js).
55
55
  *
56
56
  */
57
57
  async function nextConfig(option, strict = false) {
58
- const { enabled, options, files } = toolGate(option, strict, {
59
- tool: "next",
60
- has: hasNext,
61
- packageName: "next",
62
- absolutizeOptions: ({ rootDir }) => (Array.isArray(rootDir) ? rootDir : [rootDir]).filter((dir) => Boolean(dir)).flatMap((dir) => {
63
- const pattern = isAbsolute(dir) ? dir : resolve(findWorkspaceRoot(), dir);
64
- const dirs = globSync(`${pattern.replace(/\\/g, "/").replace(/\/+$/, "")}/`, { absolute: true });
65
- return (dirs.length > 0 ? dirs : [pattern]).map((appDir) => join(appDir, "package.json"));
66
- }),
67
- scan: () => findNextRoots(GLOBAL_IGNORES).map((dir) => join(dir, "package.json"))
68
- });
58
+ const { enabled, options, files } = nextGate(option, strict);
69
59
  if (!enabled) return reactBaseConfig();
70
60
  return nextBaseConfig({
71
61
  ...options,
@@ -1,13 +1,13 @@
1
- import { ToggleOptions } from "../index.js";
1
+ import { ToggleOptions } from "../config.js";
2
2
  import { Linter } from "eslint";
3
3
  //#region src/configs/storybook.d.ts
4
4
  /**
5
- * Storybook recommended rules. Full evidence-based gate (see `toolGate` in lib.js), mirroring
5
+ * Storybook recommended rules. Full evidence-based gate (see `storybookGate` in gates.js), mirroring
6
6
  * Tailwind: a `.storybook/main.*` marks a Storybook repo even when the `storybook` package is
7
7
  * installed only in a leaf package (invisible to `hasStorybook`) - and because
8
8
  * `eslint-plugin-storybook` statically imports the `storybook` package itself, `storybook` must
9
9
  * be resolvable from the workspace root (hoisted); a leaf-only install is a hard error with
10
- * hoisting guidance (see `toolGate` in lib.js). The plugin stays lazily imported so consumers
10
+ * hoisting guidance (see `storybookGate` in gates.js). The plugin stays lazily imported so consumers
11
11
  * without Storybook never pay for it.
12
12
  *
13
13
  */
@@ -1,22 +1,17 @@
1
- import { GLOBAL_IGNORES, hasStorybook, scanWorkspace, toolGate } from "../lib.js";
1
+ import { storybookGate } from "../gates.js";
2
2
  //#region src/configs/storybook.ts
3
3
  /**
4
- * Storybook recommended rules. Full evidence-based gate (see `toolGate` in lib.js), mirroring
4
+ * Storybook recommended rules. Full evidence-based gate (see `storybookGate` in gates.js), mirroring
5
5
  * Tailwind: a `.storybook/main.*` marks a Storybook repo even when the `storybook` package is
6
6
  * installed only in a leaf package (invisible to `hasStorybook`) - and because
7
7
  * `eslint-plugin-storybook` statically imports the `storybook` package itself, `storybook` must
8
8
  * be resolvable from the workspace root (hoisted); a leaf-only install is a hard error with
9
- * hoisting guidance (see `toolGate` in lib.js). The plugin stays lazily imported so consumers
9
+ * hoisting guidance (see `storybookGate` in gates.js). The plugin stays lazily imported so consumers
10
10
  * without Storybook never pay for it.
11
11
  *
12
12
  */
13
13
  async function storybookConfig(option, strict = false) {
14
- const { enabled } = toolGate(option, strict, {
15
- tool: "storybook",
16
- has: hasStorybook,
17
- packageName: "storybook",
18
- scan: () => scanWorkspace(".storybook/main.*", GLOBAL_IGNORES, { dot: true })
19
- });
14
+ const { enabled } = storybookGate(option, strict);
20
15
  if (!enabled) return [];
21
16
  return (await import("eslint-plugin-storybook")).default.configs["flat/recommended"];
22
17
  }
@@ -1,40 +1,21 @@
1
- import { TailwindOptions } from "../index.js";
1
+ import { TailwindOptions } from "../config.js";
2
+ import { findTailwindEntry, tailwindGate } from "../gates.js";
2
3
  import { Linter } from "eslint";
3
4
  //#region src/configs/tailwind.d.ts
4
- /**
5
- * Auto-find THE Tailwind v4 entry CSS ({@link findTailwindEntries} narrowed to exactly one).
6
- *
7
- * eslint-plugin-tailwindcss v4 loads the entry (`settings.tailwindcss.cssConfigPath`) and
8
- * HARD-CRASHES with ENOENT when it can't, so {@link tailwindConfig} only enables the plugin when
9
- * exactly one entry is found (`allowMultiple: false` in its gate spec); with zero or several the
10
- * consumer must configure `cssConfigPath` manually (MANDATORY for the plugin; several candidates
11
- * are a hard error) - see README "Detection".
12
- *
13
- */
14
- export declare function findTailwindEntry(ignores: string[]): string | null;
15
5
  /**
16
6
  * Tailwind recommended rules (warnings + `no-contradicting-classname` as error) as a standalone
17
7
  * block (simple to override wholesale).
18
8
  *
19
- * Auto-detection is driven by the entry CSS (see {@link findTailwindEntries}), not by the package
9
+ * Auto-detection is driven by the entry CSS (see `findTailwindEntry` in gates.js), not by the package
20
10
  * probe: explicit `cssConfigPath` wins, otherwise auto-find. Zero entries stays inert in auto mode
21
11
  * (nothing marks the repo as Tailwind) but fails loudly when Tailwind was FORCED on (`true` /
22
12
  * options object). SEVERAL entries fail loudly even in auto mode: they prove the repo uses
23
13
  * Tailwind, the right one cannot be guessed, and a silent skip would be hard to detect - pass
24
14
  * `cssConfigPath` to pick one. `tailwindcss` must be resolvable from the workspace root (where
25
15
  * the plugin's theme-loading workers resolve it); a leaf-only install is a hard error with
26
- * hoisting guidance (see `toolGate` in lib.js).
16
+ * hoisting guidance (see `tailwindGate` in gates.js).
27
17
  *
28
18
  */
29
19
  export declare function tailwindConfig(option?: boolean | TailwindOptions, strict?: boolean): Promise<Linter.Config[]>;
30
- /**
31
- * The Tailwind activation decision shared by the ESLint block and the Vite+ config: `null` when off, otherwise the
32
- * entry CSS (in the consumer's own notation when given) and the absolute directory of the one package to scope the
33
- * rules to (`null` = the whole workspace).
34
- */
35
- export declare function tailwindGate(option?: boolean | TailwindOptions, strict?: boolean): {
36
- cssConfigPath: string;
37
- absoluteCssConfigPath: string;
38
- packageDir: string | null;
39
- } | null;
40
- //#endregion
20
+ //#endregion
21
+ export { findTailwindEntry, tailwindGate };
@@ -1,48 +1,17 @@
1
- import { GLOBAL_IGNORES, findWorkspaceRoot, hasTailwind, packageDirOf, scanWorkspace, toolGate } from "../lib.js";
2
- import { isAbsolute, resolve } from "node:path";
3
- import { readFileSync } from "node:fs";
1
+ import { findTailwindEntry, tailwindGate } from "../gates.js";
4
2
  //#region src/configs/tailwind.ts
5
3
  /**
6
- * All Tailwind v4 entry CSS candidates: every `*.css` across the workspace (see `scanWorkspace` -
7
- * the root plus every workspace package, `.gitignore`- and build-output-aware) containing the
8
- * Tailwind v4 marker `@import "tailwindcss"`.
9
- *
10
- */
11
- function findTailwindEntries(ignores) {
12
- return scanWorkspace("*.css", ignores).filter((file) => {
13
- try {
14
- return /@import\s+['"]tailwindcss['"]/.test(readFileSync(file, "utf-8"));
15
- } catch {
16
- return false;
17
- }
18
- });
19
- }
20
- /**
21
- * Auto-find THE Tailwind v4 entry CSS ({@link findTailwindEntries} narrowed to exactly one).
22
- *
23
- * eslint-plugin-tailwindcss v4 loads the entry (`settings.tailwindcss.cssConfigPath`) and
24
- * HARD-CRASHES with ENOENT when it can't, so {@link tailwindConfig} only enables the plugin when
25
- * exactly one entry is found (`allowMultiple: false` in its gate spec); with zero or several the
26
- * consumer must configure `cssConfigPath` manually (MANDATORY for the plugin; several candidates
27
- * are a hard error) - see README "Detection".
28
- *
29
- */
30
- function findTailwindEntry(ignores) {
31
- const entries = findTailwindEntries(ignores);
32
- return entries.length === 1 ? entries[0] : null;
33
- }
34
- /**
35
4
  * Tailwind recommended rules (warnings + `no-contradicting-classname` as error) as a standalone
36
5
  * block (simple to override wholesale).
37
6
  *
38
- * Auto-detection is driven by the entry CSS (see {@link findTailwindEntries}), not by the package
7
+ * Auto-detection is driven by the entry CSS (see `findTailwindEntry` in gates.js), not by the package
39
8
  * probe: explicit `cssConfigPath` wins, otherwise auto-find. Zero entries stays inert in auto mode
40
9
  * (nothing marks the repo as Tailwind) but fails loudly when Tailwind was FORCED on (`true` /
41
10
  * options object). SEVERAL entries fail loudly even in auto mode: they prove the repo uses
42
11
  * Tailwind, the right one cannot be guessed, and a silent skip would be hard to detect - pass
43
12
  * `cssConfigPath` to pick one. `tailwindcss` must be resolvable from the workspace root (where
44
13
  * the plugin's theme-loading workers resolve it); a leaf-only install is a hard error with
45
- * hoisting guidance (see `toolGate` in lib.js).
14
+ * hoisting guidance (see `tailwindGate` in gates.js).
46
15
  *
47
16
  */
48
17
  async function tailwindConfig(option, strict = false) {
@@ -56,35 +25,5 @@ async function tailwindConfig(option, strict = false) {
56
25
  settings: { tailwindcss: { cssConfigPath } }
57
26
  }];
58
27
  }
59
- /**
60
- * The Tailwind activation decision shared by the ESLint block and the Vite+ config: `null` when off, otherwise the
61
- * entry CSS (in the consumer's own notation when given) and the absolute directory of the one package to scope the
62
- * rules to (`null` = the whole workspace).
63
- */
64
- function tailwindGate(option, strict = false) {
65
- const { enabled, options, files } = toolGate(option, strict, {
66
- tool: "tailwind",
67
- has: hasTailwind,
68
- packageName: "tailwindcss",
69
- needs: {
70
- what: "entry CSS",
71
- detail: "single Tailwind v4 entry CSS (a *.css containing `@import \"tailwindcss\"`, scanned across the workspace root and every workspace package)",
72
- hint: "`tailwind: { cssConfigPath }`"
73
- },
74
- allowMultiple: false,
75
- absolutizeOptions: ({ cssConfigPath }) => cssConfigPath ? [isAbsolute(cssConfigPath) ? cssConfigPath : resolve(findWorkspaceRoot(), cssConfigPath)] : [],
76
- scan: () => findTailwindEntries(GLOBAL_IGNORES)
77
- });
78
- if (!enabled) return null;
79
- const cssConfigPath = options.cssConfigPath ?? files[0];
80
- const { scoped = true } = options;
81
- const owner = scoped ? packageDirOf(files[0]) : null;
82
- const packageDir = owner && owner !== findWorkspaceRoot() ? owner : null;
83
- return {
84
- cssConfigPath,
85
- absoluteCssConfigPath: files[0],
86
- packageDir
87
- };
88
- }
89
28
  //#endregion
90
29
  export { findTailwindEntry, tailwindConfig, tailwindGate };
@@ -1,4 +1,4 @@
1
- import { ToggleOptions } from "../index.js";
1
+ import { ToggleOptions } from "../config.js";
2
2
  import vitestPlugin from "@vitest/eslint-plugin";
3
3
  import jestPlugin from "eslint-plugin-jest";
4
4
  import { Linter } from "eslint";
@@ -1,5 +1,5 @@
1
1
  import { tsExts } from "../exts.js";
2
- import { GLOBAL_IGNORES, hasJest, hasVitest, scanWorkspace, toolGate } from "../lib.js";
2
+ import { jestGate, vitestGate } from "../gates.js";
3
3
  import { testColocation } from "../testColocation.js";
4
4
  import vitestPlugin from "@vitest/eslint-plugin";
5
5
  import jestPlugin from "eslint-plugin-jest";
@@ -9,13 +9,7 @@ import jestPlugin from "eslint-plugin-jest";
9
9
  *
10
10
  */
11
11
  function jestConfig(option, strict = false) {
12
- const { enabled } = toolGate(option, strict, {
13
- tool: "jest",
14
- has: hasJest,
15
- packageName: "jest",
16
- requirePackage: false,
17
- scan: () => scanWorkspace("jest.config.*", GLOBAL_IGNORES)
18
- });
12
+ const { enabled } = jestGate(option, strict);
19
13
  if (!enabled) return [];
20
14
  return [{
21
15
  ...jestPlugin.configs["flat/recommended"],
@@ -28,13 +22,7 @@ function jestConfig(option, strict = false) {
28
22
  *
29
23
  */
30
24
  function vitestConfig(option, strict = false) {
31
- const { enabled } = toolGate(option, strict, {
32
- tool: "vitest",
33
- has: hasVitest,
34
- packageName: "vitest",
35
- requirePackage: false,
36
- scan: () => scanWorkspace("{vitest,vite}.config.*", GLOBAL_IGNORES)
37
- });
25
+ const { enabled } = vitestGate(option, strict);
38
26
  if (!enabled) return [];
39
27
  return [{
40
28
  ...vitestPlugin.configs.recommended,
@@ -1,9 +1,9 @@
1
- import { ToggleOptions } from "../index.js";
1
+ import { ToggleOptions } from "../config.js";
2
2
  import { Linter } from "eslint";
3
3
  //#region src/configs/turbo.d.ts
4
4
  export declare const turboPlugin: typeof import("eslint-plugin-turbo") | null;
5
5
  /**
6
- * Turborepo rules. Probe-only gate (see `toolGate` in lib.js) - no evidence scan, no bridge.
6
+ * Turborepo rules. Probe-only gate (see `turboGate` in gates.js) - no evidence scan, no bridge.
7
7
  *
8
8
  */
9
9
  export declare function turboConfig(option?: boolean | ToggleOptions): Promise<Linter.Config[]>;
@@ -1,15 +1,13 @@
1
- import { hasTurbo, toolGate } from "../lib.js";
1
+ import { hasTurbo } from "../lib.js";
2
+ import { turboGate } from "../gates.js";
2
3
  //#region src/configs/turbo.ts
3
4
  const turboPlugin = hasTurbo ? (await import("eslint-plugin-turbo")).default : null;
4
5
  /**
5
- * Turborepo rules. Probe-only gate (see `toolGate` in lib.js) - no evidence scan, no bridge.
6
+ * Turborepo rules. Probe-only gate (see `turboGate` in gates.js) - no evidence scan, no bridge.
6
7
  *
7
8
  */
8
9
  async function turboConfig(option) {
9
- const { enabled } = toolGate(option, false, {
10
- tool: "turbo",
11
- has: hasTurbo
12
- });
10
+ const { enabled } = turboGate(option);
13
11
  if (!enabled) return [];
14
12
  const recommended = (await import("eslint-plugin-turbo")).default.configs?.["flat/recommended"];
15
13
  return [...Array.isArray(recommended) ? recommended : [recommended ?? {}], {
@@ -1,4 +1,4 @@
1
- import { TypeAwareOptions } from "../index.js";
1
+ import { TypeAwareOptions } from "../config.js";
2
2
  import { Linter } from "eslint";
3
3
  //#region src/configs/typescriptTypeAware.d.ts
4
4
  /**
@@ -0,0 +1,72 @@
1
+ import { NextOptions, TailwindOptions, ToggleOptions } from "./config.js";
2
+ //#region src/gates.d.ts
3
+ /**
4
+ * Next.js. `requirePackage`: `eslint-config-next` `require`s files inside the `next` package, so the ESLint config needs
5
+ * `next` resolvable from the workspace root; Oxlint's native `nextjs` plugin does not.
6
+ */
7
+ export declare function nextGate(option: boolean | NextOptions | undefined, strict: boolean, { requirePackage }?: {
8
+ requirePackage?: boolean | undefined;
9
+ }): {
10
+ enabled: boolean;
11
+ options: {
12
+ rootDir?: string | string[] | undefined;
13
+ };
14
+ files: string[];
15
+ };
16
+ /**
17
+ * Storybook: a `.storybook/main.*` marks a Storybook repo even when the package sits in a leaf package;
18
+ * `eslint-plugin-storybook` statically imports `storybook`, so it must be resolvable from the workspace root.
19
+ */
20
+ export declare function storybookGate(option: boolean | ToggleOptions | undefined, strict: boolean): {
21
+ enabled: boolean;
22
+ options: {};
23
+ files: string[];
24
+ };
25
+ /** Turborepo: probe only, never strict - no evidence scan. */
26
+ export declare function turboGate(option: boolean | ToggleOptions | undefined): {
27
+ enabled: boolean;
28
+ options: {};
29
+ files: string[];
30
+ };
31
+ /**
32
+ * Nx: `nx.json` at the workspace root (strict: at cwd). `packageName`: the package the integration needs resolvable -
33
+ * the Vite+ config runs `@nx/eslint-plugin` as a JS plugin, which needs `eslint`.
34
+ */
35
+ export declare function nxGate(option: boolean | ToggleOptions | undefined, strict: boolean, { packageName }?: {
36
+ packageName?: string | undefined;
37
+ }): {
38
+ enabled: boolean;
39
+ options: {};
40
+ files: string[];
41
+ };
42
+ export declare function jestGate(option: boolean | ToggleOptions | undefined, strict: boolean): {
43
+ enabled: boolean;
44
+ options: {};
45
+ files: string[];
46
+ };
47
+ export declare function vitestGate(option: boolean | ToggleOptions | undefined, strict: boolean): {
48
+ enabled: boolean;
49
+ options: {};
50
+ files: string[];
51
+ };
52
+ /**
53
+ * Auto-find THE Tailwind v4 entry CSS ({@link findTailwindEntries} narrowed to exactly one).
54
+ *
55
+ * eslint-plugin-tailwindcss v4 loads the entry (`settings.tailwindcss.cssConfigPath`) and
56
+ * HARD-CRASHES with ENOENT when it can't, so the plugin is only enabled when exactly one entry is
57
+ * found (`allowMultiple: false` in the {@link tailwindGate} spec); with zero or several the
58
+ * consumer must configure `cssConfigPath` manually (MANDATORY for the plugin; several candidates
59
+ * are a hard error) - see README "Detection".
60
+ *
61
+ */
62
+ export declare function findTailwindEntry(ignores: string[]): string | null;
63
+ /**
64
+ * Tailwind: `null` when off, otherwise the entry CSS (in the consumer's own notation when given) and the absolute
65
+ * directory of the one package to scope the rules to (`null` = the whole workspace).
66
+ */
67
+ export declare function tailwindGate(option?: boolean | TailwindOptions, strict?: boolean): {
68
+ cssConfigPath: string;
69
+ absoluteCssConfigPath: string;
70
+ packageDir: string | null;
71
+ } | null;
72
+ //#endregion