@kirill.konshin/lint 0.5.4 → 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.
- package/README.md +47 -7
- package/commands/spec-author.md +39 -0
- package/dist/configs/base.d.ts +4 -3
- package/dist/configs/base.js +61 -74
- package/dist/configs/imports.d.ts +3 -2
- package/dist/configs/imports.js +95 -146
- package/dist/configs/nx.d.ts +4 -3
- package/dist/configs/nx.js +31 -41
- package/dist/configs/prettier.d.ts +3 -2
- package/dist/configs/prettier.js +19 -16
- package/dist/configs/promise.d.ts +3 -2
- package/dist/configs/promise.js +16 -16
- package/dist/configs/react.d.ts +4 -3
- package/dist/configs/react.js +178 -217
- package/dist/configs/storybook.d.ts +4 -3
- package/dist/configs/storybook.js +22 -22
- package/dist/configs/tailwind.d.ts +4 -3
- package/dist/configs/tailwind.js +67 -91
- package/dist/configs/testing.d.ts +7 -6
- package/dist/configs/testing.js +112 -136
- package/dist/configs/turbo.d.ts +4 -3
- package/dist/configs/turbo.js +19 -27
- package/dist/configs/typescriptTypeAware.d.ts +4 -3
- package/dist/configs/typescriptTypeAware.js +99 -95
- package/dist/configs/unicorn.d.ts +3 -2
- package/dist/configs/unicorn.js +34 -41
- package/dist/exts.d.ts +2 -1
- package/dist/exts.js +10 -11
- package/dist/index.d.ts +44 -41
- package/dist/index.js +53 -84
- package/dist/lib.d.ts +21 -21
- package/dist/lib.js +261 -301
- package/dist/lintPrepare.d.ts +33 -28
- package/dist/lintPrepare.js +347 -376
- package/dist/lintStaged.d.ts +4 -3
- package/dist/lintStaged.js +25 -22
- package/dist/prettier.d.ts +4 -3
- package/dist/prettier.js +16 -17
- package/dist/restrictions.d.ts +24 -0
- package/dist/restrictions.js +20 -0
- package/dist/yarn.cjs +79 -98
- package/dist/yarn.d.cts +3 -2
- package/package.json +24 -8
- package/rules/agent.md +7 -4
- package/rules/openspec.md +1 -1
- package/skills/spec-steward/SKILL.md +4 -12
- package/skills/spec-steward/references/audit.md +18 -43
- package/skills/spec-steward/references/contract.md +7 -7
- package/skills/spec-steward/references/criteria.md +4 -4
- package/skills/spec-steward/references/model.md +1 -1
- package/skills/spec-steward/references/review-format.md +6 -6
- package/skills/spec-steward/references/wiring.md +4 -4
- package/skills/spec-steward/references/worker.md +67 -0
- package/skills/spec-steward/scripts/lib/align.mjs +7 -6
- package/skills/spec-steward/scripts/lib/checks.mjs +6 -1
- package/skills/spec-steward/scripts/lib/corpus.mjs +5 -8
- package/skills/spec-steward/scripts/lib/coverage.mjs +2 -3
- package/skills/spec-steward/scripts/lib/evidence.mjs +2 -148
- package/skills/spec-steward/scripts/lib/wire.mjs +6 -4
- package/skills/spec-steward/scripts/steward.mjs +30 -91
- package/skills/spec-steward/sweeps.json +49 -0
- package/skills/spec-tools/SKILL.md +46 -0
- package/skills/spec-tools/references/contract.md +111 -0
- package/skills/spec-tools/references/gitlab.md +122 -0
- package/skills/spec-verify/SKILL.md +153 -0
- package/spec-tools/dist/audit-DkZZulq6.mjs +130 -0
- package/spec-tools/dist/auditChanged-CNGjlake.mjs +1 -0
- package/spec-tools/dist/auditChanged-CZCvMgyZ.mjs +618 -0
- package/spec-tools/dist/auditReport-xgq4wK2i.mjs +458 -0
- package/spec-tools/dist/auditScope-CBuBtfPG.mjs +104 -0
- package/spec-tools/dist/changeGates-DdeQKfle.mjs +333 -0
- package/spec-tools/dist/changeGates-uy4Ti8rK.mjs +1 -0
- package/spec-tools/dist/ci-BUewHJS3.mjs +143 -0
- package/spec-tools/dist/ci-CFBzn8Of.mjs +1 -0
- package/spec-tools/dist/cli.mjs +93 -0
- package/spec-tools/dist/comment-szasMMg2.mjs +57 -0
- package/spec-tools/dist/files-Bppsb34B.mjs +1 -0
- package/spec-tools/dist/files-QlzY687_.mjs +38 -0
- package/spec-tools/dist/html-BMTkpbUN.mjs +1766 -0
- package/spec-tools/dist/jsonrepair-Dlm5dEen.mjs +742 -0
- package/spec-tools/dist/repo-CjIoUPYl.mjs +16 -0
- package/spec-tools/dist/repo-DUcnJw3c.mjs +1 -0
- package/spec-tools/dist/run-BElA9du3.mjs +67 -0
- package/spec-tools/dist/specDiff-8G56jMYn.mjs +123 -0
- package/spec-tools/dist/steward-DeieyOcj.mjs +34 -0
- package/spec-tools/dist/stewardAudit-BRMM0lrD.mjs +1 -0
- package/spec-tools/dist/stewardAudit-v0vOMfLN.mjs +271 -0
- package/spec-tools/dist/tier-Cn0P7juM.mjs +1 -0
- package/spec-tools/dist/tier-c3s_mA_I.mjs +65 -0
- package/spec-tools/dist/util-wnxhsnWO.mjs +49 -0
- package/spec-tools/dist/verdict-BFfN9PO8.mjs +58 -0
- package/spec-tools/dist/workers-BcIgckeq.mjs +417 -0
- package/spec-tools/dist/workflowEvidence-DyBj8EdG.mjs +1 -0
- package/spec-tools/dist/workflowEvidence-oui6ghPI.mjs +78 -0
- package/dist/configs/base.d.ts.map +0 -1
- package/dist/configs/imports.d.ts.map +0 -1
- package/dist/configs/nx.d.ts.map +0 -1
- package/dist/configs/prettier.d.ts.map +0 -1
- package/dist/configs/promise.d.ts.map +0 -1
- package/dist/configs/react.d.ts.map +0 -1
- package/dist/configs/storybook.d.ts.map +0 -1
- package/dist/configs/tailwind.d.ts.map +0 -1
- package/dist/configs/testing.d.ts.map +0 -1
- package/dist/configs/turbo.d.ts.map +0 -1
- package/dist/configs/typescriptTypeAware.d.ts.map +0 -1
- package/dist/configs/unicorn.d.ts.map +0 -1
- package/dist/exts.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lib.d.ts.map +0 -1
- package/dist/lintPrepare.d.ts.map +0 -1
- package/dist/lintStaged.d.ts.map +0 -1
- package/dist/prettier.d.ts.map +0 -1
- package/dist/yarn.d.cts.map +0 -1
- package/skills/spec-steward/workflows/audit.js +0 -539
package/dist/configs/nx.js
CHANGED
|
@@ -1,43 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolve } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const nxPlugin = hasNx ? (await import('@nx/eslint-plugin')).default : null;
|
|
1
|
+
import { hasNx, toolGate } from "../lib.js";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import * as jsoncParser from "jsonc-eslint-parser";
|
|
5
|
+
//#region src/configs/nx.ts
|
|
6
|
+
const nxPlugin = hasNx ? (await import("@nx/eslint-plugin")).default : null;
|
|
8
7
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
name: '@nx/dependency-checks',
|
|
33
|
-
files: ['**/package.json'],
|
|
34
|
-
languageOptions: {
|
|
35
|
-
parser: jsoncParser,
|
|
36
|
-
},
|
|
37
|
-
rules: {
|
|
38
|
-
// https://nx.dev/docs/technologies/eslint/eslint-plugin/guides/dependency-checks
|
|
39
|
-
'@nx/dependency-checks': 'error',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
];
|
|
8
|
+
* Nx blocks: plugin registration + `@nx/dependency-checks` on every `package.json`.
|
|
9
|
+
*
|
|
10
|
+
* Only `flat/base` (registers the '@nx' plugin, no rules of its own).
|
|
11
|
+
*
|
|
12
|
+
* `flat/typescript`/`flat/javascript` were deliberately NOT used - same call as with eslint-plugin-unicorn's
|
|
13
|
+
* recommended: they bundle the ENTIRE @stylistic plugin (hundreds of formatting rules - indent, quotes,
|
|
14
|
+
* semi, comma-dangle, ...) which would directly fight Prettier, plus a second full copy of
|
|
15
|
+
* @typescript-eslint/recommended that would relitigate rules already configured deliberately here.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
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
|
+
});
|
|
24
|
+
if (!enabled) return [];
|
|
25
|
+
return [...(await import("@nx/eslint-plugin")).default.configs["flat/base"], {
|
|
26
|
+
name: "@nx/dependency-checks",
|
|
27
|
+
files: ["**/package.json"],
|
|
28
|
+
languageOptions: { parser: jsoncParser },
|
|
29
|
+
rules: { "@nx/dependency-checks": "error" }
|
|
30
|
+
}];
|
|
43
31
|
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { nxConfig, nxPlugin };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Linter } from "eslint";
|
|
2
|
+
//#region src/configs/prettier.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* Prettier compatibility: turns off all rules that would fight the formatter.
|
|
4
5
|
*
|
|
@@ -14,4 +15,4 @@ import type { Linter } from 'eslint';
|
|
|
14
15
|
* exported object to improve https://eslint.org/blog/2024/04/eslint-config-inspector/ experience.
|
|
15
16
|
*/
|
|
16
17
|
export declare function prettierConfig(): Linter.Config[];
|
|
17
|
-
//#
|
|
18
|
+
//#endregion
|
package/dist/configs/prettier.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import prettierFlat from
|
|
1
|
+
import prettierFlat from "eslint-config-prettier/flat";
|
|
2
|
+
//#region src/configs/prettier.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
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
|
-
//#
|
|
7
|
+
//#endregion
|
package/dist/configs/promise.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import promisePlugin from
|
|
1
|
+
import promisePlugin from "eslint-plugin-promise";
|
|
2
|
+
//#region src/configs/promise.ts
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 };
|
package/dist/configs/react.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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
|
-
//#
|
|
85
|
+
//#endregion
|
package/dist/configs/react.js
CHANGED
|
@@ -1,236 +1,197 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
|
2
|
-
import
|
|
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
|
-
//#
|
|
15
|
+
//#endregion
|