@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.
- package/README.md +38 -3
- 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 -146
- 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 -42
- package/dist/index.js +53 -85
- package/dist/lib.d.ts +21 -21
- package/dist/lib.js +261 -301
- package/dist/lintPrepare.d.ts +20 -17
- package/dist/lintPrepare.js +341 -371
- 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 +11 -10
- package/dist/restrictions.js +18 -22
- package/dist/yarn.cjs +79 -98
- package/dist/yarn.d.cts +3 -2
- package/package.json +24 -8
- package/rules/agent.md +2 -0
- package/rules/openspec.md +1 -1
- package/skills/spec-steward/SKILL.md +3 -11
- package/skills/spec-steward/references/audit.md +18 -43
- package/skills/spec-steward/references/contract.md +4 -4
- package/skills/spec-steward/references/criteria.md +4 -4
- package/skills/spec-steward/references/review-format.md +6 -6
- package/skills/spec-steward/references/wiring.md +2 -2
- package/skills/spec-steward/references/worker.md +67 -0
- package/skills/spec-steward/scripts/lib/corpus.mjs +1 -1
- package/skills/spec-steward/scripts/lib/evidence.mjs +2 -147
- 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/restrictions.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/tailwind.js
CHANGED
|
@@ -1,98 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isAbsolute, resolve } from
|
|
3
|
-
import {
|
|
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";
|
|
4
|
+
//#region src/configs/tailwind.ts
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
*/
|
|
10
11
|
function findTailwindEntries(ignores) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
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
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
if (!enabled)
|
|
74
|
-
return [];
|
|
75
|
-
// an explicit path is passed through in the consumer's own notation (the absolutized copy only
|
|
76
|
-
// served the probes); an auto-found entry is the absolute evidence file
|
|
77
|
-
const cssConfigPath = options.cssConfigPath ?? files[0];
|
|
78
|
-
/*
|
|
79
|
-
* The entry CSS pins down the ONE package that uses Tailwind, so by default the block is
|
|
80
|
-
* scoped to it via `basePath` (ESLint >= 9.30, absolute paths supported) instead of flagging
|
|
81
|
-
* class-like strings across the whole workspace. `files[0]` is the absolutized evidence path
|
|
82
|
-
* even when `cssConfigPath` was supplied relative. Owning package == workspace root (single-
|
|
83
|
-
* package repo, or the entry is not inside a declared workspace package) makes scoping a
|
|
84
|
-
* no-op - the block stays untouched.
|
|
85
|
-
*/
|
|
86
|
-
const { scoped = true } = options;
|
|
87
|
-
const packageDir = scoped ? packageDirOf(files[0]) : null;
|
|
88
|
-
const basePath = packageDir && packageDir !== findWorkspaceRoot() ? { basePath: packageDir } : {};
|
|
89
|
-
const tailwindPlugin = (await import('eslint-plugin-tailwindcss')).default;
|
|
90
|
-
return [
|
|
91
|
-
{
|
|
92
|
-
// The plugin still publishes @typescript-eslint's ESLint 9 config types.
|
|
93
|
-
...tailwindPlugin.configs.recommended,
|
|
94
|
-
...basePath,
|
|
95
|
-
settings: { tailwindcss: { cssConfigPath } },
|
|
96
|
-
},
|
|
97
|
-
];
|
|
35
|
+
* Tailwind recommended rules (warnings + `no-contradicting-classname` as error) as a standalone
|
|
36
|
+
* block (simple to override wholesale).
|
|
37
|
+
*
|
|
38
|
+
* Auto-detection is driven by the entry CSS (see {@link findTailwindEntries}), not by the package
|
|
39
|
+
* probe: explicit `cssConfigPath` wins, otherwise auto-find. Zero entries stays inert in auto mode
|
|
40
|
+
* (nothing marks the repo as Tailwind) but fails loudly when Tailwind was FORCED on (`true` /
|
|
41
|
+
* options object). SEVERAL entries fail loudly even in auto mode: they prove the repo uses
|
|
42
|
+
* Tailwind, the right one cannot be guessed, and a silent skip would be hard to detect - pass
|
|
43
|
+
* `cssConfigPath` to pick one. `tailwindcss` must be resolvable from the workspace root (where
|
|
44
|
+
* 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).
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
async function tailwindConfig(option, strict = false) {
|
|
49
|
+
const { enabled, options, files } = toolGate(option, strict, {
|
|
50
|
+
tool: "tailwind",
|
|
51
|
+
has: hasTailwind,
|
|
52
|
+
packageName: "tailwindcss",
|
|
53
|
+
needs: {
|
|
54
|
+
what: "entry CSS",
|
|
55
|
+
detail: "single Tailwind v4 entry CSS (a *.css containing `@import \"tailwindcss\"`, scanned across the workspace root and every workspace package)",
|
|
56
|
+
hint: "`tailwind: { cssConfigPath }`"
|
|
57
|
+
},
|
|
58
|
+
allowMultiple: false,
|
|
59
|
+
absolutizeOptions: ({ cssConfigPath }) => cssConfigPath ? [isAbsolute(cssConfigPath) ? cssConfigPath : resolve(findWorkspaceRoot(), cssConfigPath)] : [],
|
|
60
|
+
scan: () => findTailwindEntries(GLOBAL_IGNORES)
|
|
61
|
+
});
|
|
62
|
+
if (!enabled) return [];
|
|
63
|
+
const cssConfigPath = options.cssConfigPath ?? files[0];
|
|
64
|
+
const { scoped = true } = options;
|
|
65
|
+
const packageDir = scoped ? packageDirOf(files[0]) : null;
|
|
66
|
+
const basePath = packageDir && packageDir !== findWorkspaceRoot() ? { basePath: packageDir } : {};
|
|
67
|
+
return [{
|
|
68
|
+
...(await import("eslint-plugin-tailwindcss")).default.configs.recommended,
|
|
69
|
+
...basePath,
|
|
70
|
+
settings: { tailwindcss: { cssConfigPath } }
|
|
71
|
+
}];
|
|
98
72
|
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { findTailwindEntry, tailwindConfig };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import jestPlugin from
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { ToggleOptions } from "../index.js";
|
|
2
|
+
import vitestPlugin from "@vitest/eslint-plugin";
|
|
3
|
+
import jestPlugin from "eslint-plugin-jest";
|
|
4
|
+
import { Linter } from "eslint";
|
|
5
|
+
//#region src/configs/testing.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Jest recommended rules, scoped to test files.
|
|
8
8
|
*
|
|
@@ -19,4 +19,5 @@ export declare function vitestConfig(option?: boolean | ToggleOptions, strict?:
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
export declare function testConfig(): Linter.Config[];
|
|
22
|
-
//#
|
|
22
|
+
//#endregion
|
|
23
|
+
export { jestPlugin, vitestPlugin };
|
package/dist/configs/testing.js
CHANGED
|
@@ -1,155 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
import fs from 'node:fs';
|
|
12
|
-
import path from 'node:path';
|
|
13
|
-
import vitestPlugin from '@vitest/eslint-plugin';
|
|
14
|
-
import jestPlugin from 'eslint-plugin-jest';
|
|
15
|
-
import { tsExts, tsExtsRaw } from '../exts.js';
|
|
16
|
-
import { GLOBAL_IGNORES, hasJest, hasVitest, scanWorkspace, toolGate } from '../lib.js';
|
|
17
|
-
export { jestPlugin, vitestPlugin };
|
|
18
|
-
/*
|
|
19
|
-
* Both runners use the evidence-based `toolGate` (see lib.js): a runner config file marks the repo
|
|
20
|
-
* even when the runner is installed only in a leaf package (invisible to the `has*` probe), and
|
|
21
|
-
* the runner package itself must then be resolvable - eslint-plugin-jest sniffs the installed
|
|
22
|
-
* `jest` version (jest/no-deprecated-functions) - so leaf-only installs are bridged. Unlike the
|
|
23
|
-
* plugin-crashing tools (next/storybook/tailwind) the rules are pure AST checks that work without
|
|
24
|
-
* the runner, so forcing a runner on never throws (`requirePackage: false`).
|
|
25
|
-
*/
|
|
26
|
-
// derived from the shared extension list - one source of truth with the lint file globs
|
|
27
|
-
const SOURCE_EXTS = tsExtsRaw.split(',').map((ext) => `.${ext}`);
|
|
28
|
-
const TEST_SUFFIX = new RegExp(`\\.test\\.(${tsExtsRaw.replaceAll(',', '|')})$`);
|
|
1
|
+
import { tsExts, tsExtsRaw } from "../exts.js";
|
|
2
|
+
import { GLOBAL_IGNORES, hasJest, hasVitest, scanWorkspace, toolGate } from "../lib.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import vitestPlugin from "@vitest/eslint-plugin";
|
|
6
|
+
import jestPlugin from "eslint-plugin-jest";
|
|
7
|
+
//#region src/configs/testing.ts
|
|
8
|
+
const SOURCE_EXTS = tsExtsRaw.split(",").map((ext) => `.${ext}`);
|
|
9
|
+
const TEST_SUFFIX = new RegExp(`\\.test\\.(${tsExtsRaw.replaceAll(",", "|")})$`);
|
|
29
10
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
* Custom rule (registered as `local/test-colocation` by {@link testConfig}). Only `*.test.*` is
|
|
12
|
+
* checked, not `*.spec.*` - per testing.md, spec files cover e2e/integration flows that don't map
|
|
13
|
+
* 1:1 to a single sibling source file, so co-location isn't meaningful there.
|
|
14
|
+
*/
|
|
34
15
|
const testColocation = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
messageId: 'missingSibling',
|
|
65
|
-
data: { testFile: base, expected: `${stem}.ts` },
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
},
|
|
16
|
+
meta: {
|
|
17
|
+
type: "problem",
|
|
18
|
+
docs: { description: "require *.test.* files to sit next to the source file they test, not in a separate folder" },
|
|
19
|
+
schema: [],
|
|
20
|
+
messages: { missingSibling: "No sibling source file found for '{{testFile}}'. Expected e.g. '{{expected}}' in the same directory, not a separate __tests__/ folder." }
|
|
21
|
+
},
|
|
22
|
+
create(context) {
|
|
23
|
+
const base = path.basename(context.filename);
|
|
24
|
+
const match = base.match(TEST_SUFFIX);
|
|
25
|
+
if (!match) return {};
|
|
26
|
+
const stem = base.slice(0, -match[0].length);
|
|
27
|
+
let siblings;
|
|
28
|
+
try {
|
|
29
|
+
siblings = fs.readdirSync(path.dirname(context.filename));
|
|
30
|
+
} catch {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
if (SOURCE_EXTS.some((ext) => siblings.includes(`${stem}${ext}`))) return {};
|
|
34
|
+
return { Program(node) {
|
|
35
|
+
context.report({
|
|
36
|
+
node,
|
|
37
|
+
messageId: "missingSibling",
|
|
38
|
+
data: {
|
|
39
|
+
testFile: base,
|
|
40
|
+
expected: `${stem}.ts`
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
} };
|
|
44
|
+
}
|
|
70
45
|
};
|
|
71
46
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
files: [`**/*.{test,spec}.${tsExts}`],
|
|
90
|
-
},
|
|
91
|
-
];
|
|
47
|
+
* Jest recommended rules, scoped to test files.
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
function jestConfig(option, strict = false) {
|
|
51
|
+
const { enabled } = toolGate(option, strict, {
|
|
52
|
+
tool: "jest",
|
|
53
|
+
has: hasJest,
|
|
54
|
+
packageName: "jest",
|
|
55
|
+
requirePackage: false,
|
|
56
|
+
scan: () => scanWorkspace("jest.config.*", GLOBAL_IGNORES)
|
|
57
|
+
});
|
|
58
|
+
if (!enabled) return [];
|
|
59
|
+
return [{
|
|
60
|
+
...jestPlugin.configs["flat/recommended"],
|
|
61
|
+
name: "Jest Rules",
|
|
62
|
+
files: [`**/*.{test,spec}.${tsExts}`]
|
|
63
|
+
}];
|
|
92
64
|
}
|
|
93
65
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
{
|
|
125
|
-
...vitestPlugin.configs.env,
|
|
126
|
-
name: 'Vitest globals',
|
|
127
|
-
files: [`**/*.{test,spec}.${tsExts}`],
|
|
128
|
-
},
|
|
129
|
-
];
|
|
66
|
+
* Vitest recommended rules + globals, scoped to test files.
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
function vitestConfig(option, strict = false) {
|
|
70
|
+
const { enabled } = toolGate(option, strict, {
|
|
71
|
+
tool: "vitest",
|
|
72
|
+
has: hasVitest,
|
|
73
|
+
packageName: "vitest",
|
|
74
|
+
requirePackage: false,
|
|
75
|
+
scan: () => scanWorkspace("{vitest,vite}.config.*", GLOBAL_IGNORES)
|
|
76
|
+
});
|
|
77
|
+
if (!enabled) return [];
|
|
78
|
+
return [{
|
|
79
|
+
...vitestPlugin.configs.recommended,
|
|
80
|
+
name: "Vitest Rules",
|
|
81
|
+
files: [`**/*.{test,spec}.${tsExts}`],
|
|
82
|
+
rules: {
|
|
83
|
+
...vitestPlugin.configs.recommended.rules,
|
|
84
|
+
"vitest/expect-expect": ["error", { assertFunctionNames: [
|
|
85
|
+
"expect",
|
|
86
|
+
"assert",
|
|
87
|
+
"expectTypeOf",
|
|
88
|
+
"assertType"
|
|
89
|
+
] }]
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
...vitestPlugin.configs.env,
|
|
93
|
+
name: "Vitest globals",
|
|
94
|
+
files: [`**/*.{test,spec}.${tsExts}`]
|
|
95
|
+
}];
|
|
130
96
|
}
|
|
131
97
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
];
|
|
98
|
+
* Runner-agnostic test rules: pure AST/call-name checking, needs neither jest nor vitest installed
|
|
99
|
+
* to work correctly, so it applies regardless of which one (if either) is present.
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
function testConfig() {
|
|
103
|
+
return [{
|
|
104
|
+
name: "Test rules",
|
|
105
|
+
files: [`**/*.{test,spec}.${tsExts}`],
|
|
106
|
+
plugins: {
|
|
107
|
+
jest: jestPlugin,
|
|
108
|
+
vitest: vitestPlugin,
|
|
109
|
+
local: { rules: { "test-colocation": testColocation } }
|
|
110
|
+
},
|
|
111
|
+
rules: {
|
|
112
|
+
"jest/consistent-test-it": ["error", { fn: "test" }],
|
|
113
|
+
"vitest/consistent-test-it": ["error", { fn: "test" }],
|
|
114
|
+
"local/test-colocation": "error",
|
|
115
|
+
"jest/no-disabled-tests": "warn",
|
|
116
|
+
"vitest/no-disabled-tests": "warn"
|
|
117
|
+
}
|
|
118
|
+
}];
|
|
155
119
|
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { jestConfig, jestPlugin, testConfig, vitestConfig, vitestPlugin };
|
package/dist/configs/turbo.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ToggleOptions } from "../index.js";
|
|
2
|
+
import { Linter } from "eslint";
|
|
3
|
+
//#region src/configs/turbo.d.ts
|
|
3
4
|
export declare const turboPlugin: typeof import("eslint-plugin-turbo") | null;
|
|
4
5
|
/**
|
|
5
6
|
* Turborepo rules. Probe-only gate (see `toolGate` in lib.js) - no evidence scan, no bridge.
|
|
6
7
|
*
|
|
7
8
|
*/
|
|
8
9
|
export declare function turboConfig(option?: boolean | ToggleOptions): Promise<Linter.Config[]>;
|
|
9
|
-
//#
|
|
10
|
+
//#endregion
|
package/dist/configs/turbo.js
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
import { hasTurbo, toolGate } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { hasTurbo, toolGate } from "../lib.js";
|
|
2
|
+
//#region src/configs/turbo.ts
|
|
3
|
+
const turboPlugin = hasTurbo ? (await import("eslint-plugin-turbo")).default : null;
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
name: 'eslint-plugin-turbo overrides',
|
|
20
|
-
rules: {
|
|
21
|
-
/*
|
|
22
|
-
* Only covers undeclared env vars, not the full dependsOn/outputs consistency - that part has no
|
|
23
|
-
* ESLint-shaped check. Downgraded from their default 'error' to 'warn'.
|
|
24
|
-
*/
|
|
25
|
-
'turbo/no-undeclared-env-vars': 'warn',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
];
|
|
5
|
+
* Turborepo rules. Probe-only gate (see `toolGate` in lib.js) - no evidence scan, no bridge.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
async function turboConfig(option) {
|
|
9
|
+
const { enabled } = toolGate(option, false, {
|
|
10
|
+
tool: "turbo",
|
|
11
|
+
has: hasTurbo
|
|
12
|
+
});
|
|
13
|
+
if (!enabled) return [];
|
|
14
|
+
const recommended = (await import("eslint-plugin-turbo")).default.configs?.["flat/recommended"];
|
|
15
|
+
return [...Array.isArray(recommended) ? recommended : [recommended ?? {}], {
|
|
16
|
+
name: "eslint-plugin-turbo overrides",
|
|
17
|
+
rules: { "turbo/no-undeclared-env-vars": "warn" }
|
|
18
|
+
}];
|
|
29
19
|
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { turboConfig, turboPlugin };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { TypeAwareOptions } from "../index.js";
|
|
2
|
+
import { Linter } from "eslint";
|
|
3
|
+
//#region src/configs/typescriptTypeAware.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Type-aware rules. Off by default (FIXME: does not perform) - enable via
|
|
5
6
|
* `defineLintConfig({ typeAware: true })` or by composing this block manually; it is self-contained
|
|
@@ -17,4 +18,4 @@ import type { TypeAwareOptions } from '../index.js';
|
|
|
17
18
|
* There is nothing to auto-detect, so only an explicit `true` or options object enables the block.
|
|
18
19
|
*/
|
|
19
20
|
export declare function typeAwareConfig(option?: boolean | TypeAwareOptions, strict?: boolean): Linter.Config[];
|
|
20
|
-
//#
|
|
21
|
+
//#endregion
|