@kirill.konshin/lint 0.5.5 → 0.6.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 (111) hide show
  1. package/README.md +38 -3
  2. package/commands/spec-author.md +39 -0
  3. package/dist/configs/base.d.ts +4 -3
  4. package/dist/configs/base.js +61 -74
  5. package/dist/configs/imports.d.ts +3 -2
  6. package/dist/configs/imports.js +95 -146
  7. package/dist/configs/nx.d.ts +4 -3
  8. package/dist/configs/nx.js +31 -41
  9. package/dist/configs/prettier.d.ts +3 -2
  10. package/dist/configs/prettier.js +19 -16
  11. package/dist/configs/promise.d.ts +3 -2
  12. package/dist/configs/promise.js +16 -16
  13. package/dist/configs/react.d.ts +4 -3
  14. package/dist/configs/react.js +178 -217
  15. package/dist/configs/storybook.d.ts +4 -3
  16. package/dist/configs/storybook.js +22 -22
  17. package/dist/configs/tailwind.d.ts +4 -3
  18. package/dist/configs/tailwind.js +67 -91
  19. package/dist/configs/testing.d.ts +7 -6
  20. package/dist/configs/testing.js +112 -146
  21. package/dist/configs/turbo.d.ts +4 -3
  22. package/dist/configs/turbo.js +19 -27
  23. package/dist/configs/typescriptTypeAware.d.ts +4 -3
  24. package/dist/configs/typescriptTypeAware.js +99 -95
  25. package/dist/configs/unicorn.d.ts +3 -2
  26. package/dist/configs/unicorn.js +34 -41
  27. package/dist/exts.d.ts +2 -1
  28. package/dist/exts.js +10 -11
  29. package/dist/index.d.ts +44 -42
  30. package/dist/index.js +53 -85
  31. package/dist/lib.d.ts +21 -21
  32. package/dist/lib.js +261 -301
  33. package/dist/lintPrepare.d.ts +20 -17
  34. package/dist/lintPrepare.js +341 -371
  35. package/dist/lintStaged.d.ts +4 -3
  36. package/dist/lintStaged.js +25 -22
  37. package/dist/prettier.d.ts +4 -3
  38. package/dist/prettier.js +16 -17
  39. package/dist/restrictions.d.ts +11 -10
  40. package/dist/restrictions.js +18 -22
  41. package/dist/yarn.cjs +79 -98
  42. package/dist/yarn.d.cts +3 -2
  43. package/package.json +24 -8
  44. package/rules/agent.md +2 -0
  45. package/rules/openspec.md +1 -1
  46. package/skills/spec-steward/SKILL.md +3 -11
  47. package/skills/spec-steward/references/audit.md +18 -43
  48. package/skills/spec-steward/references/contract.md +4 -4
  49. package/skills/spec-steward/references/criteria.md +4 -4
  50. package/skills/spec-steward/references/review-format.md +6 -6
  51. package/skills/spec-steward/references/wiring.md +2 -2
  52. package/skills/spec-steward/references/worker.md +67 -0
  53. package/skills/spec-steward/scripts/lib/corpus.mjs +1 -1
  54. package/skills/spec-steward/scripts/lib/evidence.mjs +2 -147
  55. package/skills/spec-steward/scripts/lib/wire.mjs +6 -4
  56. package/skills/spec-steward/scripts/steward.mjs +30 -91
  57. package/skills/spec-steward/sweeps.json +49 -0
  58. package/skills/spec-tools/SKILL.md +46 -0
  59. package/skills/spec-tools/references/contract.md +111 -0
  60. package/skills/spec-tools/references/gitlab.md +122 -0
  61. package/skills/spec-verify/SKILL.md +153 -0
  62. package/spec-tools/dist/audit-DkZZulq6.mjs +130 -0
  63. package/spec-tools/dist/auditChanged-CNGjlake.mjs +1 -0
  64. package/spec-tools/dist/auditChanged-CZCvMgyZ.mjs +618 -0
  65. package/spec-tools/dist/auditReport-xgq4wK2i.mjs +458 -0
  66. package/spec-tools/dist/auditScope-CBuBtfPG.mjs +104 -0
  67. package/spec-tools/dist/changeGates-DdeQKfle.mjs +333 -0
  68. package/spec-tools/dist/changeGates-uy4Ti8rK.mjs +1 -0
  69. package/spec-tools/dist/ci-BUewHJS3.mjs +143 -0
  70. package/spec-tools/dist/ci-CFBzn8Of.mjs +1 -0
  71. package/spec-tools/dist/cli.mjs +93 -0
  72. package/spec-tools/dist/comment-szasMMg2.mjs +57 -0
  73. package/spec-tools/dist/files-Bppsb34B.mjs +1 -0
  74. package/spec-tools/dist/files-QlzY687_.mjs +38 -0
  75. package/spec-tools/dist/html-BMTkpbUN.mjs +1766 -0
  76. package/spec-tools/dist/jsonrepair-Dlm5dEen.mjs +742 -0
  77. package/spec-tools/dist/repo-CjIoUPYl.mjs +16 -0
  78. package/spec-tools/dist/repo-DUcnJw3c.mjs +1 -0
  79. package/spec-tools/dist/run-BElA9du3.mjs +67 -0
  80. package/spec-tools/dist/specDiff-8G56jMYn.mjs +123 -0
  81. package/spec-tools/dist/steward-DeieyOcj.mjs +34 -0
  82. package/spec-tools/dist/stewardAudit-BRMM0lrD.mjs +1 -0
  83. package/spec-tools/dist/stewardAudit-v0vOMfLN.mjs +271 -0
  84. package/spec-tools/dist/tier-Cn0P7juM.mjs +1 -0
  85. package/spec-tools/dist/tier-c3s_mA_I.mjs +65 -0
  86. package/spec-tools/dist/util-wnxhsnWO.mjs +49 -0
  87. package/spec-tools/dist/verdict-BFfN9PO8.mjs +58 -0
  88. package/spec-tools/dist/workers-BcIgckeq.mjs +417 -0
  89. package/spec-tools/dist/workflowEvidence-DyBj8EdG.mjs +1 -0
  90. package/spec-tools/dist/workflowEvidence-oui6ghPI.mjs +78 -0
  91. package/dist/configs/base.d.ts.map +0 -1
  92. package/dist/configs/imports.d.ts.map +0 -1
  93. package/dist/configs/nx.d.ts.map +0 -1
  94. package/dist/configs/prettier.d.ts.map +0 -1
  95. package/dist/configs/promise.d.ts.map +0 -1
  96. package/dist/configs/react.d.ts.map +0 -1
  97. package/dist/configs/storybook.d.ts.map +0 -1
  98. package/dist/configs/tailwind.d.ts.map +0 -1
  99. package/dist/configs/testing.d.ts.map +0 -1
  100. package/dist/configs/turbo.d.ts.map +0 -1
  101. package/dist/configs/typescriptTypeAware.d.ts.map +0 -1
  102. package/dist/configs/unicorn.d.ts.map +0 -1
  103. package/dist/exts.d.ts.map +0 -1
  104. package/dist/index.d.ts.map +0 -1
  105. package/dist/lib.d.ts.map +0 -1
  106. package/dist/lintPrepare.d.ts.map +0 -1
  107. package/dist/lintStaged.d.ts.map +0 -1
  108. package/dist/prettier.d.ts.map +0 -1
  109. package/dist/restrictions.d.ts.map +0 -1
  110. package/dist/yarn.d.cts.map +0 -1
  111. package/skills/spec-steward/workflows/audit.js +0 -539
@@ -1,18 +1,21 @@
1
- import prettierFlat from 'eslint-config-prettier/flat';
1
+ import prettierFlat from "eslint-config-prettier/flat";
2
+ //#region src/configs/prettier.ts
2
3
  /**
3
- * Prettier compatibility: turns off all rules that would fight the formatter.
4
- *
5
- * @see https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#arrow-body-style-and-prefer-arrow-callback-issue
6
- * Plugin is not recommended by Prettier, they suggest to just use config, and disable all the rules, except for
7
- * these two in plugin last since they disable some previously set rules:
8
- * import prettierConfigRecommended from 'eslint-plugin-prettier/recommended';
9
- * 'arrow-body-style': 'off'
10
- * 'prefer-arrow-callback': 'off',
11
- *
12
- * @see https://nextjs.org/docs/app/api-reference/config/eslint#with-prettier
13
- * Note the `/flat` suffix here, the difference from default entry is that `/flat` added `name` property to the
14
- * exported object to improve https://eslint.org/blog/2024/04/eslint-config-inspector/ experience.
15
- */
16
- export function prettierConfig() {
17
- return [prettierFlat];
4
+ * Prettier compatibility: turns off all rules that would fight the formatter.
5
+ *
6
+ * @see https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#arrow-body-style-and-prefer-arrow-callback-issue
7
+ * Plugin is not recommended by Prettier, they suggest to just use config, and disable all the rules, except for
8
+ * these two in plugin last since they disable some previously set rules:
9
+ * import prettierConfigRecommended from 'eslint-plugin-prettier/recommended';
10
+ * 'arrow-body-style': 'off'
11
+ * 'prefer-arrow-callback': 'off',
12
+ *
13
+ * @see https://nextjs.org/docs/app/api-reference/config/eslint#with-prettier
14
+ * Note the `/flat` suffix here, the difference from default entry is that `/flat` added `name` property to the
15
+ * exported object to improve https://eslint.org/blog/2024/04/eslint-config-inspector/ experience.
16
+ */
17
+ function prettierConfig() {
18
+ return [prettierFlat];
18
19
  }
20
+ //#endregion
21
+ export { prettierConfig };
@@ -1,6 +1,7 @@
1
- import type { Linter } from 'eslint';
1
+ import { Linter } from "eslint";
2
+ //#region src/configs/promise.d.ts
2
3
  /**
3
4
  * Promise rules: recommended + overrides.
4
5
  */
5
6
  export declare function promiseConfig(): Linter.Config[];
6
- //# sourceMappingURL=promise.d.ts.map
7
+ //#endregion
@@ -1,18 +1,18 @@
1
- import promisePlugin from 'eslint-plugin-promise';
1
+ import promisePlugin from "eslint-plugin-promise";
2
+ //#region src/configs/promise.ts
2
3
  /**
3
- * Promise rules: recommended + overrides.
4
- */
5
- export function promiseConfig() {
6
- return [
7
- promisePlugin.configs['flat/recommended'],
8
- {
9
- name: 'eslint-plugin-promise overrides',
10
- rules: {
11
- 'promise/prefer-await-to-then': 'warn',
12
- 'promise/param-names': 'off',
13
- 'promise/always-return': 'off',
14
- 'promise/catch-or-return': 'off',
15
- },
16
- },
17
- ];
4
+ * Promise rules: recommended + overrides.
5
+ */
6
+ function promiseConfig() {
7
+ return [promisePlugin.configs["flat/recommended"], {
8
+ name: "eslint-plugin-promise overrides",
9
+ rules: {
10
+ "promise/prefer-await-to-then": "warn",
11
+ "promise/param-names": "off",
12
+ "promise/always-return": "off",
13
+ "promise/catch-or-return": "off"
14
+ }
15
+ }];
18
16
  }
17
+ //#endregion
18
+ export { promiseConfig };
@@ -1,5 +1,6 @@
1
- import type { Linter } from 'eslint';
2
- import type { NextOptions } from '../index.js';
1
+ import { NextOptions } from "../index.js";
2
+ import { Linter } from "eslint";
3
+ //#region src/configs/react.d.ts
3
4
  export declare const nextPlugin: typeof import("@next/eslint-plugin-next") | null;
4
5
  /**
5
6
  * Auto-find Next.js app roots below the workspace root (scanned like the Tailwind entry - see
@@ -81,4 +82,4 @@ export declare function reactSettingsConfig(): Linter.Config[];
81
82
  *
82
83
  */
83
84
  export declare function reactConfig(option?: boolean | NextOptions, strict?: boolean): Promise<Linter.Config[]>;
84
- //# sourceMappingURL=react.d.ts.map
85
+ //#endregion
@@ -1,236 +1,197 @@
1
- import { readFileSync } from 'node:fs';
2
- import { dirname, isAbsolute, join, resolve } from 'node:path';
3
- import nextTs from 'eslint-config-next/typescript';
4
- import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
5
- import reactPlugin from 'eslint-plugin-react';
6
- import reactHooksPlugin from 'eslint-plugin-react-hooks';
7
- import { globSync } from 'glob';
8
- import { tsExts } from '../exts.js';
9
- import { findWorkspaceRoot, GLOBAL_IGNORES, hasNext, scanWorkspace, toolGate } from '../lib.js';
10
- // lazy so consumers without Next don't pay the load cost - re-exported from index.js
11
- export const nextPlugin = hasNext ? (await import('@next/eslint-plugin-next')).default : null;
1
+ import { tsExts } from "../exts.js";
2
+ import { GLOBAL_IGNORES, findWorkspaceRoot, hasNext, scanWorkspace, toolGate } from "../lib.js";
3
+ import { dirname, isAbsolute, join, resolve } from "node:path";
4
+ import { readFileSync } from "node:fs";
5
+ import { globSync } from "glob";
6
+ import nextTs from "eslint-config-next/typescript";
7
+ import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
8
+ import reactPlugin from "eslint-plugin-react";
9
+ import reactHooksPlugin from "eslint-plugin-react-hooks";
10
+ //#region src/configs/react.ts
11
+ const nextPlugin = hasNext ? (await import("@next/eslint-plugin-next")).default : null;
12
12
  /**
13
- * Does this `package.json` declare `next` as a dependency? Peer/optional declarations are
14
- * deliberately ignored - they mark component libraries, not apps.
15
- */
13
+ * Does this `package.json` declare `next` as a dependency? Peer/optional declarations are
14
+ * deliberately ignored - they mark component libraries, not apps.
15
+ */
16
16
  function dependsOnNext(file) {
17
- try {
18
- const { dependencies, devDependencies } = JSON.parse(readFileSync(file, 'utf-8'));
19
- return Boolean(dependencies?.next ?? devDependencies?.next);
20
- }
21
- catch {
22
- return false; // unreadable / malformed - not evidence
23
- }
17
+ try {
18
+ const { dependencies, devDependencies } = JSON.parse(readFileSync(file, "utf-8"));
19
+ return Boolean(dependencies?.next ?? devDependencies?.next);
20
+ } catch {
21
+ return false;
22
+ }
24
23
  }
25
24
  /**
26
- * Auto-find Next.js app roots below the workspace root (scanned like the Tailwind entry - see
27
- * `scanWorkspace`). `next.config.*` is optional in Next.js, so any of three signals marks an app
28
- * root:
29
- * - a `next.config.*` file
30
- * - a `package.json` depending on `next` (see {@link dependsOnNext})
31
- * - a `src/app` or `src/pages` directory - the reported root is the directory CONTAINING `src`,
32
- * because the plugin resolves both layouts (`pages`/`app` and `src/pages`/`src/app`) from the
33
- * package root itself; the bare root-level dir names are too generic to scan for, but such apps
34
- * are caught by the other two signals
35
- *
36
- * Returns absolute directories, deduplicated (one app usually shows several signals) and sorted
37
- * so the emitted settings block is deterministic across filesystems.
38
- */
39
- export function findNextRoots(ignores) {
40
- return [
41
- ...new Set([
42
- ...scanWorkspace('next.config.*', ignores).map((file) => dirname(file)),
43
- ...scanWorkspace('package.json', ignores)
44
- .filter(dependsOnNext)
45
- .map((file) => dirname(file)),
46
- // the trailing slash makes glob match directories only
47
- ...scanWorkspace('src/{app,pages}/', ignores).map((dir) => dirname(dirname(dir))),
48
- ]),
49
- ].sort();
25
+ * Auto-find Next.js app roots below the workspace root (scanned like the Tailwind entry - see
26
+ * `scanWorkspace`). `next.config.*` is optional in Next.js, so any of three signals marks an app
27
+ * root:
28
+ * - a `next.config.*` file
29
+ * - a `package.json` depending on `next` (see {@link dependsOnNext})
30
+ * - a `src/app` or `src/pages` directory - the reported root is the directory CONTAINING `src`,
31
+ * because the plugin resolves both layouts (`pages`/`app` and `src/pages`/`src/app`) from the
32
+ * package root itself; the bare root-level dir names are too generic to scan for, but such apps
33
+ * are caught by the other two signals
34
+ *
35
+ * Returns absolute directories, deduplicated (one app usually shows several signals) and sorted
36
+ * so the emitted settings block is deterministic across filesystems.
37
+ */
38
+ function findNextRoots(ignores) {
39
+ return [.../* @__PURE__ */ new Set([
40
+ ...scanWorkspace("next.config.*", ignores).map((file) => dirname(file)),
41
+ ...scanWorkspace("package.json", ignores).filter(dependsOnNext).map((file) => dirname(file)),
42
+ ...scanWorkspace("src/{app,pages}/", ignores).map((dir) => dirname(dirname(dir)))
43
+ ])].sort();
50
44
  }
51
45
  /**
52
- * Next.js blocks: the whole `eslint-config-next` flat config, plus `settings.next.rootDir`.
53
- *
54
- * `rootDir` is auto-detected via {@link findNextRoots} when omitted: zero apps found → no settings
55
- * block (the setting is optional and the plugin works without it - NOT an error, unlike the
56
- * Tailwind entry); one or several → ALL of them (`settings.next.rootDir` accepts an array -
57
- * pointing at just one app would break linting of the others).
58
- *
59
- * `eslint-config-next`'s own parser module does `require('next/dist/compiled/babel/eslint-parser')` -
60
- * a file INSIDE the `next` package itself - so merely *importing* `eslint-config-next` crashes if
61
- * `next` isn't installed at all (verified empirically: it throws "Cannot find module
62
- * 'next/dist/compiled/babel/eslint-parser'" the instant the module loads). Hence the lazy import
63
- * here; when the block is forced on without `next` around, that error IS the failure mode.
64
- *
65
- */
66
- export async function nextBaseConfig({ rootDir = findNextRoots(GLOBAL_IGNORES) } = {}) {
67
- const next = (await import('eslint-config-next')).default;
68
- return [
69
- ...next,
70
- // eslint-config-next already registers the @next/next plugin, only the settings are needed
71
- ...(rootDir?.length ? [{ name: '@next/eslint-plugin-next settings', settings: { next: { rootDir } } }] : []),
72
- ];
46
+ * Next.js blocks: the whole `eslint-config-next` flat config, plus `settings.next.rootDir`.
47
+ *
48
+ * `rootDir` is auto-detected via {@link findNextRoots} when omitted: zero apps found → no settings
49
+ * block (the setting is optional and the plugin works without it - NOT an error, unlike the
50
+ * Tailwind entry); one or several → ALL of them (`settings.next.rootDir` accepts an array -
51
+ * pointing at just one app would break linting of the others).
52
+ *
53
+ * `eslint-config-next`'s own parser module does `require('next/dist/compiled/babel/eslint-parser')` -
54
+ * a file INSIDE the `next` package itself - so merely *importing* `eslint-config-next` crashes if
55
+ * `next` isn't installed at all (verified empirically: it throws "Cannot find module
56
+ * 'next/dist/compiled/babel/eslint-parser'" the instant the module loads). Hence the lazy import
57
+ * here; when the block is forced on without `next` around, that error IS the failure mode.
58
+ *
59
+ */
60
+ async function nextBaseConfig({ rootDir = findNextRoots(GLOBAL_IGNORES) } = {}) {
61
+ return [...(await import("eslint-config-next")).default, ...rootDir?.length ? [{
62
+ name: "@next/eslint-plugin-next settings",
63
+ settings: { next: { rootDir } }
64
+ }] : []];
73
65
  }
74
66
  /**
75
- * Non-Next React projects - this config is also used for Vite+React apps - still want React/React
76
- * Hooks/jsx-a11y linting, which `eslint-config-next` normally provides but only via the Next-specific
77
- * parser. Cover the same ground directly instead, with whatever parser is already active
78
- * (typescript-eslint for .ts/.tsx via typescriptConfig, the default parser otherwise).
79
- *
80
- */
81
- export function reactBaseConfig() {
82
- return [
83
- reactPlugin.configs.flat.recommended,
84
- reactPlugin.configs.flat['jsx-runtime'],
85
- reactHooksPlugin.configs.flat['recommended-latest'],
86
- jsxA11yPlugin.flatConfigs.recommended,
87
- ];
67
+ * Non-Next React projects - this config is also used for Vite+React apps - still want React/React
68
+ * Hooks/jsx-a11y linting, which `eslint-config-next` normally provides but only via the Next-specific
69
+ * parser. Cover the same ground directly instead, with whatever parser is already active
70
+ * (typescript-eslint for .ts/.tsx via typescriptConfig, the default parser otherwise).
71
+ *
72
+ */
73
+ function reactBaseConfig() {
74
+ return [
75
+ reactPlugin.configs.flat.recommended,
76
+ reactPlugin.configs.flat["jsx-runtime"],
77
+ reactHooksPlugin.configs.flat["recommended-latest"],
78
+ jsxA11yPlugin.flatConfigs.recommended
79
+ ];
88
80
  }
89
81
  /**
90
- * Composite: {@link nextBaseConfig} when Next is enabled, the {@link reactBaseConfig} fallback
91
- * otherwise. Full evidence-based gate (see `toolGate` in lib.js), mirroring Tailwind: app-root
92
- * evidence (see {@link findNextRoots} - `next.config.*`, a `package.json` depending on `next`, a
93
- * `src/app`/`src/pages` tree) marks a Next repo even when the `next` package is installed only in
94
- * a leaf app (invisible to `hasNext`) - and because `eslint-config-next` `require`s files INSIDE
95
- * the `next` package, `next` must be resolvable from the workspace root (hoisted); a leaf-only
96
- * install is a hard error with hoisting guidance (see `toolGate` in lib.js).
97
- *
98
- */
99
- export async function nextConfig(option, strict = false) {
100
- const { enabled, options, files } = toolGate(option, strict, {
101
- tool: 'next',
102
- has: hasNext,
103
- packageName: 'next',
104
- /*
105
- * rootDir entries may be relative or absolute paths OR globs (`apps/*` - the plugin
106
- * expands them itself for its settings), so for the evidence probes each entry is
107
- * expanded against the workspace root into real app dirs; a plain path that exists simply
108
- * matches itself. An entry matching nothing falls back to the literal path as the probe
109
- * anchor (harmless - resolution just walks up from there). The probes resolve from each
110
- * app's package.json.
111
- */
112
- absolutizeOptions: ({ rootDir }) => (Array.isArray(rootDir) ? rootDir : [rootDir])
113
- .filter((dir) => Boolean(dir))
114
- .flatMap((dir) => {
115
- const pattern = isAbsolute(dir) ? dir : resolve(findWorkspaceRoot(), dir);
116
- // trailing slash = directories only; backslash normalization mirrors the plugin
117
- const dirs = globSync(`${pattern.replace(/\\/g, '/').replace(/\/+$/, '')}/`, { absolute: true });
118
- return (dirs.length > 0 ? dirs : [pattern]).map((appDir) => join(appDir, 'package.json'));
119
- }),
120
- scan: () => findNextRoots(GLOBAL_IGNORES).map((dir) => join(dir, 'package.json')),
121
- });
122
- if (!enabled)
123
- return reactBaseConfig();
124
- // explicit rootDir is passed through in the consumer's own notation; auto-detected roots are
125
- // the evidence dirs (absolute; empty under strict → no settings block, the setting is optional)
126
- return nextBaseConfig({ ...options, rootDir: options.rootDir ?? files.map((file) => dirname(file)) });
82
+ * Composite: {@link nextBaseConfig} when Next is enabled, the {@link reactBaseConfig} fallback
83
+ * otherwise. Full evidence-based gate (see `toolGate` in lib.js), mirroring Tailwind: app-root
84
+ * evidence (see {@link findNextRoots} - `next.config.*`, a `package.json` depending on `next`, a
85
+ * `src/app`/`src/pages` tree) marks a Next repo even when the `next` package is installed only in
86
+ * a leaf app (invisible to `hasNext`) - and because `eslint-config-next` `require`s files INSIDE
87
+ * the `next` package, `next` must be resolvable from the workspace root (hoisted); a leaf-only
88
+ * install is a hard error with hoisting guidance (see `toolGate` in lib.js).
89
+ *
90
+ */
91
+ async function nextConfig(option, strict = false) {
92
+ const { enabled, options, files } = toolGate(option, strict, {
93
+ tool: "next",
94
+ has: hasNext,
95
+ packageName: "next",
96
+ absolutizeOptions: ({ rootDir }) => (Array.isArray(rootDir) ? rootDir : [rootDir]).filter((dir) => Boolean(dir)).flatMap((dir) => {
97
+ const pattern = isAbsolute(dir) ? dir : resolve(findWorkspaceRoot(), dir);
98
+ const dirs = globSync(`${pattern.replace(/\\/g, "/").replace(/\/+$/, "")}/`, { absolute: true });
99
+ return (dirs.length > 0 ? dirs : [pattern]).map((appDir) => join(appDir, "package.json"));
100
+ }),
101
+ scan: () => findNextRoots(GLOBAL_IGNORES).map((dir) => join(dir, "package.json"))
102
+ });
103
+ if (!enabled) return reactBaseConfig();
104
+ return nextBaseConfig({
105
+ ...options,
106
+ rootDir: options.rootDir ?? files.map((file) => dirname(file))
107
+ });
127
108
  }
128
109
  /**
129
- * TypeScript blocks - lives here because the wiring stems from `eslint-config-next/typescript`
130
- * (typescript-eslint recommended setup, useful with or without Next itself) + deliberate overrides
131
- * of its rule set.
132
- *
133
- */
134
- export function typescriptOverridesConfig() {
135
- return [
136
- ...nextTs,
137
- {
138
- name: '@typescript-eslint overrides',
139
- files: [`**/*.${tsExts}`],
140
- rules: {
141
- '@typescript-eslint/explicit-module-boundary-types': 'off',
142
- '@typescript-eslint/no-empty-function': 'off',
143
- '@typescript-eslint/no-explicit-any': 'off',
144
- '@typescript-eslint/no-require-imports': 'off',
145
- '@typescript-eslint/no-unused-vars': 'off', // superseded by 'unused-imports/no-unused-imports', which is actually autofixable
146
- '@typescript-eslint/consistent-type-definitions': ['error', 'type'],
147
- '@typescript-eslint/consistent-type-imports': [
148
- 'error',
149
- { prefer: 'type-imports', fixStyle: 'inline-type-imports' },
150
- ],
151
- '@typescript-eslint/ban-ts-comment': [
152
- 'error',
153
- {
154
- 'ts-expect-error': 'allow-with-description',
155
- 'ts-ignore': true,
156
- 'ts-nocheck': true,
157
- 'ts-check': false,
158
- minimumDescriptionLength: 3,
159
- },
160
- ],
161
- /*
162
- * `as const` is the mechanical half of "Prefer `as const` and `readonly` for immutable
163
- * constants and objects" - the `readonly` half is a per-case judgment call (which objects
164
- * deserve it), so that guidance stays in typescript.md instead of being lint-enforced here.
165
- */
166
- '@typescript-eslint/prefer-as-const': 'error',
167
- },
168
- },
169
- {
170
- name: '@typescript-eslint declaration-file overrides',
171
- files: ['**/*.d.ts'],
172
- rules: {
173
- /*
174
- * `typeof import('pkg')` annotations are the standard mechanism in declaration files
175
- * (tsc itself emits them when generating .d.ts) - the annotation ban of
176
- * consistent-type-imports is meant for source files.
177
- */
178
- '@typescript-eslint/consistent-type-imports': [
179
- 'error',
180
- { prefer: 'type-imports', fixStyle: 'inline-type-imports', disallowTypeAnnotations: false },
181
- ],
182
- },
183
- },
184
- ];
110
+ * TypeScript blocks - lives here because the wiring stems from `eslint-config-next/typescript`
111
+ * (typescript-eslint recommended setup, useful with or without Next itself) + deliberate overrides
112
+ * of its rule set.
113
+ *
114
+ */
115
+ function typescriptOverridesConfig() {
116
+ return [
117
+ ...nextTs,
118
+ {
119
+ name: "@typescript-eslint overrides",
120
+ files: [`**/*.${tsExts}`],
121
+ rules: {
122
+ "@typescript-eslint/explicit-module-boundary-types": "off",
123
+ "@typescript-eslint/no-empty-function": "off",
124
+ "@typescript-eslint/no-explicit-any": "off",
125
+ "@typescript-eslint/no-require-imports": "off",
126
+ "@typescript-eslint/no-unused-vars": "off",
127
+ "@typescript-eslint/consistent-type-definitions": ["error", "type"],
128
+ "@typescript-eslint/consistent-type-imports": ["error", {
129
+ prefer: "type-imports",
130
+ fixStyle: "inline-type-imports"
131
+ }],
132
+ "@typescript-eslint/ban-ts-comment": ["error", {
133
+ "ts-expect-error": "allow-with-description",
134
+ "ts-ignore": true,
135
+ "ts-nocheck": true,
136
+ "ts-check": false,
137
+ minimumDescriptionLength: 3
138
+ }],
139
+ "@typescript-eslint/prefer-as-const": "error"
140
+ }
141
+ },
142
+ {
143
+ name: "@typescript-eslint declaration-file overrides",
144
+ files: ["**/*.d.ts"],
145
+ rules: { "@typescript-eslint/consistent-type-imports": ["error", {
146
+ prefer: "type-imports",
147
+ fixStyle: "inline-type-imports",
148
+ disallowTypeAnnotations: false
149
+ }] }
150
+ }
151
+ ];
185
152
  }
186
153
  /**
187
- * Overrides of rules set by `eslint-config-next`. Always applied (not gated on Next): the
188
- * jsx-a11y/react entries matter for {@link reactBaseConfig} consumers too, and turning off rules of an
189
- * unregistered plugin is harmless.
190
- *
191
- */
192
- export function nextOverridesConfig() {
193
- return [
194
- {
195
- name: 'eslint-config-next overrides',
196
- rules: {
197
- '@next/next/no-html-link-for-pages': 'off',
198
- '@next/next/no-img-element': 'off',
199
- 'import/no-anonymous-default-export': 'off', // overrides eslint-config-next's own default
200
- 'jsx-a11y/alt-text': 'off',
201
- 'react/prop-types': 'off', // ts does it statically
202
- },
203
- },
204
- ];
154
+ * Overrides of rules set by `eslint-config-next`. Always applied (not gated on Next): the
155
+ * jsx-a11y/react entries matter for {@link reactBaseConfig} consumers too, and turning off rules of an
156
+ * unregistered plugin is harmless.
157
+ *
158
+ */
159
+ function nextOverridesConfig() {
160
+ return [{
161
+ name: "eslint-config-next overrides",
162
+ rules: {
163
+ "@next/next/no-html-link-for-pages": "off",
164
+ "@next/next/no-img-element": "off",
165
+ "import/no-anonymous-default-export": "off",
166
+ "jsx-a11y/alt-text": "off",
167
+ "react/prop-types": "off"
168
+ }
169
+ }];
205
170
  }
206
171
  /**
207
- * FIXME ESLint 10 + Next fix
208
- * https://github.com/vercel/next.js/issues/89764
209
- * https://gist.github.com/OscarGauss/1f305edf5b7c103bb2ee32ba479f4261
210
- *
211
- */
212
- export function reactSettingsConfig() {
213
- return [
214
- {
215
- settings: {
216
- react: { version: '19' },
217
- },
218
- },
219
- ];
172
+ * FIXME ESLint 10 + Next fix
173
+ * https://github.com/vercel/next.js/issues/89764
174
+ * https://gist.github.com/OscarGauss/1f305edf5b7c103bb2ee32ba479f4261
175
+ *
176
+ */
177
+ function reactSettingsConfig() {
178
+ return [{ settings: { react: { version: "19" } } }];
220
179
  }
221
180
  /**
222
- * The whole React family in its load-bearing order: {@link nextConfig} (Next when enabled, plain
223
- * React otherwise - Next is just a shortcut to an opinionated React/TypeScript setup), then
224
- * {@link typescriptOverridesConfig}, {@link nextOverridesConfig} and {@link reactSettingsConfig} -
225
- * which apply NO MATTER whether Next or plain React won, so composing them individually risks
226
- * ordering mistakes; defineLintConfig uses this composite.
227
- *
228
- */
229
- export async function reactConfig(option, strict = false) {
230
- return [
231
- ...(await nextConfig(option, strict)),
232
- ...typescriptOverridesConfig(),
233
- ...nextOverridesConfig(),
234
- ...reactSettingsConfig(),
235
- ];
181
+ * The whole React family in its load-bearing order: {@link nextConfig} (Next when enabled, plain
182
+ * React otherwise - Next is just a shortcut to an opinionated React/TypeScript setup), then
183
+ * {@link typescriptOverridesConfig}, {@link nextOverridesConfig} and {@link reactSettingsConfig} -
184
+ * which apply NO MATTER whether Next or plain React won, so composing them individually risks
185
+ * ordering mistakes; defineLintConfig uses this composite.
186
+ *
187
+ */
188
+ async function reactConfig(option, strict = false) {
189
+ return [
190
+ ...await nextConfig(option, strict),
191
+ ...typescriptOverridesConfig(),
192
+ ...nextOverridesConfig(),
193
+ ...reactSettingsConfig()
194
+ ];
236
195
  }
196
+ //#endregion
197
+ export { findNextRoots, nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, reactBaseConfig, reactConfig, reactSettingsConfig, typescriptOverridesConfig };
@@ -1,5 +1,6 @@
1
- import type { Linter } from 'eslint';
2
- import type { ToggleOptions } from '../index.js';
1
+ import { ToggleOptions } from "../index.js";
2
+ import { Linter } from "eslint";
3
+ //#region src/configs/storybook.d.ts
3
4
  /**
4
5
  * Storybook recommended rules. Full evidence-based gate (see `toolGate` in lib.js), mirroring
5
6
  * Tailwind: a `.storybook/main.*` marks a Storybook repo even when the `storybook` package is
@@ -11,4 +12,4 @@ import type { ToggleOptions } from '../index.js';
11
12
  *
12
13
  */
13
14
  export declare function storybookConfig(option?: boolean | ToggleOptions, strict?: boolean): Promise<Linter.Config[]>;
14
- //# sourceMappingURL=storybook.d.ts.map
15
+ //#endregion
@@ -1,24 +1,24 @@
1
- import { GLOBAL_IGNORES, hasStorybook, scanWorkspace, toolGate } from '../lib.js';
1
+ import { GLOBAL_IGNORES, hasStorybook, scanWorkspace, toolGate } from "../lib.js";
2
+ //#region src/configs/storybook.ts
2
3
  /**
3
- * Storybook recommended rules. Full evidence-based gate (see `toolGate` in lib.js), mirroring
4
- * Tailwind: a `.storybook/main.*` marks a Storybook repo even when the `storybook` package is
5
- * installed only in a leaf package (invisible to `hasStorybook`) - and because
6
- * `eslint-plugin-storybook` statically imports the `storybook` package itself, `storybook` must
7
- * be resolvable from the workspace root (hoisted); a leaf-only install is a hard error with
8
- * hoisting guidance (see `toolGate` in lib.js). The plugin stays lazily imported so consumers
9
- * without Storybook never pay for it.
10
- *
11
- */
12
- export async function storybookConfig(option, strict = false) {
13
- const { enabled } = toolGate(option, strict, {
14
- tool: 'storybook',
15
- has: hasStorybook,
16
- packageName: 'storybook',
17
- scan: () => scanWorkspace('.storybook/main.*', GLOBAL_IGNORES, { dot: true }),
18
- });
19
- if (!enabled)
20
- return [];
21
- const storybookPlugin = (await import('eslint-plugin-storybook')).default;
22
- // Storybook still publishes ESLint 9 rule types; the runtime flat configs are valid in ESLint 10.
23
- return storybookPlugin.configs['flat/recommended'];
4
+ * Storybook recommended rules. Full evidence-based gate (see `toolGate` in lib.js), mirroring
5
+ * Tailwind: a `.storybook/main.*` marks a Storybook repo even when the `storybook` package is
6
+ * installed only in a leaf package (invisible to `hasStorybook`) - and because
7
+ * `eslint-plugin-storybook` statically imports the `storybook` package itself, `storybook` must
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
10
+ * without Storybook never pay for it.
11
+ *
12
+ */
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
+ });
20
+ if (!enabled) return [];
21
+ return (await import("eslint-plugin-storybook")).default.configs["flat/recommended"];
24
22
  }
23
+ //#endregion
24
+ export { storybookConfig };
@@ -1,5 +1,6 @@
1
- import type { Linter } from 'eslint';
2
- import type { TailwindOptions } from '../index.js';
1
+ import { TailwindOptions } from "../index.js";
2
+ import { Linter } from "eslint";
3
+ //#region src/configs/tailwind.d.ts
3
4
  /**
4
5
  * Auto-find THE Tailwind v4 entry CSS ({@link findTailwindEntries} narrowed to exactly one).
5
6
  *
@@ -26,4 +27,4 @@ export declare function findTailwindEntry(ignores: string[]): string | null;
26
27
  *
27
28
  */
28
29
  export declare function tailwindConfig(option?: boolean | TailwindOptions, strict?: boolean): Promise<Linter.Config[]>;
29
- //# sourceMappingURL=tailwind.d.ts.map
30
+ //#endregion