@kirill.konshin/lint 0.6.8 → 0.7.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 (50) hide show
  1. package/README.md +253 -94
  2. package/dist/configs/imports.js +3 -30
  3. package/dist/configs/react.d.ts +0 -15
  4. package/dist/configs/react.js +2 -36
  5. package/dist/configs/tailwind.d.ts +10 -0
  6. package/dist/configs/tailwind.js +25 -9
  7. package/dist/configs/testing.js +2 -41
  8. package/dist/configs/unicorn.js +2 -10
  9. package/dist/conventions.d.ts +12 -0
  10. package/dist/conventions.js +53 -0
  11. package/dist/index.d.ts +4 -4
  12. package/dist/index.js +4 -4
  13. package/dist/lib.d.ts +18 -1
  14. package/dist/lib.js +36 -2
  15. package/dist/lintPrepare.d.ts +2 -1
  16. package/dist/lintPrepare.js +13 -1
  17. package/dist/oxlintPlugin.d.ts +10 -0
  18. package/dist/oxlintPlugin.js +13 -0
  19. package/dist/testColocation.d.ts +10 -0
  20. package/dist/testColocation.js +45 -0
  21. package/dist/vitePlus.d.ts +58 -0
  22. package/dist/vitePlus.js +434 -0
  23. package/package.json +32 -9
  24. package/rules/agent.md +3 -0
  25. package/rules/code-style.md +1 -1
  26. package/rules/github.md +2 -1
  27. package/rules/gitlab.md +2 -1
  28. package/rules/jest.md +1 -1
  29. package/rules/markdown.md +11 -0
  30. package/rules/monorepo-turbo-nx.md +9 -0
  31. package/rules/mui.md +0 -2
  32. package/rules/npm-yarn.md +10 -1
  33. package/rules/nx.md +3 -2
  34. package/rules/playwright.md +18 -0
  35. package/rules/react.md +1 -3
  36. package/rules/tailwind.md +1 -0
  37. package/rules/testing.md +5 -2
  38. package/rules/typescript.md +5 -4
  39. package/rules/vite.md +5 -1
  40. package/{rules/electron.md → skills/lint-electron/SKILL.md} +5 -3
  41. package/skills/lint-github/SKILL.md +31 -1
  42. package/skills/lint-gitlab/SKILL.md +22 -1
  43. package/skills/lint-migrate/SKILL.md +24 -0
  44. package/skills/lint-repo/SKILL.md +21 -5
  45. package/skills/lint-webstorm/SKILL.md +55 -3
  46. package/skills/spec-steward/SKILL.md +72 -15
  47. package/skills/spec-steward/references/contract.md +6 -6
  48. package/skills/spec-tools/SKILL.md +11 -11
  49. package/skills/spec-tools/references/rules/common.md +32 -7
  50. package/skills/spec-tools/scripts/cli.js +18 -12
@@ -1,48 +1,9 @@
1
- import { tsExts, tsExtsRaw } from "../exts.js";
1
+ import { tsExts } from "../exts.js";
2
2
  import { GLOBAL_IGNORES, hasJest, hasVitest, scanWorkspace, toolGate } from "../lib.js";
3
- import path from "node:path";
4
- import fs from "node:fs";
3
+ import { testColocation } from "../testColocation.js";
5
4
  import vitestPlugin from "@vitest/eslint-plugin";
6
5
  import jestPlugin from "eslint-plugin-jest";
7
6
  //#region src/configs/testing.ts
8
- const SOURCE_EXTS = tsExtsRaw.split(",").map((ext) => `.${ext}`);
9
- const TEST_SUFFIX = new RegExp(`\\.test\\.(${tsExtsRaw.replaceAll(",", "|")})$`);
10
- /**
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
- */
15
- const testColocation = {
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
- }
45
- };
46
7
  /**
47
8
  * Jest recommended rules, scoped to test files.
48
9
  *
@@ -1,4 +1,5 @@
1
1
  import { tsExts } from "../exts.js";
2
+ import { filenameCaseIgnore } from "../conventions.js";
2
3
  import unicornPlugin from "eslint-plugin-unicorn";
3
4
  //#region src/configs/unicorn.ts
4
5
  /**
@@ -17,16 +18,7 @@ function unicornConfig() {
17
18
  "unicorn/filename-case": ["error", {
18
19
  case: "camelCase",
19
20
  checkDirectories: false,
20
- ignore: [
21
- /^not-found\.[jt]sx?$/,
22
- /^global-error\.[jt]sx?$/,
23
- /^opengraph-image\.[jt]sx?$/,
24
- /^twitter-image\.[jt]sx?$/,
25
- /^apple-icon\.[jt]sx?$/,
26
- /^mdx-components\.[jt]sx?$/,
27
- /\.d\.tsx?$/,
28
- /^electron-builder\..+$/
29
- ]
21
+ ignore: filenameCaseIgnore
30
22
  }],
31
23
  "unicorn/prefer-node-protocol": "error"
32
24
  }
@@ -0,0 +1,12 @@
1
+ //#region src/conventions.d.ts
2
+ /**
3
+ * Files that legitimately default-export (framework/tooling conventions): configs, stories, Storybook, Next.js App
4
+ * Router files and declarations.
5
+ */
6
+ export declare const defaultExportFiles: string[];
7
+ /**
8
+ * File names exempt from camelCase: Next.js App Router mandates these exact hyphenated names, React Native / Expo its
9
+ * `App` entry, declarations follow the package they describe, and electron-builder looks up its own config name.
10
+ */
11
+ export declare const filenameCaseIgnore: RegExp[];
12
+ //#endregion
@@ -0,0 +1,53 @@
1
+ import { tsExts } from "./exts.js";
2
+ //#region src/conventions.ts
3
+ /**
4
+ * Files that legitimately default-export (framework/tooling conventions): configs, stories, Storybook, Next.js App
5
+ * Router files and declarations.
6
+ */
7
+ const defaultExportFiles = [
8
+ "**/*.config.*",
9
+ `**/*.stories.${tsExts}`,
10
+ `**/.storybook/main.${tsExts}`,
11
+ `**/.storybook/preview.${tsExts}`,
12
+ "**/.lintstagedrc*",
13
+ "**/.prettierrc*",
14
+ "**/electron-builder.*",
15
+ `**/App.${tsExts}`,
16
+ `**/index.${tsExts}`,
17
+ `**/main.${tsExts}`,
18
+ "**/*.d.ts",
19
+ `**/default.${tsExts}`,
20
+ `**/error.${tsExts}`,
21
+ `**/forbidden.${tsExts}`,
22
+ `**/global-error.${tsExts}`,
23
+ `**/layout.${tsExts}`,
24
+ `**/loading.${tsExts}`,
25
+ `**/not-found.${tsExts}`,
26
+ `**/page.${tsExts}`,
27
+ `**/template.${tsExts}`,
28
+ `**/unauthorized.${tsExts}`,
29
+ `**/apple-icon.${tsExts}`,
30
+ `**/icon.${tsExts}`,
31
+ `**/manifest.${tsExts}`,
32
+ `**/opengraph-image.${tsExts}`,
33
+ `**/robots.${tsExts}`,
34
+ `**/sitemap.${tsExts}`,
35
+ `**/twitter-image.${tsExts}`
36
+ ];
37
+ /**
38
+ * File names exempt from camelCase: Next.js App Router mandates these exact hyphenated names, React Native / Expo its
39
+ * `App` entry, declarations follow the package they describe, and electron-builder looks up its own config name.
40
+ */
41
+ const filenameCaseIgnore = [
42
+ /^App\.[jt]sx?$/,
43
+ /^not-found\.[jt]sx?$/,
44
+ /^global-error\.[jt]sx?$/,
45
+ /^opengraph-image\.[jt]sx?$/,
46
+ /^twitter-image\.[jt]sx?$/,
47
+ /^apple-icon\.[jt]sx?$/,
48
+ /^mdx-components\.[jt]sx?$/,
49
+ /\.d\.tsx?$/,
50
+ /^electron-builder\..+$/
51
+ ];
52
+ //#endregion
53
+ export { defaultExportFiles, filenameCaseIgnore };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { importSortConfig, importXConfig, unusedImportsConfig } from "./configs/imports.js";
2
- import { findNextRoots, nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, reactBaseConfig, reactConfig, reactSettingsConfig, typescriptOverridesConfig } from "./configs/react.js";
2
+ import { nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, reactBaseConfig, reactConfig, reactSettingsConfig, typescriptOverridesConfig } from "./configs/react.js";
3
3
  import { nxConfig, nxPlugin } from "./configs/nx.js";
4
4
  import { prettierConfig } from "./configs/prettier.js";
5
5
  import { promiseConfig } from "./configs/promise.js";
6
6
  import { storybookConfig } from "./configs/storybook.js";
7
- import { findTailwindEntry, tailwindConfig } from "./configs/tailwind.js";
7
+ import { findTailwindEntry, tailwindConfig, tailwindGate } from "./configs/tailwind.js";
8
8
  import { jestConfig, jestPlugin, testConfig, vitestConfig, vitestPlugin } from "./configs/testing.js";
9
9
  import { turboConfig, turboPlugin } from "./configs/turbo.js";
10
10
  import { typeAwareConfig } from "./configs/typescriptTypeAware.js";
11
11
  import { unicornConfig } from "./configs/unicorn.js";
12
12
  import { eslintExts, eslintExtsRaw, markupExtsRaw, prettierExts, prettierExtsRaw, tsExts, tsExtsRaw } from "./exts.js";
13
- import { GLOBAL_IGNORES, asOptions, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
13
+ import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
14
14
  import { Restriction, restrictions } from "./restrictions.js";
15
15
  import { listStaged } from "./lintStaged.js";
16
16
  import { prettier } from "./prettier.js";
@@ -67,4 +67,4 @@ export type LintOptions = {
67
67
  */
68
68
  export declare function defineLintConfig(options?: LintOptions | Promise<LintOptions> | (() => LintOptions | Promise<LintOptions>)): Promise<Linter.Config[]>;
69
69
  //#endregion
70
- export { GLOBAL_IGNORES, Restriction, asOptions, baseConfig, defaultIgnoreConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestPlugin, listStaged, markupExtsRaw, nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, nxConfig, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, restrictions, scanWorkspace, storybookConfig, tailwindConfig, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestPlugin };
70
+ export { GLOBAL_IGNORES, Restriction, asOptions, baseConfig, defaultIgnoreConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestPlugin, listStaged, markupExtsRaw, nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, nxConfig, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, restrictions, scanWorkspace, storybookConfig, tailwindConfig, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestPlugin };
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { eslintExts, eslintExtsRaw, markupExtsRaw, prettierExts, prettierExtsRaw, tsExts, tsExtsRaw } from "./exts.js";
2
- import { GLOBAL_IGNORES, asOptions, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
2
+ import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
3
3
  import { baseConfig, defaultIgnoreConfig, includeIgnoreFile } from "./configs/base.js";
4
4
  import { importSortConfig, importXConfig, unusedImportsConfig } from "./configs/imports.js";
5
5
  import { nxConfig, nxPlugin } from "./configs/nx.js";
6
6
  import { prettierConfig } from "./configs/prettier.js";
7
7
  import { promiseConfig } from "./configs/promise.js";
8
- import { findNextRoots, nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, reactBaseConfig, reactConfig, reactSettingsConfig, typescriptOverridesConfig } from "./configs/react.js";
8
+ import { nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, reactBaseConfig, reactConfig, reactSettingsConfig, typescriptOverridesConfig } from "./configs/react.js";
9
9
  import { storybookConfig } from "./configs/storybook.js";
10
- import { findTailwindEntry, tailwindConfig } from "./configs/tailwind.js";
10
+ import { findTailwindEntry, tailwindConfig, tailwindGate } from "./configs/tailwind.js";
11
11
  import { jestConfig, jestPlugin, testConfig, vitestConfig, vitestPlugin } from "./configs/testing.js";
12
12
  import { turboConfig, turboPlugin } from "./configs/turbo.js";
13
13
  import { typeAwareConfig } from "./configs/typescriptTypeAware.js";
@@ -52,4 +52,4 @@ async function defineLintConfig(options = {}) {
52
52
  ];
53
53
  }
54
54
  //#endregion
55
- export { GLOBAL_IGNORES, asOptions, baseConfig, defaultIgnoreConfig, defineLintConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestPlugin, listStaged, markupExtsRaw, nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, nxConfig, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, restrictions, scanWorkspace, storybookConfig, tailwindConfig, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestPlugin };
55
+ export { GLOBAL_IGNORES, asOptions, baseConfig, defaultIgnoreConfig, defineLintConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestPlugin, listStaged, markupExtsRaw, nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, nxConfig, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, restrictions, scanWorkspace, storybookConfig, tailwindConfig, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestPlugin };
package/dist/lib.d.ts CHANGED
@@ -66,6 +66,22 @@ export declare function packageDirOf(file: string): string;
66
66
  export declare function scanWorkspace(fileGlob: string, ignores?: string[], { dot }?: {
67
67
  dot?: boolean;
68
68
  }): string[];
69
+ /**
70
+ * Auto-find Next.js app roots below the workspace root (scanned like the Tailwind entry - see
71
+ * {@link scanWorkspace}). `next.config.*` is optional in Next.js, so any of three signals marks an app
72
+ * root:
73
+ * - a `next.config.*` file
74
+ * - a `package.json` depending on `next` (see {@link dependsOnNext})
75
+ * - a `src/app` or `src/pages` directory - the reported root is the directory CONTAINING `src`,
76
+ * because the plugin resolves both layouts (`pages`/`app` and `src/pages`/`src/app`) from the
77
+ * package root itself; the bare root-level dir names are too generic to scan for, but such apps
78
+ * are caught by the other two signals
79
+ *
80
+ * Returns absolute directories, deduplicated (one app usually shows several signals) and sorted
81
+ * so the emitted settings block is deterministic across filesystems. Lives here, not in the React
82
+ * block, so the Vite+ config detects Next.js without loading `eslint-config-next`.
83
+ */
84
+ export declare function findNextRoots(ignores: string[]): string[];
69
85
  export declare const hasNext: boolean;
70
86
  export declare const hasStorybook: boolean;
71
87
  export declare const hasVite: boolean;
@@ -107,4 +123,5 @@ export declare function asOptions<T extends ToggleOptions>(option: boolean | T |
107
123
  *
108
124
  */
109
125
  export declare function toolGate<T extends ToggleOptions>(option: boolean | T | undefined, strict: boolean, spec: ToolGateSpec<T>): ToolGateResult<T>;
110
- //#endregion
126
+ //#endregion
127
+ export {};
package/dist/lib.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { dirname, isAbsolute, relative, resolve } from "node:path";
2
2
  import { includeIgnoreFile } from "@eslint/config-helpers";
3
- import { existsSync } from "node:fs";
3
+ import { existsSync, readFileSync } from "node:fs";
4
4
  import { findRootSync } from "@manypkg/find-root";
5
5
  import { getPackagesSync } from "@manypkg/get-packages";
6
6
  import { globSync } from "glob";
@@ -168,6 +168,40 @@ function scanWorkspace(fileGlob, ignores = [], { dot = false } = {}) {
168
168
  dot
169
169
  }))];
170
170
  }
171
+ /**
172
+ * Does this `package.json` declare `next` as a dependency? Peer/optional declarations are
173
+ * deliberately ignored - they mark component libraries, not apps.
174
+ */
175
+ function dependsOnNext(file) {
176
+ try {
177
+ const { dependencies, devDependencies } = JSON.parse(readFileSync(file, "utf-8"));
178
+ return Boolean(dependencies?.next ?? devDependencies?.next);
179
+ } catch {
180
+ return false;
181
+ }
182
+ }
183
+ /**
184
+ * Auto-find Next.js app roots below the workspace root (scanned like the Tailwind entry - see
185
+ * {@link scanWorkspace}). `next.config.*` is optional in Next.js, so any of three signals marks an app
186
+ * root:
187
+ * - a `next.config.*` file
188
+ * - a `package.json` depending on `next` (see {@link dependsOnNext})
189
+ * - a `src/app` or `src/pages` directory - the reported root is the directory CONTAINING `src`,
190
+ * because the plugin resolves both layouts (`pages`/`app` and `src/pages`/`src/app`) from the
191
+ * package root itself; the bare root-level dir names are too generic to scan for, but such apps
192
+ * are caught by the other two signals
193
+ *
194
+ * Returns absolute directories, deduplicated (one app usually shows several signals) and sorted
195
+ * so the emitted settings block is deterministic across filesystems. Lives here, not in the React
196
+ * block, so the Vite+ config detects Next.js without loading `eslint-config-next`.
197
+ */
198
+ function findNextRoots(ignores) {
199
+ return [.../* @__PURE__ */ new Set([
200
+ ...scanWorkspace("next.config.*", ignores).map((file) => dirname(file)),
201
+ ...scanWorkspace("package.json", ignores).filter(dependsOnNext).map((file) => dirname(file)),
202
+ ...scanWorkspace("src/{app,pages}/", ignores).map((dir) => dirname(dirname(dir)))
203
+ ])].sort();
204
+ }
171
205
  const hasNext = isPackageResolvable("next");
172
206
  const hasStorybook = isPackageResolvable("storybook");
173
207
  const hasVite = isPackageResolvable("vite");
@@ -287,4 +321,4 @@ function toolGate(option, strict, spec) {
287
321
  }, enabled ? "forced on" : "detected");
288
322
  }
289
323
  //#endregion
290
- export { GLOBAL_IGNORES, asOptions, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate };
324
+ export { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate };
@@ -103,4 +103,5 @@ export declare function checkExisting(targetPath: string): ExistingFile;
103
103
  * Main function
104
104
  */
105
105
  export declare function main(): void;
106
- //#endregion
106
+ //#endregion
107
+ export {};
@@ -46,6 +46,17 @@ const FOOTER = `---
46
46
 
47
47
  Add your project-specific rules below the comment line.`;
48
48
  const GENERATED_MARKER = "<!-- @kirill.konshin/lint:generated -->";
49
+ /**
50
+ * Marked sections of AGENTS.md that other tools own. Tools write their own agent instructions - nobody copies them by
51
+ * hand: this file only provides each anchor, an empty marker pair, on every generation. Sequencing does the rest: the
52
+ * tool runs right after `lint-prepare` in the same install script and fills its section - Vite+ on `vp config` (it
53
+ * never creates a section, and its creating commands rewrite dependencies).
54
+ */
55
+ const TOOL_SECTIONS = [{
56
+ tool: "Vite+",
57
+ start: "<!--VITE PLUS START-->",
58
+ end: "<!--VITE PLUS END-->"
59
+ }];
49
60
  const lstat = (file) => fs.lstatSync(file, { throwIfNoEntry: false });
50
61
  /**
51
62
  * `monorepo-turbo-nx` -> `Monorepo turbo nx`
@@ -335,7 +346,8 @@ function generateAgentsFile(rules, customSection) {
335
346
  const scope = rule.paths ? `; when touching ${rule.paths.map((glob) => `\`${glob}\``).join(", ")}` : "";
336
347
  return `- **${toTitle(rule.name)}**${description}${scope}: [${rulePath}](${rulePath})`;
337
348
  });
338
- const generated = `${HEADER}\n\n# Rules\n\n${entries.join("\n")}\n\n${FOOTER}\n\n${GENERATED_MARKER}`;
349
+ const sections = TOOL_SECTIONS.map(({ start, end }) => `${start}\n${end}`);
350
+ const generated = `${HEADER}\n\n# Rules\n\n${entries.join("\n")}\n\n${sections.join("\n\n")}\n\n${FOOTER}\n\n${GENERATED_MARKER}`;
339
351
  return customSection ? `${generated}\n\n${customSection}\n` : `${generated}\n`;
340
352
  }
341
353
  /**
@@ -0,0 +1,10 @@
1
+ import { ESLint } from "eslint";
2
+ //#region src/oxlintPlugin.d.ts
3
+ /**
4
+ * Oxlint JS plugin with this package's custom rules, the `@kirill.konshin/lint/oxlint-plugin` entry. The Vite+ config
5
+ * registers it as `local`, the name the ESLint config uses, so `local/test-colocation` reads the same in both. Oxlint
6
+ * runs ESLint-shaped rules, so the ESLint rule module is reused as is.
7
+ */
8
+ declare const plugin: ESLint.Plugin;
9
+ //#endregion
10
+ export { plugin as default };
@@ -0,0 +1,13 @@
1
+ import { testColocation } from "./testColocation.js";
2
+ //#region src/oxlintPlugin.ts
3
+ /**
4
+ * Oxlint JS plugin with this package's custom rules, the `@kirill.konshin/lint/oxlint-plugin` entry. The Vite+ config
5
+ * registers it as `local`, the name the ESLint config uses, so `local/test-colocation` reads the same in both. Oxlint
6
+ * runs ESLint-shaped rules, so the ESLint rule module is reused as is.
7
+ */
8
+ const plugin = {
9
+ meta: { name: "local" },
10
+ rules: { "test-colocation": testColocation }
11
+ };
12
+ //#endregion
13
+ export { plugin as default };
@@ -0,0 +1,10 @@
1
+ import { Rule } from "eslint";
2
+ //#region src/testColocation.d.ts
3
+ /**
4
+ * Custom rule, registered as `local/test-colocation` by the ESLint `testConfig` and by the Oxlint JS plugin
5
+ * (`@kirill.konshin/lint/oxlint-plugin`). Free of plugin imports, so Oxlint loads only this rule. Only `*.test.*` is
6
+ * checked, not `*.spec.*` - per testing.md, spec files cover e2e/integration flows that don't map 1:1 to a single
7
+ * sibling source file, so co-location isn't meaningful there.
8
+ */
9
+ export declare const testColocation: Rule.RuleModule;
10
+ //#endregion
@@ -0,0 +1,45 @@
1
+ import { tsExtsRaw } from "./exts.js";
2
+ import path from "node:path";
3
+ import fs from "node:fs";
4
+ //#region src/testColocation.ts
5
+ const SOURCE_EXTS = tsExtsRaw.split(",").map((ext) => `.${ext}`);
6
+ const TEST_SUFFIX = new RegExp(`\\.test\\.(${tsExtsRaw.replaceAll(",", "|")})$`);
7
+ /**
8
+ * Custom rule, registered as `local/test-colocation` by the ESLint `testConfig` and by the Oxlint JS plugin
9
+ * (`@kirill.konshin/lint/oxlint-plugin`). Free of plugin imports, so Oxlint loads only this rule. Only `*.test.*` is
10
+ * checked, not `*.spec.*` - per testing.md, spec files cover e2e/integration flows that don't map 1:1 to a single
11
+ * sibling source file, so co-location isn't meaningful there.
12
+ */
13
+ const testColocation = {
14
+ meta: {
15
+ type: "problem",
16
+ docs: { description: "require *.test.* files to sit next to the source file they test, not in a separate folder" },
17
+ schema: [],
18
+ messages: { missingSibling: "No sibling source file found for '{{testFile}}'. Expected e.g. '{{expected}}' in the same directory, not a separate __tests__/ folder." }
19
+ },
20
+ create(context) {
21
+ const base = path.basename(context.filename);
22
+ const match = base.match(TEST_SUFFIX);
23
+ if (!match) return {};
24
+ const stem = base.slice(0, -match[0].length);
25
+ let siblings;
26
+ try {
27
+ siblings = fs.readdirSync(path.dirname(context.filename));
28
+ } catch {
29
+ return {};
30
+ }
31
+ if (SOURCE_EXTS.some((ext) => siblings.includes(`${stem}${ext}`))) return {};
32
+ return { Program(node) {
33
+ context.report({
34
+ node,
35
+ messageId: "missingSibling",
36
+ data: {
37
+ testFile: base,
38
+ expected: `${stem}.ts`
39
+ }
40
+ });
41
+ } };
42
+ }
43
+ };
44
+ //#endregion
45
+ export { testColocation };
@@ -0,0 +1,58 @@
1
+ import { tsExts } from "./exts.js";
2
+ import { DetectionOptions, TailwindOptions, ToggleOptions } from "./index.js";
3
+ import { UserConfig } from "vite-plus";
4
+ import { OxfmtConfig } from "vite-plus/fmt";
5
+ import { OxlintConfig } from "vite-plus/lint";
6
+ //#region src/vitePlus.d.ts
7
+ type StagedConfig = NonNullable<UserConfig['staged']>;
8
+ export type VitePlusOptions = {
9
+ detection?: boolean | DetectionOptions;
10
+ next?: boolean | ToggleOptions;
11
+ storybook?: boolean | ToggleOptions;
12
+ turbo?: boolean | ToggleOptions;
13
+ nx?: boolean | ToggleOptions;
14
+ jest?: boolean | ToggleOptions;
15
+ vitest?: boolean | ToggleOptions;
16
+ tailwind?: boolean | TailwindOptions;
17
+ typeAware?: boolean | ToggleOptions;
18
+ };
19
+ /**
20
+ * Oxlint config: the ESLint config's rules, by Oxlint's names. Each plugin's `recommended` set maps to Oxlint's
21
+ * `correctness` category; the deliberate overrides of the ESLint config are listed rule by rule. Plugins Oxlint has no
22
+ * native port of (Nx, Storybook, Tailwind, Turbo, the local `test-colocation` rule) run as JS plugins.
23
+ *
24
+ * Not carried over: `@nx/dependency-checks` (Oxlint does not lint JSON), `multiline-comment-style` (off anyway),
25
+ * `@typescript-eslint/naming-convention` (type-aware only, off by default), the resolution-dependent `import-x` rules
26
+ * (off anyway). Import sorting moves to Oxfmt (`sortImports`), unused-import removal to `no-unused-vars` with an
27
+ * import autofix.
28
+ */
29
+ export declare function lintConfig(options?: VitePlusOptions): OxlintConfig;
30
+ /**
31
+ * Oxfmt config: the Prettier config (`./prettier`), plus the import order `simple-import-sort` enforced (see
32
+ * typescript.md). Oxfmt reads `.editorconfig`, which Prettier partly ignored, so the Prettier behaviors that differ
33
+ * from an `.editorconfig` are set explicitly (`insertFinalNewline`). `package.json` key order is left alone, as
34
+ * Prettier did. Oxfmt honours `.gitignore` and `.prettierignore`; the `.prettierignore` the README recommended is the
35
+ * default `ignorePatterns`. With `proseWrap: 'never'` a Markdown table is aligned only while it fits `printWidth`, so
36
+ * Markdown gets 200 columns; a wider table is HTML, or stays unaligned when it is mostly code (rules/markdown.md).
37
+ */
38
+ export declare function fmtConfig(): OxfmtConfig;
39
+ /**
40
+ * Staged-file checks (`vp staged`): what lint-staged ran, as one `vp check --fix` - it formats every file and lints
41
+ * the code files, so no two tasks race on one file.
42
+ */
43
+ export declare function stagedConfig(): StagedConfig;
44
+ /**
45
+ * The shared Vite+ config: {@link lintConfig}, {@link fmtConfig} and {@link stagedConfig} merged with the consumer's
46
+ * own config. Lists add up (`plugins`, `jsPlugins`, `overrides`, `ignorePatterns`), maps merge key by key (`rules`,
47
+ * `settings`, `env`, ...), and a consumer's `staged` replaces the default. Wrap the result in `defineConfig`:
48
+ *
49
+ * ```ts
50
+ * import { vitePlusConfig } from '@kirill.konshin/lint/vite-plus';
51
+ * import { defineConfig } from 'vite-plus';
52
+ *
53
+ * export default defineConfig(vitePlusConfig({ lint: { rules: { ... } } }));
54
+ * ```
55
+ */
56
+ export declare function vitePlusConfig(config?: UserConfig, options?: VitePlusOptions): UserConfig;
57
+ //#endregion
58
+ export { tsExts };