@kirill.konshin/lint 0.8.8 → 0.8.10
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 +28 -6
- package/dist/config.d.ts +13 -0
- package/dist/config.js +7 -1
- package/dist/configs/base.js +2 -4
- package/dist/configs/nx.d.ts +3 -1
- package/dist/configs/nx.js +4 -4
- package/dist/configs/promise.js +2 -6
- package/dist/configs/react.d.ts +4 -2
- package/dist/configs/react.js +12 -31
- package/dist/configs/testing.js +32 -18
- package/dist/configs/turbo.d.ts +4 -3
- package/dist/configs/turbo.js +5 -7
- package/dist/configs/unicorn.js +2 -2
- package/dist/conventions.d.ts +26 -1
- package/dist/conventions.js +66 -1
- package/dist/exts.d.ts +3 -0
- package/dist/exts.js +4 -1
- package/dist/gates.d.ts +5 -5
- package/dist/gates.js +36 -24
- package/dist/graphify.d.ts +96 -0
- package/dist/graphify.js +255 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +8 -9
- package/dist/lib.d.ts +37 -21
- package/dist/lib.js +105 -71
- package/dist/lintPrepare.d.ts +13 -10
- package/dist/lintPrepare.js +52 -39
- package/dist/runCommand.d.ts +24 -0
- package/dist/runCommand.js +12 -0
- package/dist/textBlocks.d.ts +7 -0
- package/dist/textBlocks.js +12 -0
- package/dist/vitePlus.js +35 -68
- package/package.json +4 -1
- package/skills/spec-tools/scripts/cli.js +700 -627
package/dist/lintPrepare.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { asOptions, findWorkspaceRoot, workspaceDependsOn } from "./lib.js";
|
|
2
|
+
import { asOptions, detectionOf, findWorkspaceRoot, workspaceDependsOn } from "./lib.js";
|
|
3
3
|
import { LINT_CONFIG_FILE, resolveLintConfig } from "./config.js";
|
|
4
|
+
import { runOrWarn } from "./runCommand.js";
|
|
5
|
+
import { findBlock } from "./textBlocks.js";
|
|
6
|
+
import { GRAPHIFY_SECTION, GRAPHIFY_SKILL, finishGraphify, isGraphifySkill, setUpGraphify, writeGitignoreBlock } from "./graphify.js";
|
|
4
7
|
import { createRequire } from "node:module";
|
|
5
8
|
import fs from "node:fs";
|
|
6
9
|
import path from "node:path";
|
|
@@ -70,6 +73,7 @@ const GENERATED_MARKER = "<!-- @kirill.konshin/lint:generated -->";
|
|
|
70
73
|
* hand: this file only provides each anchor, a marker pair, on every generation, and keeps what the tool wrote between
|
|
71
74
|
* them. Vite+ fills its section on `vp config`, run right after `lint-prepare` in the same install script (it never
|
|
72
75
|
* creates a section, and its creating commands rewrite dependencies); Next.js on `next dev`, when it detects an agent.
|
|
76
|
+
* Sections of tools `lint.config.ts` turns on (graphify) are passed to generateAgentsFile().
|
|
73
77
|
*/
|
|
74
78
|
const TOOL_SECTIONS = [{
|
|
75
79
|
tool: "Vite+",
|
|
@@ -267,8 +271,12 @@ function readRules() {
|
|
|
267
271
|
* shipped with all its files (scripts, references, ...).
|
|
268
272
|
*/
|
|
269
273
|
function readSkills() {
|
|
270
|
-
|
|
271
|
-
|
|
274
|
+
return skillDirs(SKILLS_DIR).sort((a, b) => a.localeCompare(b)).map((name) => ({ name }));
|
|
275
|
+
}
|
|
276
|
+
/** The skills in `root`: every directory holding a `SKILL.md`, by name; none when `root` does not exist. */
|
|
277
|
+
function skillDirs(root) {
|
|
278
|
+
if (!fs.existsSync(root)) return [];
|
|
279
|
+
return fs.readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && fs.existsSync(path.join(root, entry.name, "SKILL.md"))).map((entry) => entry.name);
|
|
272
280
|
}
|
|
273
281
|
/**
|
|
274
282
|
* Package entries to link, keyed by their path inside an agent dir: every rule file as `rules/<file>`. Package skills
|
|
@@ -289,12 +297,7 @@ const skillDirName = (name) => name.toLowerCase().replace(/[^a-z0-9._]+/g, "-").
|
|
|
289
297
|
* none.
|
|
290
298
|
*/
|
|
291
299
|
function readSyncedSkills(cwd) {
|
|
292
|
-
|
|
293
|
-
const skills = JSON.parse(fs.readFileSync(path.join(cwd, SKILLS_LOCK), "utf-8"))?.skills;
|
|
294
|
-
return new Set(skills && typeof skills === "object" ? Object.keys(skills).map(skillDirName) : []);
|
|
295
|
-
} catch {
|
|
296
|
-
return /* @__PURE__ */ new Set();
|
|
297
|
-
}
|
|
300
|
+
return new Set(Object.keys(readSkillsLock(cwd)).map(skillDirName));
|
|
298
301
|
}
|
|
299
302
|
/**
|
|
300
303
|
* A symlink into `node_modules`: how the `skills` CLI links a package skill, before its lock lists it.
|
|
@@ -314,7 +317,7 @@ function readUserEntries(cwd) {
|
|
|
314
317
|
const own = manifestNames(root);
|
|
315
318
|
for (const name of fs.readdirSync(root)) {
|
|
316
319
|
const entry = path.join(root, name);
|
|
317
|
-
const isSynced = kind === "skills" && (synced
|
|
320
|
+
const isSynced = kind === "skills" && (isToolSkill(entry, synced) || isPackageLink(entry));
|
|
318
321
|
if (!name.startsWith(".") && !own.has(name) && !isSynced && fs.existsSync(entry)) entries.set(path.join(kind, name), entry);
|
|
319
322
|
}
|
|
320
323
|
}
|
|
@@ -327,17 +330,20 @@ function readUserEntries(cwd) {
|
|
|
327
330
|
function runSkillsCli(cwd, args, run) {
|
|
328
331
|
const manifestPath = createRequire(import.meta.url).resolve("skills/package.json");
|
|
329
332
|
const { bin } = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
333
|
+
return runOrWarn(run, {
|
|
334
|
+
command: process.execPath,
|
|
335
|
+
args: [path.join(path.dirname(manifestPath), bin.skills), ...args],
|
|
336
|
+
options: {
|
|
337
|
+
cwd,
|
|
338
|
+
stdio: "inherit",
|
|
339
|
+
env: {
|
|
340
|
+
DISABLE_TELEMETRY: "1",
|
|
341
|
+
...process.env
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
label: `skills ${args[0]}`,
|
|
345
|
+
what: "skills"
|
|
337
346
|
});
|
|
338
|
-
if (result.status === 0) return true;
|
|
339
|
-
console.warn(`[lint-prepare] skills ${args[0]} failed (${result.error?.message ?? `exit code ${result.status}`}), skills may be missing: re-run lint-prepare`);
|
|
340
|
-
return false;
|
|
341
347
|
}
|
|
342
348
|
/**
|
|
343
349
|
* Install the skills that the dependencies of the root and of every workspace package ship (this package's own
|
|
@@ -357,11 +363,7 @@ const isNpmSkillSource = (source) => source.startsWith("@") || !source.includes(
|
|
|
357
363
|
* Names of the skills an installed npm package ships: `skills/<name>/SKILL.md` or `dist/skills/<name>/SKILL.md`.
|
|
358
364
|
*/
|
|
359
365
|
function readPackageSkills(cwd, packageName) {
|
|
360
|
-
return ["skills", path.join("dist", "skills")].flatMap((dir) =>
|
|
361
|
-
const root = path.join(cwd, "node_modules", packageName, dir);
|
|
362
|
-
if (!fs.existsSync(root)) return [];
|
|
363
|
-
return fs.readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && fs.existsSync(path.join(root, entry.name, "SKILL.md"))).map((entry) => entry.name);
|
|
364
|
-
});
|
|
366
|
+
return ["skills", path.join("dist", "skills")].flatMap((dir) => skillDirs(path.join(cwd, "node_modules", packageName, dir)));
|
|
365
367
|
}
|
|
366
368
|
/**
|
|
367
369
|
* Turn the `skills` map into CLI work. A skill gated by a package name is on when `hasDependency` says the workspace
|
|
@@ -418,8 +420,9 @@ function syncRemoteSkills(cwd, remote, run = spawnSync) {
|
|
|
418
420
|
if (process.env.CI) return;
|
|
419
421
|
const own = (entry) => entry.sourceType !== "node_modules" && !entry.via;
|
|
420
422
|
const fromSource = (lock, { source, ref }) => Object.keys(lock).filter((name) => own(lock[name]) && lock[name].source === source && lock[name].ref === ref);
|
|
423
|
+
let lock = readSkillsLock(cwd);
|
|
421
424
|
for (const wanted of remote) {
|
|
422
|
-
const installed = fromSource(
|
|
425
|
+
const installed = fromSource(lock, wanted);
|
|
423
426
|
if (wanted.skills === "*" ? installed.length > 0 : wanted.skills.every((name) => installed.includes(name))) continue;
|
|
424
427
|
const skills = wanted.skills === "*" ? ["*"] : wanted.skills;
|
|
425
428
|
runSkillsCli(cwd, [
|
|
@@ -430,8 +433,8 @@ function syncRemoteSkills(cwd, remote, run = spawnSync) {
|
|
|
430
433
|
"--skill",
|
|
431
434
|
...skills
|
|
432
435
|
], run);
|
|
436
|
+
lock = readSkillsLock(cwd);
|
|
433
437
|
}
|
|
434
|
-
const lock = readSkillsLock(cwd);
|
|
435
438
|
const kept = new Set(remote.flatMap((wanted) => fromSource(lock, wanted).filter((name) => wanted.skills === "*" ? !wanted.exclude.includes(name) : wanted.skills.includes(name))));
|
|
436
439
|
const stale = Object.keys(lock).filter((name) => own(lock[name]) && !kept.has(name));
|
|
437
440
|
if (stale.length) runSkillsCli(cwd, [
|
|
@@ -445,18 +448,23 @@ function enabledRules(rules, config) {
|
|
|
445
448
|
return rules.filter((rule) => config.rules?.[rule.name] !== false);
|
|
446
449
|
}
|
|
447
450
|
/**
|
|
448
|
-
* List the skills the `skills` CLI installed in the `.gitignore` of every agent `skills` dir: they stay out
|
|
449
|
-
* the links this tool placed keep their own list.
|
|
451
|
+
* List the skills the `skills` CLI and graphify installed in the `.gitignore` of every agent `skills` dir: they stay out
|
|
452
|
+
* of git, and the links this tool placed keep their own list.
|
|
450
453
|
*/
|
|
451
454
|
function recordSyncedSkills(cwd) {
|
|
452
|
-
const synced =
|
|
455
|
+
const synced = readSyncedSkills(cwd);
|
|
453
456
|
for (const dir of AGENT_DIRS) {
|
|
454
457
|
const root = path.join(cwd, dir, "skills");
|
|
455
458
|
if (!lstat(root)?.isDirectory()) continue;
|
|
456
459
|
const gitignore = path.join(root, GITIGNORE);
|
|
457
|
-
writeManifest(gitignore, readManifest(gitignore), synced.filter((name) =>
|
|
460
|
+
writeManifest(gitignore, readManifest(gitignore), [.../* @__PURE__ */ new Set([...synced, GRAPHIFY_SKILL])].filter((name) => isToolSkill(path.join(root, name), synced)));
|
|
458
461
|
}
|
|
459
462
|
}
|
|
463
|
+
/** A skill a tool installed: the `skills` CLI (its lock lists it) or graphify (its stamp is inside). */
|
|
464
|
+
function isToolSkill(entry, synced) {
|
|
465
|
+
const name = path.basename(entry);
|
|
466
|
+
return !!lstat(entry) && (synced.has(name) || name === "graphify" && isGraphifySkill(entry));
|
|
467
|
+
}
|
|
460
468
|
/**
|
|
461
469
|
* Make `rules` and `skills` real directories in every agent dir and link the top-level entries we know into them:
|
|
462
470
|
* package rule files into both, pointing straight at the package, the user's own `.agents` entries into `.claude`.
|
|
@@ -538,19 +546,20 @@ function symlinkClaudeMd(cwd) {
|
|
|
538
546
|
*
|
|
539
547
|
* The links are plain, never `@path` imports: Claude Code loads `.claude/rules` itself (syncAgentDirs() links them
|
|
540
548
|
* there) and honours each rule's `paths`, while an `@` import would load every rule into every session, scoped or not.
|
|
541
|
-
* Codex, which expands no `@`, reads this index.
|
|
549
|
+
* Codex, which expands no `@`, reads this index. `toolSections` follow the sections of {@link TOOL_SECTIONS}.
|
|
542
550
|
*/
|
|
543
|
-
function generateAgentsFile(rules, customSection, previous = "") {
|
|
551
|
+
function generateAgentsFile(rules, customSection, previous = "", toolSections = []) {
|
|
544
552
|
const entries = rules.map((rule) => {
|
|
545
553
|
const rulePath = `${CANONICAL_AGENT_DIR}/rules/${rule.file}`;
|
|
546
554
|
const description = rule.description ? ` — ${rule.description}` : "";
|
|
547
555
|
const scope = rule.paths ? `; when touching ${rule.paths.map((glob) => `\`${glob}\``).join(", ")}` : "";
|
|
548
556
|
return `- **${toTitle(rule.name)}**${description}${scope}: [${rulePath}](${rulePath})`;
|
|
549
557
|
});
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
const
|
|
553
|
-
|
|
558
|
+
const lines = previous.split(/\r?\n/);
|
|
559
|
+
const sections = [...TOOL_SECTIONS, ...toolSections].map(({ start, end, tail }) => {
|
|
560
|
+
const block = findBlock(lines, start, end);
|
|
561
|
+
const kept = block ? lines.slice(block[0], block[1] + 1).join("\n") : `${start}\n${end}`;
|
|
562
|
+
return tail ? `${kept}\n\n${tail}` : kept;
|
|
554
563
|
});
|
|
555
564
|
const generated = `${HEADER}\n\n# Rules\n\n${entries.join("\n")}\n\n${sections.join("\n\n")}\n\n${FOOTER}\n\n${GENERATED_MARKER}`;
|
|
556
565
|
return customSection ? `${generated}\n\n${customSection}\n` : `${generated}\n`;
|
|
@@ -602,20 +611,24 @@ async function main() {
|
|
|
602
611
|
const config = await resolveLintConfig({}, root);
|
|
603
612
|
const rules = enabledRules(readRules(), config);
|
|
604
613
|
console.log(`Found ${rules.length} rule files: ${rules.map((r) => r.name).join(", ")}`);
|
|
614
|
+
const graphify = setUpGraphify(cwd, config.graphify, spawnSync);
|
|
615
|
+
writeGitignoreBlock(cwd, graphify.mode);
|
|
605
616
|
const userEntries = readUserEntries(cwd);
|
|
606
617
|
syncAgentDirs(cwd, packageEntries(rules), userEntries);
|
|
607
618
|
console.log(`Synced ${AGENT_DIRS.join(", ")}, mirrored ${userEntries.size} own entries from ${CANONICAL_AGENT_DIR}`);
|
|
608
|
-
const {
|
|
619
|
+
const { detect } = detectionOf(config);
|
|
609
620
|
const plan = planSkills(config.skills ?? {}, (packageName) => readPackageSkills(cwd, packageName), detect ? (packageName) => workspaceDependsOn(packageName, root) : void 0);
|
|
610
621
|
if (runSkillsSync(cwd, spawnSync, plan.syncExclude)) console.log(`Synced skills with the skills CLI, see ${SKILLS_LOCK}`);
|
|
611
622
|
syncRemoteSkills(cwd, plan.remote);
|
|
612
623
|
recordSyncedSkills(cwd);
|
|
613
624
|
const previous = exists ? fs.readFileSync(targetPath, "utf-8") : "";
|
|
614
|
-
const
|
|
625
|
+
const toolSections = graphify.mode === "venv" ? [GRAPHIFY_SECTION] : [];
|
|
626
|
+
const content = generateAgentsFile(installedRules(rules, userEntries), customSection, previous, toolSections);
|
|
615
627
|
fs.writeFileSync(targetPath, content, "utf-8");
|
|
616
628
|
console.log(`${exists ? "Updated" : "Created"} ${AGENTS_FILE}`);
|
|
617
629
|
symlinkClaudeMd(cwd);
|
|
618
630
|
console.log(`Symlinked ${CLAUDE_FILE} -> ${AGENTS_FILE}`);
|
|
631
|
+
finishGraphify(cwd, graphify, spawnSync);
|
|
619
632
|
return;
|
|
620
633
|
}
|
|
621
634
|
console.log(`Unknown command: ${command}`);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SpawnSyncOptions } from "node:child_process";
|
|
2
|
+
//#region src/runCommand.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The part of `spawnSync` `lint-prepare` uses to run the tools it drives (the `skills` CLI, uv, graphify); tests pass a
|
|
5
|
+
* stand-in.
|
|
6
|
+
*/
|
|
7
|
+
export type RunCommand = (command: string, args: string[], options: SpawnSyncOptions) => {
|
|
8
|
+
status: number | null;
|
|
9
|
+
error?: Error;
|
|
10
|
+
};
|
|
11
|
+
/** A command `lint-prepare` runs, named in its warning by `label`; `what` may be incomplete when it fails. */
|
|
12
|
+
type ToolRun = {
|
|
13
|
+
command: string;
|
|
14
|
+
args: string[];
|
|
15
|
+
options: SpawnSyncOptions;
|
|
16
|
+
label: string;
|
|
17
|
+
what: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Run a tool `lint-prepare` drives. A failure is a warning, the install goes on. Returns whether the command succeeded.
|
|
21
|
+
*/
|
|
22
|
+
export declare function runOrWarn(run: RunCommand, { command, args, options, label, what }: ToolRun): boolean;
|
|
23
|
+
//#endregion
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/runCommand.ts
|
|
2
|
+
/**
|
|
3
|
+
* Run a tool `lint-prepare` drives. A failure is a warning, the install goes on. Returns whether the command succeeded.
|
|
4
|
+
*/
|
|
5
|
+
function runOrWarn(run, { command, args, options, label, what }) {
|
|
6
|
+
const result = run(command, args, options);
|
|
7
|
+
if (result.status === 0) return true;
|
|
8
|
+
console.warn(`[lint-prepare] ${label} failed (${result.error?.message ?? `exit code ${result.status}`}), ${what} may be incomplete: re-run lint-prepare`);
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { runOrWarn };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/textBlocks.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The line range of a marked block in `lines`: the first line that is exactly `start`, through the first line after it
|
|
4
|
+
* that is exactly `end`. Undefined when either is missing.
|
|
5
|
+
*/
|
|
6
|
+
export declare function findBlock(lines: string[], start: string, end: string): [from: number, to: number] | undefined;
|
|
7
|
+
//#endregion
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/textBlocks.ts
|
|
2
|
+
/**
|
|
3
|
+
* The line range of a marked block in `lines`: the first line that is exactly `start`, through the first line after it
|
|
4
|
+
* that is exactly `end`. Undefined when either is missing.
|
|
5
|
+
*/
|
|
6
|
+
function findBlock(lines, start, end) {
|
|
7
|
+
const from = lines.indexOf(start);
|
|
8
|
+
const to = from === -1 ? -1 : lines.indexOf(end, from + 1);
|
|
9
|
+
return to === -1 ? void 0 : [from, to];
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { findBlock };
|
package/dist/vitePlus.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { GLOBAL_IGNORES, asOptions, findWorkspaceRoot } from "./lib.js";
|
|
2
|
-
import {
|
|
1
|
+
import { GLOBAL_IGNORES, asOptions, detectionOf, findWorkspaceRoot } from "./lib.js";
|
|
2
|
+
import { markupExtsRaw, prettierExtsRaw, testFiles, tsExts, tsExtsRaw, tsFiles } from "./exts.js";
|
|
3
3
|
import { resolveLintConfig } from "./config.js";
|
|
4
|
-
import { defaultExportFiles, filenameCaseIgnore } from "./conventions.js";
|
|
4
|
+
import { coreRules, declarationFileRules, defaultExportFiles, filenameCaseIgnore, nextRules, promiseRules, reactRules, testRunnerRules, typescriptRules, vitestRules } from "./conventions.js";
|
|
5
5
|
import { jestGate, nextGate, nxGate, storybookGate, tailwindGate, turboGate } from "./gates.js";
|
|
6
|
+
import { prettier } from "./prettier.js";
|
|
6
7
|
import { dirname, relative } from "node:path";
|
|
7
8
|
import { fileURLToPath } from "node:url";
|
|
8
9
|
//#region src/vitePlus.ts
|
|
9
|
-
const TS_FILES = `**/*.${tsExts}`;
|
|
10
|
-
const TEST_FILES = `**/*.{test,spec}.${tsExts}`;
|
|
11
10
|
/**
|
|
12
11
|
* Type-aware `correctness` rules of Oxlint 1.88 that stay off when `typeAware` is on. Tried on this monorepo they
|
|
13
12
|
* reported mostly noise (`act()` with sync callbacks, `for await` over sync iterables, unions with `any`); the
|
|
@@ -26,6 +25,14 @@ const TYPE_AWARE_CORRECTNESS_OFF = [
|
|
|
26
25
|
function pluginPath(specifier) {
|
|
27
26
|
return fileURLToPath(import.meta.resolve(specifier));
|
|
28
27
|
}
|
|
28
|
+
const OXLINT_PREFIXES = [["@typescript-eslint/", "typescript/"], ["@next/next/", "nextjs/"]];
|
|
29
|
+
/** Rules by their ESLint names, renamed for Oxlint. */
|
|
30
|
+
function oxlintRules(rules) {
|
|
31
|
+
return Object.fromEntries(Object.entries(rules).map(([name, setting]) => {
|
|
32
|
+
const prefix = OXLINT_PREFIXES.find(([eslint]) => name.startsWith(eslint));
|
|
33
|
+
return [prefix ? prefix[1] + name.slice(prefix[0].length) : name, setting];
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
29
36
|
/** A workspace-root-relative glob for an absolute directory (Oxlint override globs resolve from the config file). */
|
|
30
37
|
function workspaceGlob(dir, glob) {
|
|
31
38
|
const rel = relative(findWorkspaceRoot(), dir).replaceAll("\\", "/");
|
|
@@ -42,14 +49,13 @@ function workspaceGlob(dir, glob) {
|
|
|
42
49
|
* import autofix.
|
|
43
50
|
*/
|
|
44
51
|
function lintConfig(options = {}) {
|
|
45
|
-
const {
|
|
46
|
-
const flag = (option) => option === void 0 && !defaultOn ? false : option;
|
|
52
|
+
const { strict, flag } = detectionOf(options);
|
|
47
53
|
const next = nextGate(flag(options.next), strict, { requirePackage: false });
|
|
48
54
|
const storybook = storybookGate(flag(options.storybook), strict);
|
|
49
55
|
const turbo = turboGate(flag(options.turbo));
|
|
50
56
|
const nx = nxGate(flag(options.nx), strict, { packageName: "eslint" });
|
|
51
57
|
const jest = jestGate(flag(options.jest), strict);
|
|
52
|
-
const vitest = asOptions(flag(options.vitest)).enabled ??
|
|
58
|
+
const vitest = asOptions(flag(options.vitest)).enabled ?? !jest.enabled;
|
|
53
59
|
const tailwind = tailwindGate(flag(options.tailwind), strict);
|
|
54
60
|
const { enabled: typeAware = true } = asOptions(options.vitePlus?.typeAware);
|
|
55
61
|
const nextRootDir = next.enabled ? next.options.rootDir ?? (next.files.length > 0 ? next.files.map(dirname) : void 0) : void 0;
|
|
@@ -64,18 +70,14 @@ function lintConfig(options = {}) {
|
|
|
64
70
|
const overrides = [
|
|
65
71
|
{
|
|
66
72
|
files: ["**/*.d.ts"],
|
|
67
|
-
rules:
|
|
68
|
-
prefer: "type-imports",
|
|
69
|
-
fixStyle: "inline-type-imports",
|
|
70
|
-
disallowTypeAnnotations: false
|
|
71
|
-
}] }
|
|
73
|
+
rules: oxlintRules(declarationFileRules)
|
|
72
74
|
},
|
|
73
75
|
{
|
|
74
76
|
files: defaultExportFiles,
|
|
75
77
|
rules: { "import/no-default-export": "off" }
|
|
76
78
|
},
|
|
77
79
|
{
|
|
78
|
-
files: [
|
|
80
|
+
files: [testFiles],
|
|
79
81
|
plugins: [...vitest ? ["vitest"] : [], ...jest.enabled ? ["jest"] : []],
|
|
80
82
|
env: {
|
|
81
83
|
...vitest ? { vitest: true } : {},
|
|
@@ -83,21 +85,12 @@ function lintConfig(options = {}) {
|
|
|
83
85
|
},
|
|
84
86
|
rules: {
|
|
85
87
|
"local/test-colocation": "error",
|
|
86
|
-
...vitest ? {
|
|
87
|
-
"vitest
|
|
88
|
-
"vitest/no-disabled-tests": "warn",
|
|
88
|
+
...vitest ? oxlintRules({
|
|
89
|
+
...testRunnerRules("vitest"),
|
|
89
90
|
"vitest/require-mock-type-parameters": "off",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"expectTypeOf",
|
|
94
|
-
"assertType"
|
|
95
|
-
] }]
|
|
96
|
-
} : {},
|
|
97
|
-
...jest.enabled ? {
|
|
98
|
-
"jest/consistent-test-it": ["error", { fn: "test" }],
|
|
99
|
-
"jest/no-disabled-tests": "warn"
|
|
100
|
-
} : {}
|
|
91
|
+
...vitestRules
|
|
92
|
+
}) : {},
|
|
93
|
+
...jest.enabled ? oxlintRules(testRunnerRules("jest")) : {}
|
|
101
94
|
}
|
|
102
95
|
}
|
|
103
96
|
];
|
|
@@ -133,7 +126,7 @@ function lintConfig(options = {}) {
|
|
|
133
126
|
});
|
|
134
127
|
}
|
|
135
128
|
if (tailwind) overrides.push({
|
|
136
|
-
files: [tailwind.packageDir ? workspaceGlob(tailwind.packageDir,
|
|
129
|
+
files: [tailwind.packageDir ? workspaceGlob(tailwind.packageDir, tsFiles) : tsFiles],
|
|
137
130
|
jsPlugins: [{
|
|
138
131
|
name: "tailwindcss",
|
|
139
132
|
specifier: pluginPath("eslint-plugin-tailwindcss")
|
|
@@ -149,7 +142,7 @@ function lintConfig(options = {}) {
|
|
|
149
142
|
}
|
|
150
143
|
});
|
|
151
144
|
if (turbo.enabled) overrides.push({
|
|
152
|
-
files: [
|
|
145
|
+
files: [tsFiles],
|
|
153
146
|
jsPlugins: [{
|
|
154
147
|
name: "turbo",
|
|
155
148
|
specifier: pluginPath("eslint-plugin-turbo")
|
|
@@ -186,10 +179,7 @@ function lintConfig(options = {}) {
|
|
|
186
179
|
typeCheck: true
|
|
187
180
|
} } : {},
|
|
188
181
|
rules: {
|
|
189
|
-
|
|
190
|
-
name: "next/router",
|
|
191
|
-
message: "Please use next/navigation instead of next/router"
|
|
192
|
-
}] }],
|
|
182
|
+
...oxlintRules(coreRules),
|
|
193
183
|
"no-unused-vars": ["error", {
|
|
194
184
|
args: "none",
|
|
195
185
|
caughtErrors: "none",
|
|
@@ -206,22 +196,7 @@ function lintConfig(options = {}) {
|
|
|
206
196
|
"unicorn/no-empty-file": "off",
|
|
207
197
|
"jsx-a11y/prefer-tag-over-role": "off",
|
|
208
198
|
"typescript/no-useless-empty-export": "off",
|
|
209
|
-
|
|
210
|
-
"typescript/consistent-type-imports": ["error", {
|
|
211
|
-
prefer: "type-imports",
|
|
212
|
-
fixStyle: "inline-type-imports"
|
|
213
|
-
}],
|
|
214
|
-
"typescript/ban-ts-comment": ["error", {
|
|
215
|
-
"ts-expect-error": "allow-with-description",
|
|
216
|
-
"ts-ignore": true,
|
|
217
|
-
"ts-nocheck": true,
|
|
218
|
-
"ts-check": false,
|
|
219
|
-
minimumDescriptionLength: 3
|
|
220
|
-
}],
|
|
221
|
-
"typescript/prefer-as-const": "error",
|
|
222
|
-
"typescript/no-explicit-any": "off",
|
|
223
|
-
"typescript/no-empty-function": "off",
|
|
224
|
-
"typescript/no-require-imports": "off",
|
|
199
|
+
...oxlintRules(typescriptRules),
|
|
225
200
|
...typeAware ? {
|
|
226
201
|
"typescript/prefer-optional-chain": "warn",
|
|
227
202
|
"typescript/prefer-nullish-coalescing": "warn",
|
|
@@ -243,17 +218,10 @@ function lintConfig(options = {}) {
|
|
|
243
218
|
"react/set-state-in-render": "error",
|
|
244
219
|
"react/unsupported-syntax": "warn",
|
|
245
220
|
"react/react-in-jsx-scope": "off",
|
|
246
|
-
|
|
247
|
-
...next.enabled ? {
|
|
248
|
-
"nextjs/no-html-link-for-pages": "off",
|
|
249
|
-
"nextjs/no-img-element": "off"
|
|
250
|
-
} : {},
|
|
251
|
-
"import/no-anonymous-default-export": "off",
|
|
221
|
+
...oxlintRules(reactRules),
|
|
222
|
+
...next.enabled ? oxlintRules(nextRules) : {},
|
|
252
223
|
"import/no-default-export": "warn",
|
|
253
|
-
|
|
254
|
-
"promise/param-names": "off",
|
|
255
|
-
"promise/always-return": "off",
|
|
256
|
-
"promise/catch-or-return": "off",
|
|
224
|
+
...oxlintRules(promiseRules),
|
|
257
225
|
"unicorn/filename-case": ["error", {
|
|
258
226
|
case: "camelCase",
|
|
259
227
|
ignore: filenameCaseIgnore.map((regex) => regex.source)
|
|
@@ -272,11 +240,9 @@ function lintConfig(options = {}) {
|
|
|
272
240
|
* Markdown gets 200 columns; a wider table is HTML, or stays unaligned when it is mostly code (rules/markdown.md).
|
|
273
241
|
*/
|
|
274
242
|
function fmtConfig() {
|
|
243
|
+
const { overrides: prettierOverrides = [], ...prettierOptions } = prettier;
|
|
275
244
|
return {
|
|
276
|
-
|
|
277
|
-
tabWidth: 2,
|
|
278
|
-
singleQuote: true,
|
|
279
|
-
proseWrap: "never",
|
|
245
|
+
...prettierOptions,
|
|
280
246
|
insertFinalNewline: true,
|
|
281
247
|
sortPackageJson: false,
|
|
282
248
|
ignorePatterns: [
|
|
@@ -285,6 +251,7 @@ function fmtConfig() {
|
|
|
285
251
|
".yarn",
|
|
286
252
|
"/AGENTS.md",
|
|
287
253
|
"**/next-env.d.ts",
|
|
254
|
+
"**/graphify-out",
|
|
288
255
|
".agents/skills/openspec-*",
|
|
289
256
|
".claude/skills/openspec-*",
|
|
290
257
|
".claude/commands/opsx"
|
|
@@ -331,10 +298,10 @@ function fmtConfig() {
|
|
|
331
298
|
"unknown"
|
|
332
299
|
]
|
|
333
300
|
},
|
|
334
|
-
overrides: [{
|
|
335
|
-
files: [`**/${
|
|
336
|
-
options
|
|
337
|
-
}, {
|
|
301
|
+
overrides: [...prettierOverrides.map(({ files, options }) => ({
|
|
302
|
+
files: [files].flat().map((glob) => `**/${glob}`),
|
|
303
|
+
options
|
|
304
|
+
})), {
|
|
338
305
|
files: ["**/*.{md,mdx}"],
|
|
339
306
|
options: {
|
|
340
307
|
sortImports: false,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"keywords": [
|
|
5
5
|
"tanstack-intent"
|
|
6
6
|
],
|
|
7
|
-
"version": "0.8.
|
|
7
|
+
"version": "0.8.10",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"skipGenerate": true,
|
|
10
10
|
"bin": {
|
|
@@ -153,6 +153,9 @@
|
|
|
153
153
|
"optional": true
|
|
154
154
|
}
|
|
155
155
|
},
|
|
156
|
+
"engines": {
|
|
157
|
+
"uv": ">=0.11"
|
|
158
|
+
},
|
|
156
159
|
"publishConfig": {
|
|
157
160
|
"access": "public"
|
|
158
161
|
},
|