@kirill.konshin/lint 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +160 -113
- package/dist/config.d.ts +103 -0
- package/dist/config.js +112 -0
- package/dist/configs/base.d.ts +1 -1
- package/dist/configs/nx.d.ts +1 -1
- package/dist/configs/nx.js +3 -8
- package/dist/configs/react.d.ts +3 -3
- package/dist/configs/react.js +6 -16
- package/dist/configs/storybook.d.ts +3 -3
- package/dist/configs/storybook.js +4 -9
- package/dist/configs/tailwind.d.ts +6 -25
- package/dist/configs/tailwind.js +3 -64
- package/dist/configs/testing.d.ts +1 -1
- package/dist/configs/testing.js +3 -15
- package/dist/configs/turbo.d.ts +2 -2
- package/dist/configs/turbo.js +4 -6
- package/dist/configs/typescriptTypeAware.d.ts +1 -1
- package/dist/gates.d.ts +72 -0
- package/dist/gates.js +132 -0
- package/dist/index.d.ts +15 -51
- package/dist/index.js +16 -14
- package/dist/lib.d.ts +1 -1
- package/dist/lib.js +1 -1
- package/dist/lintPrepare.d.ts +75 -28
- package/dist/lintPrepare.js +243 -35
- package/dist/testColocation.js +1 -1
- package/dist/vitePlus.d.ts +8 -18
- package/dist/vitePlus.js +40 -47
- package/package.json +7 -4
- package/rules/agent.md +1 -0
- package/rules/auth.md +3 -3
- package/rules/db.md +6 -9
- package/rules/expo.md +2 -0
- package/rules/github.md +1 -1
- package/rules/gitlab.md +1 -1
- package/rules/i18n.md +3 -0
- package/rules/monorepo-turbo-nx.md +38 -4
- package/rules/mui.md +8 -18
- package/rules/nextjs.md +13 -13
- package/rules/npm-yarn.md +28 -118
- package/rules/nx.md +1 -1
- package/rules/playwright.md +1 -1
- package/rules/react.md +7 -32
- package/rules/tailwind.md +9 -47
- package/rules/testing.md +2 -2
- package/rules/turbo.md +1 -1
- package/rules/typescript.md +6 -2
- package/rules/ui-kit.md +6 -0
- package/rules/vite.md +1 -1
- package/skills/lint-db/SKILL.md +23 -0
- package/skills/lint-electron/SKILL.md +9 -6
- package/skills/lint-github/SKILL.md +15 -8
- package/skills/lint-gitlab/SKILL.md +20 -5
- package/skills/lint-migrate/SKILL.md +18 -2
- package/skills/lint-mui/SKILL.md +28 -0
- package/skills/lint-nextjs/SKILL.md +53 -16
- package/skills/lint-npm-yarn/SKILL.md +126 -0
- package/skills/lint-repo/SKILL.md +12 -12
- package/skills/lint-tailwind/SKILL.md +53 -0
- package/skills/lint-webstorm/SKILL.md +3 -3
- package/skills/lint-worktree/SKILL.md +25 -9
- package/skills/spec-author/SKILL.md +2 -2
- package/skills/spec-steward/SKILL.md +1 -1
- package/skills/spec-steward/references/apply.md +1 -1
- package/skills/spec-steward/references/contract.md +2 -2
- package/skills/spec-steward/references/model.md +2 -2
- package/skills/spec-steward/references/review-format.md +4 -4
- package/skills/spec-steward/references/wiring.md +2 -2
- package/skills/spec-steward/references/worker.md +1 -1
- package/skills/spec-tools/SKILL.md +2 -2
- package/skills/spec-tools/references/rules/common.md +1 -1
- package/skills/spec-tools/references/rules/spec-steward.md +1 -1
- package/skills/spec-tools/scripts/cli.js +2 -2
- package/skills/spec-verify/SKILL.md +1 -1
package/dist/gates.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { GLOBAL_IGNORES, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVitest, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
import { globSync } from "glob";
|
|
5
|
+
//#region src/gates.ts
|
|
6
|
+
/**
|
|
7
|
+
* Next.js. `requirePackage`: `eslint-config-next` `require`s files inside the `next` package, so the ESLint config needs
|
|
8
|
+
* `next` resolvable from the workspace root; Oxlint's native `nextjs` plugin does not.
|
|
9
|
+
*/
|
|
10
|
+
function nextGate(option, strict, { requirePackage = true } = {}) {
|
|
11
|
+
return toolGate(option, strict, {
|
|
12
|
+
tool: "next",
|
|
13
|
+
has: hasNext,
|
|
14
|
+
packageName: "next",
|
|
15
|
+
requirePackage,
|
|
16
|
+
absolutizeOptions: ({ rootDir }) => (Array.isArray(rootDir) ? rootDir : [rootDir]).filter((dir) => Boolean(dir)).flatMap((dir) => {
|
|
17
|
+
const pattern = isAbsolute(dir) ? dir : resolve(findWorkspaceRoot(), dir);
|
|
18
|
+
const dirs = globSync(`${pattern.replace(/\\/g, "/").replace(/\/+$/, "")}/`, { absolute: true });
|
|
19
|
+
return (dirs.length > 0 ? dirs : [pattern]).map((appDir) => join(appDir, "package.json"));
|
|
20
|
+
}),
|
|
21
|
+
scan: () => findNextRoots(GLOBAL_IGNORES).map((dir) => join(dir, "package.json"))
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Storybook: a `.storybook/main.*` marks a Storybook repo even when the package sits in a leaf package;
|
|
26
|
+
* `eslint-plugin-storybook` statically imports `storybook`, so it must be resolvable from the workspace root.
|
|
27
|
+
*/
|
|
28
|
+
function storybookGate(option, strict) {
|
|
29
|
+
return toolGate(option, strict, {
|
|
30
|
+
tool: "storybook",
|
|
31
|
+
has: hasStorybook,
|
|
32
|
+
packageName: "storybook",
|
|
33
|
+
scan: () => scanWorkspace(".storybook/main.*", GLOBAL_IGNORES, { dot: true })
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** Turborepo: probe only, never strict - no evidence scan. */
|
|
37
|
+
function turboGate(option) {
|
|
38
|
+
return toolGate(option, false, {
|
|
39
|
+
tool: "turbo",
|
|
40
|
+
has: hasTurbo
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Nx: `nx.json` at the workspace root (strict: at cwd). `packageName`: the package the integration needs resolvable -
|
|
45
|
+
* the Vite+ config runs `@nx/eslint-plugin` as a JS plugin, which needs `eslint`.
|
|
46
|
+
*/
|
|
47
|
+
function nxGate(option, strict, { packageName = "" } = {}) {
|
|
48
|
+
return toolGate(option, strict, {
|
|
49
|
+
tool: "nx",
|
|
50
|
+
has: hasNx,
|
|
51
|
+
strictHas: strict && existsSync(resolve(process.cwd(), "nx.json")),
|
|
52
|
+
...packageName ? { packageName } : {}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function jestGate(option, strict) {
|
|
56
|
+
return toolGate(option, strict, {
|
|
57
|
+
tool: "jest",
|
|
58
|
+
has: hasJest,
|
|
59
|
+
packageName: "jest",
|
|
60
|
+
requirePackage: false,
|
|
61
|
+
scan: () => scanWorkspace("jest.config.*", GLOBAL_IGNORES)
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function vitestGate(option, strict) {
|
|
65
|
+
return toolGate(option, strict, {
|
|
66
|
+
tool: "vitest",
|
|
67
|
+
has: hasVitest,
|
|
68
|
+
packageName: "vitest",
|
|
69
|
+
requirePackage: false,
|
|
70
|
+
scan: () => scanWorkspace("{vitest,vite}.config.*", GLOBAL_IGNORES)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* All Tailwind v4 entry CSS candidates: every `*.css` across the workspace (see `scanWorkspace` -
|
|
75
|
+
* the root plus every workspace package, `.gitignore`- and build-output-aware) containing the
|
|
76
|
+
* Tailwind v4 marker `@import "tailwindcss"`.
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
function findTailwindEntries(ignores) {
|
|
80
|
+
return scanWorkspace("*.css", ignores).filter((file) => {
|
|
81
|
+
try {
|
|
82
|
+
return /@import\s+['"]tailwindcss['"]/.test(readFileSync(file, "utf-8"));
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Auto-find THE Tailwind v4 entry CSS ({@link findTailwindEntries} narrowed to exactly one).
|
|
90
|
+
*
|
|
91
|
+
* eslint-plugin-tailwindcss v4 loads the entry (`settings.tailwindcss.cssConfigPath`) and
|
|
92
|
+
* HARD-CRASHES with ENOENT when it can't, so the plugin is only enabled when exactly one entry is
|
|
93
|
+
* found (`allowMultiple: false` in the {@link tailwindGate} spec); with zero or several the
|
|
94
|
+
* consumer must configure `cssConfigPath` manually (MANDATORY for the plugin; several candidates
|
|
95
|
+
* are a hard error) - see README "Detection".
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
function findTailwindEntry(ignores) {
|
|
99
|
+
const entries = findTailwindEntries(ignores);
|
|
100
|
+
return entries.length === 1 ? entries[0] : null;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Tailwind: `null` when off, otherwise the entry CSS (in the consumer's own notation when given) and the absolute
|
|
104
|
+
* directory of the one package to scope the rules to (`null` = the whole workspace).
|
|
105
|
+
*/
|
|
106
|
+
function tailwindGate(option, strict = false) {
|
|
107
|
+
const { enabled, options, files } = toolGate(option, strict, {
|
|
108
|
+
tool: "tailwind",
|
|
109
|
+
has: hasTailwind,
|
|
110
|
+
packageName: "tailwindcss",
|
|
111
|
+
needs: {
|
|
112
|
+
what: "entry CSS",
|
|
113
|
+
detail: "single Tailwind v4 entry CSS (a *.css containing `@import \"tailwindcss\"`, scanned across the workspace root and every workspace package)",
|
|
114
|
+
hint: "`tailwind: { cssConfigPath }`"
|
|
115
|
+
},
|
|
116
|
+
allowMultiple: false,
|
|
117
|
+
absolutizeOptions: ({ cssConfigPath }) => cssConfigPath ? [isAbsolute(cssConfigPath) ? cssConfigPath : resolve(findWorkspaceRoot(), cssConfigPath)] : [],
|
|
118
|
+
scan: () => findTailwindEntries(GLOBAL_IGNORES)
|
|
119
|
+
});
|
|
120
|
+
if (!enabled) return null;
|
|
121
|
+
const cssConfigPath = options.cssConfigPath ?? files[0];
|
|
122
|
+
const { scoped = true } = options;
|
|
123
|
+
const owner = scoped ? packageDirOf(files[0]) : null;
|
|
124
|
+
const packageDir = owner && owner !== findWorkspaceRoot() ? owner : null;
|
|
125
|
+
return {
|
|
126
|
+
cssConfigPath,
|
|
127
|
+
absoluteCssConfigPath: files[0],
|
|
128
|
+
packageDir
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { findTailwindEntry, jestGate, nextGate, nxGate, storybookGate, tailwindGate, turboGate, vitestGate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,70 +1,34 @@
|
|
|
1
|
+
import { eslintExts, eslintExtsRaw, markupExtsRaw, prettierExts, prettierExtsRaw, tsExts, tsExtsRaw } from "./exts.js";
|
|
2
|
+
import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
|
|
3
|
+
import { DEFAULT_LINT_CONFIG, DefaultIgnoreOptions, DetectionOptions, EslintOptions, LINT_CONFIG_FILE, LintConfig, NextOptions, SkillSourceOptions, SkillsConfig, TailwindOptions, ToggleOptions, TypeAwareOptions, VitePlusOptions, defineLintConfig, loadLintConfig, mergeLintConfig, resolveLintConfig } from "./config.js";
|
|
4
|
+
import { baseConfig, defaultIgnoreConfig, includeIgnoreFile } from "./configs/base.js";
|
|
1
5
|
import { importSortConfig, importXConfig, unusedImportsConfig } from "./configs/imports.js";
|
|
2
|
-
import { nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, reactBaseConfig, reactConfig, reactSettingsConfig, typescriptOverridesConfig } from "./configs/react.js";
|
|
3
6
|
import { nxConfig, nxPlugin } from "./configs/nx.js";
|
|
4
7
|
import { prettierConfig } from "./configs/prettier.js";
|
|
5
8
|
import { promiseConfig } from "./configs/promise.js";
|
|
9
|
+
import { nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, reactBaseConfig, reactConfig, reactSettingsConfig, typescriptOverridesConfig } from "./configs/react.js";
|
|
6
10
|
import { storybookConfig } from "./configs/storybook.js";
|
|
7
|
-
import { findTailwindEntry,
|
|
11
|
+
import { findTailwindEntry, jestGate, nextGate, nxGate, storybookGate, tailwindGate, turboGate, vitestGate } from "./gates.js";
|
|
12
|
+
import { tailwindConfig } from "./configs/tailwind.js";
|
|
8
13
|
import { jestConfig, jestPlugin, testConfig, vitestConfig, vitestPlugin } from "./configs/testing.js";
|
|
9
14
|
import { turboConfig, turboPlugin } from "./configs/turbo.js";
|
|
10
15
|
import { typeAwareConfig } from "./configs/typescriptTypeAware.js";
|
|
11
16
|
import { unicornConfig } from "./configs/unicorn.js";
|
|
12
|
-
import { eslintExts, eslintExtsRaw, markupExtsRaw, prettierExts, prettierExtsRaw, tsExts, tsExtsRaw } from "./exts.js";
|
|
13
|
-
import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
|
|
14
17
|
import { Restriction, restrictions } from "./restrictions.js";
|
|
15
18
|
import { listStaged } from "./lintStaged.js";
|
|
16
19
|
import { prettier } from "./prettier.js";
|
|
17
|
-
import { baseConfig, defaultIgnoreConfig, includeIgnoreFile } from "./configs/base.js";
|
|
18
20
|
import { Linter } from "eslint";
|
|
19
|
-
import { ParserOptions } from "@typescript-eslint/parser";
|
|
20
|
-
import { PluginSettings } from "eslint-plugin-tailwindcss";
|
|
21
21
|
//#region src/index.d.ts
|
|
22
|
-
type ProjectServiceOptions = Exclude<NonNullable<ParserOptions['projectService']>, boolean>;
|
|
23
|
-
export type ToggleOptions = {
|
|
24
|
-
enabled?: boolean;
|
|
25
|
-
};
|
|
26
|
-
export type DetectionOptions = ToggleOptions & {
|
|
27
|
-
strict?: boolean;
|
|
28
|
-
};
|
|
29
|
-
export type NextOptions = ToggleOptions & {
|
|
30
|
-
rootDir?: string | string[];
|
|
31
|
-
};
|
|
32
|
-
export type TailwindOptions = ToggleOptions & {
|
|
33
|
-
cssConfigPath?: PluginSettings['cssConfigPath'];
|
|
34
|
-
scoped?: boolean;
|
|
35
|
-
};
|
|
36
|
-
export type TypeAwareOptions = ToggleOptions & Pick<ProjectServiceOptions, 'allowDefaultProject' | 'maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING'> & {
|
|
37
|
-
tsconfigRootDir?: ParserOptions['tsconfigRootDir'];
|
|
38
|
-
};
|
|
39
|
-
export type DefaultIgnoreOptions = {
|
|
40
|
-
enabled: false;
|
|
41
|
-
importMetaUrl?: string;
|
|
42
|
-
} | {
|
|
43
|
-
enabled?: true;
|
|
44
|
-
importMetaUrl: string;
|
|
45
|
-
};
|
|
46
|
-
export type LintOptions = {
|
|
47
|
-
detection?: boolean | DetectionOptions;
|
|
48
|
-
next?: boolean | NextOptions;
|
|
49
|
-
storybook?: boolean | ToggleOptions;
|
|
50
|
-
turbo?: boolean | ToggleOptions;
|
|
51
|
-
nx?: boolean | ToggleOptions;
|
|
52
|
-
jest?: boolean | ToggleOptions;
|
|
53
|
-
vitest?: boolean | ToggleOptions;
|
|
54
|
-
tailwind?: boolean | TailwindOptions;
|
|
55
|
-
typeAware?: boolean | TypeAwareOptions;
|
|
56
|
-
defaultIgnore?: boolean | DefaultIgnoreOptions;
|
|
57
|
-
};
|
|
58
22
|
/**
|
|
59
|
-
* Build the shared flat ESLint config.
|
|
60
|
-
*
|
|
61
|
-
* By default every tool integration is auto-detected (see the `has*` exports); pass
|
|
62
|
-
* {@link LintOptions} to force any of them on/off or to supply tool-specific settings.
|
|
23
|
+
* Build the shared flat ESLint config from the workspace root `lint.config.ts` (see `defineLintConfig`), with
|
|
24
|
+
* `overrides` merged over it - per-package differences in a monorepo go here.
|
|
63
25
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
26
|
+
* By default every tool integration is auto-detected (see the `has*` exports); the config forces any of them on/off or
|
|
27
|
+
* supplies tool-specific settings.
|
|
66
28
|
*
|
|
29
|
+
* Returns a Promise - ESLint natively awaits a Promise default export, so a plain `export default eslintConfig()`
|
|
30
|
+
* works; `await` it only when composing with extra blocks.
|
|
67
31
|
*/
|
|
68
|
-
export declare function
|
|
32
|
+
export declare function eslintConfig(overrides?: LintConfig): Promise<Linter.Config[]>;
|
|
69
33
|
//#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, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestPlugin };
|
|
34
|
+
export { DEFAULT_LINT_CONFIG, DefaultIgnoreOptions, DetectionOptions, EslintOptions, GLOBAL_IGNORES, LINT_CONFIG_FILE, LintConfig, NextOptions, Restriction, SkillSourceOptions, SkillsConfig, TailwindOptions, ToggleOptions, TypeAwareOptions, VitePlusOptions, asOptions, baseConfig, defaultIgnoreConfig, defineLintConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestGate, jestPlugin, listStaged, loadLintConfig, markupExtsRaw, mergeLintConfig, nextBaseConfig, nextConfig, nextGate, nextOverridesConfig, nextPlugin, nxConfig, nxGate, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, resolveLintConfig, restrictions, scanWorkspace, storybookConfig, storybookGate, tailwindConfig, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboGate, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestGate, vitestPlugin };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { eslintExts, eslintExtsRaw, markupExtsRaw, prettierExts, prettierExtsRaw, tsExts, tsExtsRaw } from "./exts.js";
|
|
2
1
|
import { GLOBAL_IGNORES, asOptions, findNextRoots, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, isPackageResolvable, packageDirOf, scanWorkspace, toolGate } from "./lib.js";
|
|
2
|
+
import { eslintExts, eslintExtsRaw, markupExtsRaw, prettierExts, prettierExtsRaw, tsExts, tsExtsRaw } from "./exts.js";
|
|
3
|
+
import { DEFAULT_LINT_CONFIG, LINT_CONFIG_FILE, defineLintConfig, loadLintConfig, mergeLintConfig, resolveLintConfig } from "./config.js";
|
|
4
|
+
import { findTailwindEntry, jestGate, nextGate, nxGate, storybookGate, tailwindGate, turboGate, vitestGate } from "./gates.js";
|
|
3
5
|
import { baseConfig, defaultIgnoreConfig, includeIgnoreFile } from "./configs/base.js";
|
|
4
6
|
import { importSortConfig, importXConfig, unusedImportsConfig } from "./configs/imports.js";
|
|
5
7
|
import { nxConfig, nxPlugin } from "./configs/nx.js";
|
|
@@ -7,7 +9,7 @@ import { prettierConfig } from "./configs/prettier.js";
|
|
|
7
9
|
import { promiseConfig } from "./configs/promise.js";
|
|
8
10
|
import { nextBaseConfig, nextConfig, nextOverridesConfig, nextPlugin, reactBaseConfig, reactConfig, reactSettingsConfig, typescriptOverridesConfig } from "./configs/react.js";
|
|
9
11
|
import { storybookConfig } from "./configs/storybook.js";
|
|
10
|
-
import {
|
|
12
|
+
import { tailwindConfig } from "./configs/tailwind.js";
|
|
11
13
|
import { jestConfig, jestPlugin, testConfig, vitestConfig, vitestPlugin } from "./configs/testing.js";
|
|
12
14
|
import { turboConfig, turboPlugin } from "./configs/turbo.js";
|
|
13
15
|
import { typeAwareConfig } from "./configs/typescriptTypeAware.js";
|
|
@@ -17,27 +19,27 @@ import { listStaged } from "./lintStaged.js";
|
|
|
17
19
|
import { prettier } from "./prettier.js";
|
|
18
20
|
//#region src/index.ts
|
|
19
21
|
/**
|
|
20
|
-
* Build the shared flat ESLint config.
|
|
21
|
-
*
|
|
22
|
-
* By default every tool integration is auto-detected (see the `has*` exports); pass
|
|
23
|
-
* {@link LintOptions} to force any of them on/off or to supply tool-specific settings.
|
|
22
|
+
* Build the shared flat ESLint config from the workspace root `lint.config.ts` (see `defineLintConfig`), with
|
|
23
|
+
* `overrides` merged over it - per-package differences in a monorepo go here.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* By default every tool integration is auto-detected (see the `has*` exports); the config forces any of them on/off or
|
|
26
|
+
* supplies tool-specific settings.
|
|
27
27
|
*
|
|
28
|
+
* Returns a Promise - ESLint natively awaits a Promise default export, so a plain `export default eslintConfig()`
|
|
29
|
+
* works; `await` it only when composing with extra blocks.
|
|
28
30
|
*/
|
|
29
|
-
async function
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
async function eslintConfig(overrides = {}) {
|
|
32
|
+
const options = await resolveLintConfig(overrides);
|
|
33
|
+
const { typeAware, defaultIgnore } = options.eslint ?? {};
|
|
32
34
|
const { enabled: defaultOn = true, strict = false } = asOptions(options.detection);
|
|
33
35
|
const flag = (option) => option === void 0 && !defaultOn ? false : option;
|
|
34
36
|
return [
|
|
35
37
|
...baseConfig(),
|
|
36
|
-
...defaultIgnoreConfig(
|
|
38
|
+
...defaultIgnoreConfig(defaultIgnore),
|
|
37
39
|
...await reactConfig(flag(options.next), strict),
|
|
38
40
|
...prettierConfig(),
|
|
39
41
|
...await storybookConfig(flag(options.storybook), strict),
|
|
40
|
-
...typeAwareConfig(
|
|
42
|
+
...typeAwareConfig(typeAware, strict),
|
|
41
43
|
...importXConfig(),
|
|
42
44
|
...importSortConfig(),
|
|
43
45
|
...unusedImportsConfig(),
|
|
@@ -52,4 +54,4 @@ async function defineLintConfig(options = {}) {
|
|
|
52
54
|
];
|
|
53
55
|
}
|
|
54
56
|
//#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, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestPlugin };
|
|
57
|
+
export { DEFAULT_LINT_CONFIG, GLOBAL_IGNORES, LINT_CONFIG_FILE, asOptions, baseConfig, defaultIgnoreConfig, defineLintConfig, eslintConfig, eslintExts, eslintExtsRaw, findNextRoots, findTailwindEntry, findWorkspaceRoot, hasJest, hasNext, hasNx, hasStorybook, hasTailwind, hasTurbo, hasVite, hasVitest, importSortConfig, importXConfig, includeIgnoreFile, isPackageResolvable, jestConfig, jestGate, jestPlugin, listStaged, loadLintConfig, markupExtsRaw, mergeLintConfig, nextBaseConfig, nextConfig, nextGate, nextOverridesConfig, nextPlugin, nxConfig, nxGate, nxPlugin, packageDirOf, prettier, prettierConfig, prettierExts, prettierExtsRaw, promiseConfig, reactBaseConfig, reactConfig, reactSettingsConfig, resolveLintConfig, restrictions, scanWorkspace, storybookConfig, storybookGate, tailwindConfig, tailwindGate, testConfig, toolGate, tsExts, tsExtsRaw, turboConfig, turboGate, turboPlugin, typeAwareConfig, typescriptOverridesConfig, unicornConfig, unusedImportsConfig, vitestConfig, vitestGate, vitestPlugin };
|
package/dist/lib.d.ts
CHANGED
package/dist/lib.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
1
2
|
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
2
3
|
import { includeIgnoreFile } from "@eslint/config-helpers";
|
|
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";
|
package/dist/lintPrepare.d.ts
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
|
+
import { LintConfig, SkillsConfig } from "./config.js";
|
|
2
|
+
import { SpawnSyncOptions } from "node:child_process";
|
|
1
3
|
//#region src/lintPrepare.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* @kirill.konshin/lint
|
|
4
|
-
*
|
|
5
|
-
* This script makes `rules` and `skills` real directories in the consuming project's `.agents`
|
|
6
|
-
* (canonical, cross-tool, Codex reads it) and `.claude` (Claude Code), and symlinks the top-level
|
|
7
|
-
* entries it knows into them: package rule files and skill folders go into both, pointing straight at
|
|
8
|
-
* the installed package; the user's own `.agents` entries are mirrored into `.claude`. It also
|
|
9
|
-
* generates an `AGENTS.md` file for other tools, with `CLAUDE.md` symlinked to `AGENTS.md`.
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* lint-prepare init - Initialize AGENTS.md in the current directory (default)
|
|
13
|
-
* lint-prepare update - Force update AGENTS.md even if it exists
|
|
14
|
-
* lint-prepare - Same as init
|
|
15
|
-
*
|
|
16
|
-
* The module also exports its functions and only runs `main()` when executed directly,
|
|
17
|
-
* so it can be imported (for testing/reuse) without side effects.
|
|
18
|
-
*/
|
|
19
4
|
/**
|
|
20
5
|
* A rule file. `paths` scopes it: Claude Code loads it only for matching files.
|
|
21
6
|
*/
|
|
@@ -34,6 +19,13 @@ type ExistingFile = {
|
|
|
34
19
|
generated: boolean;
|
|
35
20
|
customSection: string | null;
|
|
36
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* The part of `spawnSync` runSkillsSync() uses.
|
|
24
|
+
*/
|
|
25
|
+
export type RunCommand = (command: string, args: string[], options: SpawnSyncOptions) => {
|
|
26
|
+
status: number | null;
|
|
27
|
+
error?: Error;
|
|
28
|
+
};
|
|
37
29
|
/**
|
|
38
30
|
* Read all markdown files from the package rules directory.
|
|
39
31
|
*/
|
|
@@ -44,22 +36,77 @@ export declare function readRules(): Rule[];
|
|
|
44
36
|
*/
|
|
45
37
|
export declare function readSkills(): Skill[];
|
|
46
38
|
/**
|
|
47
|
-
* Package entries to link, keyed by their path inside an agent dir: every rule file as `rules/<file
|
|
48
|
-
*
|
|
39
|
+
* Package entries to link, keyed by their path inside an agent dir: every rule file as `rules/<file>`. Package skills
|
|
40
|
+
* are not linked here: the `skills` CLI installs them (runSkillsSync()).
|
|
41
|
+
*/
|
|
42
|
+
export declare function packageEntries(rules: Rule[]): Map<string, string>;
|
|
43
|
+
/**
|
|
44
|
+
* The directory the `skills` CLI installs a skill into: its name sanitized as the CLI does it (`sanitizeName`), so
|
|
45
|
+
* `model-redux-state/design-state-ownership` lives in `model-redux-state-design-state-ownership`.
|
|
46
|
+
*/
|
|
47
|
+
export declare const skillDirName: (name: string) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Directory names of the skills the `skills` CLI installed, from its `skills-lock.json` in cwd; empty when there is
|
|
50
|
+
* none.
|
|
49
51
|
*/
|
|
50
|
-
export declare function
|
|
52
|
+
export declare function readSyncedSkills(cwd: string): Set<string>;
|
|
51
53
|
/**
|
|
52
54
|
* The user's own top-level entries in `.agents/rules` and `.agents/skills`, keyed like packageEntries() - everything
|
|
53
|
-
* there except the links this tool placed (its generated `.gitignore` lists them),
|
|
55
|
+
* there except the links this tool placed (its generated `.gitignore` lists them), the skills the `skills` CLI
|
|
56
|
+
* installed, dead links and dotfiles.
|
|
54
57
|
*/
|
|
55
58
|
export declare function readUserEntries(cwd: string): Map<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* Install the skills dependencies ship (this package's own `skills/` folder among them) with the `skills` CLI, into
|
|
61
|
+
* `.agents/skills`, linked into `.claude/skills`. `exclude`: `package` or `package#skill` patterns to leave out. On CI
|
|
62
|
+
* nothing remote is touched (`--no-remote`). Returns whether the sync succeeded.
|
|
63
|
+
*/
|
|
64
|
+
export declare function runSkillsSync(cwd: string, run?: RunCommand, exclude?: string[]): boolean;
|
|
65
|
+
/** An npm package that ships skills (`@scope/name`, or a name without `/`); anything else is a git source. */
|
|
66
|
+
export declare const isNpmSkillSource: (source: string) => boolean;
|
|
67
|
+
/** A git source to install with `skills add`: the listed skills, or all of them (`*`) except `exclude`. */
|
|
68
|
+
export type RemoteSkills = {
|
|
69
|
+
source: string;
|
|
70
|
+
ref?: string;
|
|
71
|
+
skills: string[] | '*';
|
|
72
|
+
exclude: string[];
|
|
73
|
+
};
|
|
74
|
+
/** What `lint-prepare` does with the `skills` map of `lint.config.ts`. */
|
|
75
|
+
export type SkillsPlan = {
|
|
76
|
+
syncExclude: string[];
|
|
77
|
+
remote: RemoteSkills[];
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Names of the skills an installed npm package ships: `skills/<name>/SKILL.md` or `dist/skills/<name>/SKILL.md`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function readPackageSkills(cwd: string, packageName: string): string[];
|
|
83
|
+
/**
|
|
84
|
+
* Turn the `skills` map into CLI work. npm sources become `experimental_sync` exclusions: a disabled package, the
|
|
85
|
+
* `false` skills, or - when a package lists `true` skills - every other skill it ships. Enabled git sources become
|
|
86
|
+
* `skills add` work.
|
|
87
|
+
*/
|
|
88
|
+
export declare function planSkills(skills: SkillsConfig, packageSkills?: (packageName: string) => string[]): SkillsPlan;
|
|
89
|
+
/**
|
|
90
|
+
* Install the git sources of the plan with `skills add`, skipping a source whose skills the lock already has at the
|
|
91
|
+
* same ref, then remove what the plan no longer wants: `lint.config.ts` owns the remote skills of `skills-lock.json`
|
|
92
|
+
* (the ones no package `skills` field asked for). Nothing on CI: remote skills need the network.
|
|
93
|
+
*/
|
|
94
|
+
export declare function syncRemoteSkills(cwd: string, remote: RemoteSkills[], run?: RunCommand): void;
|
|
95
|
+
/** Package rules the `rules` map of `lint.config.ts` keeps. */
|
|
96
|
+
export declare function enabledRules(rules: Rule[], config: LintConfig): Rule[];
|
|
97
|
+
/**
|
|
98
|
+
* List the skills the `skills` CLI installed in the `.gitignore` of every agent `skills` dir: they stay out of git, and
|
|
99
|
+
* the links this tool placed keep their own list.
|
|
100
|
+
*/
|
|
101
|
+
export declare function recordSyncedSkills(cwd: string): void;
|
|
56
102
|
/**
|
|
57
103
|
* Make `rules` and `skills` real directories in every agent dir and link the top-level entries we know into them:
|
|
58
|
-
* package rule files
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* directory's generated `.gitignore` records them (and keeps them out of git, so the user's own
|
|
62
|
-
* tracked)
|
|
104
|
+
* package rule files into both, pointing straight at the package, the user's own `.agents` entries into `.claude`.
|
|
105
|
+
* A real entry is the user's - never written over or through. Dead links are removed, and so are links from the
|
|
106
|
+
* previous run that are no longer placed (incl. the package skill links of older versions, so the `skills` CLI can
|
|
107
|
+
* place its own): each directory's generated `.gitignore` records them (and keeps them out of git, so the user's own
|
|
108
|
+
* entries there stay tracked); the skills the `skills` CLI installed are listed there too, but never cleaned up. The
|
|
109
|
+
* `commands` directories older versions synced are cleaned up the same way, `.codex` is not touched.
|
|
63
110
|
*
|
|
64
111
|
* FIXME Codex Includes
|
|
65
112
|
* https://github.com/openai/codex/issues/17401
|
|
@@ -91,7 +138,7 @@ export declare function symlinkClaudeMd(cwd: string): void;
|
|
|
91
138
|
* there) and honours each rule's `paths`, while an `@` import would load every rule into every session, scoped or not.
|
|
92
139
|
* Codex, which expands no `@`, reads this index.
|
|
93
140
|
*/
|
|
94
|
-
export declare function generateAgentsFile(rules: Rule[], customSection: string | null): string;
|
|
141
|
+
export declare function generateAgentsFile(rules: Rule[], customSection: string | null, previous?: string): string;
|
|
95
142
|
/**
|
|
96
143
|
* Check if AGENTS.md exists and was generated by this tool. When it was, also return
|
|
97
144
|
* whatever follows the marker (the user's custom section) so it can be carried forward -
|
|
@@ -102,6 +149,6 @@ export declare function checkExisting(targetPath: string): ExistingFile;
|
|
|
102
149
|
/**
|
|
103
150
|
* Main function
|
|
104
151
|
*/
|
|
105
|
-
export declare function main(): void
|
|
152
|
+
export declare function main(): Promise<void>;
|
|
106
153
|
//#endregion
|
|
107
154
|
export {};
|