@milkenjoyer/toolchain 0.6.5 → 0.7.1
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 +0 -8
- package/dist/{effect-plugin-DARbVmA3.mjs → effect-plugin-Cee5222q.mjs} +64 -1
- package/dist/effect-plugin.mjs +1 -1
- package/dist/effect-tsgo.d.mts +1 -6
- package/dist/effect-tsgo.mjs +16 -8
- package/dist/exceptions.mjs +1 -14
- package/dist/guard.d.mts +0 -6
- package/dist/guard.mjs +19 -9
- package/dist/lint.d.mts +19 -4
- package/dist/lint.mjs +58 -49
- package/dist/plugin-DpJJbtFQ.mjs +264 -0
- package/dist/plugin.d.mts +0 -11
- package/dist/plugin.mjs +1 -1
- package/dist/rules.d.mts +91 -227
- package/dist/rules.mjs +94 -214
- package/dist/syntax-CGEOffZK.mjs +17 -0
- package/dist/versions.mjs +0 -6
- package/package.json +1 -10
- package/renovate.json +0 -1
- package/tsconfig.base.json +13 -1
- package/dist/array-method-C_XYdjLZ.mjs +0 -178
- package/dist/foldkit.d.mts +0 -3
- package/dist/foldkit.mjs +0 -17
- package/dist/plugin-CBUJ7Tgd.mjs +0 -927
- package/dist/rikalabs-hPKWFZ1P.mjs +0 -362
- package/dist/rikalabs.d.mts +0 -80
- package/dist/rikalabs.mjs +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
# Shared lint boundaries
|
|
2
|
-
|
|
3
|
-
Shared lint rules resolve imported Effect and runtime bindings through unchanged `const` identifier and member aliases. Mutable aliases, destructuring aliases and arbitrary wrapper return values do not establish runtime identity. A runtime boundary permits provision only as the direct first argument of genuine BunRuntime or NodeRuntime `runMain`, or as a direct operator in that argument's `.pipe`.
|
|
4
|
-
|
|
5
|
-
Raw Promise detection follows global `Promise`, `globalThis.Promise`, unchanged `const` and `let` Promise bindings, native Promise factories including `Promise.try`, global `fetch` calls and their unchanged `const` aliases, chains, `Promise<T>` bindings, and calls to local async or explicitly Promise-returning functions. It does not infer arbitrary library return types or object methods. Construction and each chain invocation report separately; a factory call alone does not report.
|
|
6
|
-
|
|
7
|
-
A runtime value import from exactly `vite-plus/test/browser` or `vitest/browser` establishes a browser execution target for Foldkit's server-global rule. Type imports, filenames, DOM compiler libraries, providers and configuration imports do not establish that target. Other Foldkit rules retain their upstream behavior.
|
|
8
|
-
|
|
9
1
|
# Configure pre-push hooks
|
|
10
2
|
|
|
11
3
|
A shared absolute Git hooks path must dispatch through the invoking worktree. `@milkenjoyer/toolchain/hooks` supplies `configurePrePush` to run native Vite+ setup and install that dispatcher as one operation.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { n as memberPropertyName } from "./syntax-CGEOffZK.mjs";
|
|
1
2
|
import * as Arr from "effect/Array";
|
|
2
3
|
import { pipe } from "effect/Function";
|
|
3
4
|
import * as HashSet from "effect/HashSet";
|
|
4
5
|
import * as Option from "effect/Option";
|
|
6
|
+
import * as R from "effect/Record";
|
|
5
7
|
import * as Schema from "effect/Schema";
|
|
6
8
|
import * as Str from "effect/String";
|
|
7
9
|
import { AST, Diagnostic, Plugin, Rule, RuleContext, Scope, SourceCode, Visitor } from "effect-oxlint";
|
|
@@ -3485,9 +3487,70 @@ const plugin$1 = Plugin.define({
|
|
|
3485
3487
|
specifier: "@mpsuesser/oxlint-plugin-effect",
|
|
3486
3488
|
rules
|
|
3487
3489
|
});
|
|
3490
|
+
// src/rules/use-temp-file-scoped.ts
|
|
3491
|
+
const isOs = (source) => source === "os" || source === "node:os";
|
|
3492
|
+
const isOsBinding = (source, node) => {
|
|
3493
|
+
const lookup = (scope) => {
|
|
3494
|
+
const variable = scope.set.get(node.name);
|
|
3495
|
+
if (variable === void 0) return scope.upper === null ? false : lookup(scope.upper);
|
|
3496
|
+
return Arr.some(variable.defs, (definition) => definition.type === "ImportBinding" && (definition.node.type === "ImportDefaultSpecifier" || definition.node.type === "ImportNamespaceSpecifier") && definition.parent?.type === "ImportDeclaration" && isOs(definition.parent.source.value));
|
|
3497
|
+
};
|
|
3498
|
+
return lookup(source.getScope(node));
|
|
3499
|
+
};
|
|
3500
|
+
const useTempFileScopedRule = Rule.define({
|
|
3501
|
+
name: "use-temp-file-scoped",
|
|
3502
|
+
meta: Rule.meta({
|
|
3503
|
+
type: "suggestion",
|
|
3504
|
+
description: "Prefer scoped temporary files and directories with automatic cleanup",
|
|
3505
|
+
messages: {
|
|
3506
|
+
tmpdir: "Avoid `os.tmpdir()` — use `FileSystem.makeTempFileScoped` from `@effect/platform` for scoped temp files with automatic cleanup.",
|
|
3507
|
+
unscoped: "Avoid `{{api}}` — the unscoped variant requires manual cleanup. Use `{{api}}Scoped` so the resource is finalized when its scope closes."
|
|
3508
|
+
}
|
|
3509
|
+
}),
|
|
3510
|
+
*create() {
|
|
3511
|
+
const context = yield* RuleContext;
|
|
3512
|
+
return {
|
|
3513
|
+
ImportDeclaration: (node) => node.type === "ImportDeclaration" && isOs(node.source.value) ? Effect.forEach(Arr.filter(node.specifiers, (specifier) => specifier.type === "ImportSpecifier" && (specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value) === "tmpdir"), (specifier) => context.report(Diagnostic.fromId({
|
|
3514
|
+
node: specifier,
|
|
3515
|
+
messageId: "tmpdir"
|
|
3516
|
+
})), {
|
|
3517
|
+
concurrency: 1,
|
|
3518
|
+
discard: true
|
|
3519
|
+
}) : Effect.void,
|
|
3520
|
+
MemberExpression: (node) => node.type === "MemberExpression" && Option.contains(memberPropertyName(node), "tmpdir") && node.object.type === "Identifier" && isOsBinding(context.sourceCode, node.object) ? context.report(Diagnostic.fromId({
|
|
3521
|
+
node,
|
|
3522
|
+
messageId: "tmpdir"
|
|
3523
|
+
})) : Effect.void,
|
|
3524
|
+
CallExpression: (node) => {
|
|
3525
|
+
if (node.type !== "CallExpression" || node.callee.type !== "MemberExpression") return Effect.void;
|
|
3526
|
+
return Option.match(Option.filter(memberPropertyName(node.callee), (name) => name === "makeTempFile" || name === "makeTempDirectory"), {
|
|
3527
|
+
onNone: () => Effect.void,
|
|
3528
|
+
onSome: (api) => context.report(Diagnostic.fromId({
|
|
3529
|
+
node,
|
|
3530
|
+
messageId: "unscoped",
|
|
3531
|
+
data: { api }
|
|
3532
|
+
}))
|
|
3533
|
+
});
|
|
3534
|
+
}
|
|
3535
|
+
};
|
|
3536
|
+
}
|
|
3537
|
+
});
|
|
3488
3538
|
// src/effect-plugin.ts
|
|
3539
|
+
const kept = [
|
|
3540
|
+
"avoid-mutable-state",
|
|
3541
|
+
"avoid-option-getorthrow",
|
|
3542
|
+
"effect-run-in-body",
|
|
3543
|
+
"no-chained-type-assertions",
|
|
3544
|
+
"no-module-mocking",
|
|
3545
|
+
"prefer-redacted-config",
|
|
3546
|
+
"require-effect-concurrency",
|
|
3547
|
+
"throw-in-effect-gen"
|
|
3548
|
+
];
|
|
3489
3549
|
const plugin = {
|
|
3490
3550
|
meta: plugin$1.meta,
|
|
3491
|
-
rules:
|
|
3551
|
+
rules: {
|
|
3552
|
+
...R.filter(plugin$1.rules, (_rule, name) => kept.includes(name)),
|
|
3553
|
+
"use-temp-file-scoped": useTempFileScopedRule
|
|
3554
|
+
}
|
|
3492
3555
|
};
|
|
3493
3556
|
export { plugin as t };
|
package/dist/effect-plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./effect-plugin-
|
|
1
|
+
export { t as default } from "./effect-plugin-Cee5222q.mjs";
|
package/dist/effect-tsgo.d.mts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export declare const patchCommand = "effect-tsgo patch --oxlint";
|
|
2
2
|
export declare const effectTsgoPlugin = "effecttsgo";
|
|
3
|
-
export
|
|
4
|
-
readonly issue: string;
|
|
5
|
-
readonly rules: ReadonlyArray<string>;
|
|
6
|
-
};
|
|
7
|
-
export declare const held: HeldRules;
|
|
8
|
-
export declare const effectTsgoCatalog: ReadonlyArray<string>;
|
|
3
|
+
export declare const disabledRecommendedTsgoRules: ReadonlyArray<string>;
|
|
9
4
|
export declare const enforcedTsgoRules: ReadonlyArray<string>;
|
|
10
5
|
export declare const effectTsgoRules: Readonly<Record<string, "error" | "off">>;
|
package/dist/effect-tsgo.mjs
CHANGED
|
@@ -6,11 +6,19 @@ import * as Struct from "effect/Struct";
|
|
|
6
6
|
// src/effect-tsgo.ts
|
|
7
7
|
const patchCommand = "effect-tsgo patch --oxlint";
|
|
8
8
|
const effectTsgoPlugin = "effecttsgo";
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
const beyondRecommended = [
|
|
10
|
+
"effecttsgo/any-unknown-in-error-context",
|
|
11
|
+
"effecttsgo/crypto-random-uuid-in-effect",
|
|
12
|
+
"effecttsgo/effect-try-without-catch",
|
|
13
|
+
"effecttsgo/global-date-in-effect",
|
|
14
|
+
"effecttsgo/global-fetch-in-effect",
|
|
15
|
+
"effecttsgo/global-json-in-effect",
|
|
16
|
+
"effecttsgo/global-random-in-effect",
|
|
17
|
+
"effecttsgo/global-timers-in-effect",
|
|
18
|
+
"effecttsgo/missing-effect-service-dependency",
|
|
19
|
+
"effecttsgo/unsafe-effect-type-assertion"
|
|
20
|
+
];
|
|
21
|
+
const disabledRecommendedTsgoRules = ["effecttsgo/return-effect-in-gen", "effecttsgo/layer-merge-all-with-dependencies"];
|
|
22
|
+
const enforcedTsgoRules = Arr.sort(Arr.dedupe([...Arr.filter(Struct.keys(presets.recommended.rules ?? {}), (rule) => !disabledRecommendedTsgoRules.includes(rule)), ...beyondRecommended]), Order.String);
|
|
23
|
+
const effectTsgoRules = R.fromEntries([...Arr.map(enforcedTsgoRules, (rule) => [rule, "error"]), ...Arr.map(disabledRecommendedTsgoRules, (rule) => [rule, "off"])]);
|
|
24
|
+
export { disabledRecommendedTsgoRules, effectTsgoPlugin, effectTsgoRules, enforcedTsgoRules, patchCommand };
|
package/dist/exceptions.mjs
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
1
|
// src/exceptions.ts
|
|
2
|
-
const exceptions = [
|
|
3
|
-
files: [
|
|
4
|
-
"packages/repo-lint/src/rules/import-allowlist.ts",
|
|
5
|
-
"packages/repo-lint/src/rules/no-test-clock-real-io.ts",
|
|
6
|
-
"packages/repo-lint/src/workspace-guard.config.ts",
|
|
7
|
-
"packages/repo-lint/tests/design-system.test.ts"
|
|
8
|
-
],
|
|
9
|
-
rules: ["effecttsgo/node-builtin-import"],
|
|
10
|
-
issue: "https://github.com/birbprophet/agent-kit/issues/171"
|
|
11
|
-
}, {
|
|
12
|
-
files: ["vite.config.ts"],
|
|
13
|
-
rules: ["effecttsgo/process-env"],
|
|
14
|
-
issue: "https://github.com/birbprophet/agent-kit/issues/171"
|
|
15
|
-
}];
|
|
2
|
+
const exceptions = [];
|
|
16
3
|
export { exceptions };
|
package/dist/guard.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Packuments } from "./compatible.mjs";
|
|
2
|
-
import { HeldRules } from "./effect-tsgo.mjs";
|
|
3
2
|
import { Exception } from "./exceptions.mjs";
|
|
4
3
|
import { Catalog } from "./versions.mjs";
|
|
5
4
|
import { OxlintConfig } from "vite-plus/lint";
|
|
@@ -20,11 +19,6 @@ export declare const ruleFindings: {
|
|
|
20
19
|
(config: OxlintConfig, list?: ReadonlyArray<Exception>): ReadonlyArray<string>;
|
|
21
20
|
};
|
|
22
21
|
export declare const exceptionFindings: (list?: ReadonlyArray<Exception>) => ReadonlyArray<string>;
|
|
23
|
-
export declare const heldFindings: {
|
|
24
|
-
(list?: undefined): ReadonlyArray<string>;
|
|
25
|
-
(catalog?: ReadonlyArray<string>): (list?: HeldRules) => ReadonlyArray<string>;
|
|
26
|
-
(list?: HeldRules, catalog?: ReadonlyArray<string>): ReadonlyArray<string>;
|
|
27
|
-
};
|
|
28
22
|
export declare const tagFindings: {
|
|
29
23
|
(registry: Packuments): (current: Catalog) => ReadonlyArray<string>;
|
|
30
24
|
(current: Catalog, registry: Packuments): ReadonlyArray<string>;
|
package/dist/guard.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { latestOf, onLatestLine, otherTags } from "./compatible.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { enforcedTsgoRules } from "./effect-tsgo.mjs";
|
|
3
3
|
import { exceptions } from "./exceptions.mjs";
|
|
4
|
-
import { birbprophetRules, effectRules,
|
|
5
|
-
import { n as rikalabsRules } from "./rikalabs-hPKWFZ1P.mjs";
|
|
4
|
+
import { birbprophetRules, effectRules, foldkitPreset, toolchainScopes } from "./lint.mjs";
|
|
6
5
|
import { lead, versionOf } from "./versions.mjs";
|
|
7
6
|
import * as Arr from "effect/Array";
|
|
8
7
|
import { dual } from "effect/Function";
|
|
@@ -88,14 +87,25 @@ const atError = (setting) => [
|
|
|
88
87
|
].includes(severityOf(setting));
|
|
89
88
|
const settingOf = (rules, rule) => Option.fromNullishOr(rules?.[rule]);
|
|
90
89
|
const guarded = [
|
|
91
|
-
...R.keys(
|
|
90
|
+
...R.keys(R.filter(foldkitPreset.rules, (setting) => setting === "error")),
|
|
92
91
|
...R.keys(effectRules),
|
|
93
92
|
...R.keys(birbprophetRules),
|
|
94
|
-
...R.keys(rikalabsRules),
|
|
95
93
|
...enforcedTsgoRules
|
|
96
94
|
];
|
|
97
|
-
const
|
|
98
|
-
|
|
95
|
+
const presetScopes = Arr.map([...foldkitPreset.overrides, ...toolchainScopes], ({ files, rules = {} }) => ({
|
|
96
|
+
files,
|
|
97
|
+
rules: R.keys(R.filter(rules, (setting) => setting === "off"))
|
|
98
|
+
}));
|
|
99
|
+
const scopedGuards = Arr.map(foldkitPreset.overrides, ({ files, excludeFiles = [], rules }) => ({
|
|
100
|
+
files,
|
|
101
|
+
excludeFiles,
|
|
102
|
+
rules: R.keys(R.filter(rules, (setting) => setting === "error"))
|
|
103
|
+
}));
|
|
104
|
+
const guardedInOverrides = Arr.dedupe([...guarded, ...Arr.flatMap(scopedGuards, ({ rules }) => rules)]);
|
|
105
|
+
const sameFiles = (files, other) => files.length === other.length && Arr.every(files, (file) => other.includes(file));
|
|
106
|
+
const excepted = (override, rule, list) => Arr.some([...presetScopes, ...list], (exception) => exception.rules.includes(rule) && sameFiles(override.files, exception.files));
|
|
107
|
+
const scopeFindings = (overrides) => Arr.flatMap(scopedGuards, ({ files, excludeFiles, rules }) => Arr.flatMap(rules, (rule) => Arr.some(overrides, (override) => sameFiles(override.files, files) && sameFiles(override.excludeFiles ?? [], excludeFiles) && Option.exists(settingOf(override.rules, rule), atError)) ? [] : [`${rule} is not at error for ${Arr.join(files, ", ")}`]));
|
|
108
|
+
const overrideFindings = (where, overrides, list) => Arr.flatMap(overrides, (override) => Arr.flatMap(guardedInOverrides, (rule) => Option.match(settingOf(override.rules, rule), {
|
|
99
109
|
onNone: () => [],
|
|
100
110
|
onSome: (setting) => atError(setting) || excepted(override, rule, list) ? [] : [`${where} override for ${Arr.join(override.files, ", ")} sets ${rule} to ${severityOf(setting)} outside a named-file exception`]
|
|
101
111
|
})));
|
|
@@ -109,6 +119,7 @@ const ruleFindings = dual((args) => args[0] !== void 0 && !Schema.is(Schema.Arra
|
|
|
109
119
|
onSome: (setting) => atError(setting) ? [] : [`${rule} is ${severityOf(setting)}`]
|
|
110
120
|
})),
|
|
111
121
|
...overrideFindings("the config's", overrides, list),
|
|
122
|
+
...scopeFindings(overrides),
|
|
112
123
|
...inheritedFindings("", config)
|
|
113
124
|
]);
|
|
114
125
|
const GLOB = /[*?[\]{}!]/u;
|
|
@@ -119,7 +130,6 @@ const exceptionFindings = (list = exceptions) => Arr.flatMap(list, (exception, i
|
|
|
119
130
|
...Arr.isReadonlyArrayEmpty(exception.rules) ? [`exception ${index} names no rule`] : [],
|
|
120
131
|
...ISSUE.test(exception.issue) ? [] : [`exception ${index} has no issue link: ${exception.issue}`]
|
|
121
132
|
]);
|
|
122
|
-
const heldFindings = dual((args) => !Schema.is(Schema.Array(Schema.Unknown))(args[0]), (list = held, catalog = effectTsgoCatalog) => [...ISSUE.test(list.issue) ? [] : [`the held @effect/tsgo rules have no issue link: ${list.issue}`], ...Arr.flatMap(list.rules, (rule) => catalog.includes(rule) ? [] : [`${rule} is held but is not in the @effect/tsgo catalog`])]);
|
|
123
133
|
const familyTagFindings = (registry, family) => Option.match(latestOf(registry, family), {
|
|
124
134
|
onNone: () => [`${lead(family)} has no latest tag in the registry record`],
|
|
125
135
|
onSome: (latest) => family.version === latest ? [] : Option.match(Arr.findFirst(otherTags(registry, family), ([, version]) => version === family.version), {
|
|
@@ -128,4 +138,4 @@ const familyTagFindings = (registry, family) => Option.match(latestOf(registry,
|
|
|
128
138
|
})
|
|
129
139
|
});
|
|
130
140
|
const tagFindings = dual(2, (current, registry) => Arr.flatMap(current.families, (family) => familyTagFindings(registry, family)));
|
|
131
|
-
export { exactFindings, exceptionFindings, foldkitViteFindings,
|
|
141
|
+
export { exactFindings, exceptionFindings, foldkitViteFindings, isFoldkitViteInput, manifestRanges, pinFindings, ruleFindings, tagFindings };
|
package/dist/lint.d.mts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import { OxlintConfig } from "vite-plus/lint";
|
|
1
|
+
import { OxlintConfig, OxlintOverride } from "vite-plus/lint";
|
|
2
2
|
export type LintOptions = {
|
|
3
3
|
readonly ignores?: ReadonlyArray<string>;
|
|
4
|
-
readonly domainPackages?: ReadonlyArray<string>;
|
|
5
4
|
};
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const foldkitPreset: {
|
|
6
|
+
readonly jsPlugins: readonly {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly specifier: string;
|
|
9
|
+
}[];
|
|
10
|
+
readonly rules: {
|
|
11
|
+
readonly [x: string]: "error" | "off";
|
|
12
|
+
};
|
|
13
|
+
readonly overrides: readonly {
|
|
14
|
+
readonly files: string[];
|
|
15
|
+
readonly excludeFiles?: string[];
|
|
16
|
+
readonly rules: {
|
|
17
|
+
readonly [x: string]: "error" | "off";
|
|
18
|
+
};
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
export declare const toolchainScopes: ReadonlyArray<OxlintOverride>;
|
|
7
22
|
export declare const effectRules: Record<string, "error">;
|
|
8
23
|
export declare const birbprophetRules: Record<string, "error">;
|
|
9
|
-
export declare const lint: ({ ignores
|
|
24
|
+
export declare const lint: ({ ignores }?: LintOptions) => OxlintConfig;
|
package/dist/lint.mjs
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { t as plugin } from "./effect-plugin-
|
|
1
|
+
import { t as plugin } from "./effect-plugin-Cee5222q.mjs";
|
|
2
2
|
import { effectTsgoPlugin, effectTsgoRules } from "./effect-tsgo.mjs";
|
|
3
3
|
import { exceptions } from "./exceptions.mjs";
|
|
4
|
-
import plugin$1 from "./
|
|
5
|
-
import { t as plugin$2 } from "./plugin-CBUJ7Tgd.mjs";
|
|
6
|
-
import { n as rikalabsRules, t as plugin$3 } from "./rikalabs-hPKWFZ1P.mjs";
|
|
4
|
+
import { t as plugin$1 } from "./plugin-DpJJbtFQ.mjs";
|
|
7
5
|
import { staticRules } from "./rules.mjs";
|
|
8
6
|
import * as Arr from "effect/Array";
|
|
9
|
-
import * as HashSet from "effect/HashSet";
|
|
10
7
|
import * as Option from "effect/Option";
|
|
11
8
|
import * as R from "effect/Record";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
12
10
|
import * as Str from "effect/String";
|
|
11
|
+
import foldkitRecommended from "@foldkit/oxlint-plugin/recommended.json" with { type: "json" };
|
|
13
12
|
import ultraciteCore from "ultracite/oxlint/core";
|
|
14
|
-
import ultraciteVitest from "ultracite/oxlint/vitest";
|
|
15
13
|
// src/lint.ts
|
|
16
14
|
const plugins = [
|
|
17
15
|
"typescript",
|
|
@@ -22,76 +20,84 @@ const plugins = [
|
|
|
22
20
|
"eslint",
|
|
23
21
|
"node",
|
|
24
22
|
"vitest",
|
|
25
|
-
"jsdoc",
|
|
26
23
|
effectTsgoPlugin
|
|
27
24
|
];
|
|
28
25
|
const categories = {
|
|
29
26
|
correctness: "error",
|
|
30
27
|
suspicious: "error",
|
|
31
|
-
pedantic: "
|
|
32
|
-
perf: "
|
|
33
|
-
style: "
|
|
28
|
+
pedantic: "off",
|
|
29
|
+
perf: "off",
|
|
30
|
+
style: "off",
|
|
34
31
|
restriction: "off",
|
|
35
32
|
nursery: "off"
|
|
36
33
|
};
|
|
34
|
+
const PresetRules = Schema.Record(Schema.String, Schema.Literals(["error", "off"]));
|
|
35
|
+
const Globs = Schema.mutable(Schema.Array(Schema.String));
|
|
36
|
+
const FoldkitPreset = Schema.Struct({
|
|
37
|
+
jsPlugins: Schema.Array(Schema.Struct({
|
|
38
|
+
name: Schema.String,
|
|
39
|
+
specifier: Schema.String
|
|
40
|
+
})),
|
|
41
|
+
rules: PresetRules,
|
|
42
|
+
overrides: Schema.Array(Schema.Struct({
|
|
43
|
+
files: Globs,
|
|
44
|
+
excludeFiles: Schema.optionalKey(Globs),
|
|
45
|
+
rules: PresetRules
|
|
46
|
+
}))
|
|
47
|
+
});
|
|
48
|
+
const foldkitPreset = Schema.decodeUnknownSync(FoldkitPreset)(foldkitRecommended);
|
|
49
|
+
const testFiles = [
|
|
50
|
+
"**/*.test.ts",
|
|
51
|
+
"**/*.test.tsx",
|
|
52
|
+
"**/*.spec.ts",
|
|
53
|
+
"**/*.spec.tsx",
|
|
54
|
+
"**/tests/**",
|
|
55
|
+
"**/test/**"
|
|
56
|
+
];
|
|
57
|
+
const toolchainScopes = [
|
|
58
|
+
{
|
|
59
|
+
files: ["**/*.astro"],
|
|
60
|
+
rules: { "unicorn/prefer-module": "off" }
|
|
61
|
+
},
|
|
62
|
+
...Arr.map(Arr.filter(foldkitPreset.overrides, (scope) => scope.files.includes("**/*.test.ts") && scope.excludeFiles === void 0), ({ rules }) => ({
|
|
63
|
+
files: ["**/tests/**", "**/test/**"],
|
|
64
|
+
rules
|
|
65
|
+
})),
|
|
66
|
+
{
|
|
67
|
+
files: testFiles,
|
|
68
|
+
rules: { "effecttsgo/any-unknown-in-error-context": "off" }
|
|
69
|
+
}
|
|
70
|
+
];
|
|
37
71
|
const atError = (prefix, rules) => R.fromEntries(Arr.map(rules, (rule) => [`${prefix}/${rule}`, "error"]));
|
|
38
|
-
const foldkitRules = atError(plugin$1.meta.name, R.keys(plugin$1.rules));
|
|
39
72
|
const effectRules = atError(plugin.meta.name, R.keys(plugin.rules));
|
|
40
|
-
const birbprophetRules = atError(plugin$
|
|
41
|
-
const offEverywhere = HashSet.fromIterable(Arr.flatMap(R.toEntries(staticRules), ([rule, setting]) => setting === "off" ? [rule] : []));
|
|
42
|
-
const { overrides: vitestOverrides = [] } = ultraciteVitest;
|
|
73
|
+
const birbprophetRules = atError(plugin$1.meta.name, R.keys(plugin$1.rules));
|
|
43
74
|
const { ignorePatterns: coreIgnores = [] } = ultraciteCore;
|
|
44
|
-
const vitestPreset = {
|
|
45
|
-
...ultraciteVitest,
|
|
46
|
-
overrides: Arr.map(vitestOverrides, ({ rules = {}, ...override }) => ({
|
|
47
|
-
...override,
|
|
48
|
-
rules: R.filter(rules, (_setting, rule) => !HashSet.has(offEverywhere, rule))
|
|
49
|
-
}))
|
|
50
|
-
};
|
|
51
75
|
const resolved = (specifier) => decodeURIComponent(new URL(import.meta.resolve(specifier)).pathname);
|
|
52
76
|
const ownExtension = Str.slice(Str.lastIndexOf(".")(import.meta.filename).pipe(Option.getOrElse(() => -1)))(import.meta.filename);
|
|
53
77
|
const sibling = (module) => resolved(`./${module}${ownExtension}`);
|
|
54
|
-
const domainTiers = (roots) => Arr.match(roots, {
|
|
55
|
-
onEmpty: () => [],
|
|
56
|
-
onNonEmpty: () => [{
|
|
57
|
-
files: Arr.map(roots, (root) => `${root}/src/**`),
|
|
58
|
-
rules: { "unicorn/filename-case": ["error", {
|
|
59
|
-
case: "pascalCase",
|
|
60
|
-
multipleFileExtensions: true
|
|
61
|
-
}] }
|
|
62
|
-
}, {
|
|
63
|
-
files: Arr.map(roots, (root) => `${root}/src/**/*.command.ts`),
|
|
64
|
-
rules: { "eslint/max-classes-per-file": "off" }
|
|
65
|
-
}]
|
|
66
|
-
});
|
|
67
78
|
const exceptionTier = (exception) => ({
|
|
68
79
|
files: [...exception.files],
|
|
69
80
|
rules: R.fromEntries(Arr.map(exception.rules, (rule) => [rule, "off"]))
|
|
70
81
|
});
|
|
71
|
-
const lint = ({ ignores = []
|
|
82
|
+
const lint = ({ ignores = [] } = {}) => ({
|
|
72
83
|
plugins,
|
|
73
84
|
categories,
|
|
74
|
-
extends: [ultraciteCore, vitestPreset],
|
|
75
85
|
jsPlugins: [
|
|
76
86
|
{
|
|
77
87
|
name: "vite-plus",
|
|
78
88
|
specifier: resolved("vite-plus/oxlint-plugin")
|
|
79
89
|
},
|
|
80
|
-
{
|
|
81
|
-
name
|
|
82
|
-
specifier:
|
|
83
|
-
},
|
|
90
|
+
...Arr.map(foldkitPreset.jsPlugins, ({ name, specifier }) => ({
|
|
91
|
+
name,
|
|
92
|
+
specifier: resolved(specifier)
|
|
93
|
+
})),
|
|
84
94
|
{
|
|
85
95
|
name: plugin.meta.name,
|
|
86
96
|
specifier: sibling("effect-plugin")
|
|
87
97
|
},
|
|
88
98
|
{
|
|
89
|
-
name: plugin$
|
|
99
|
+
name: plugin$1.meta.name,
|
|
90
100
|
specifier: sibling("plugin")
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: plugin$3.meta.name,
|
|
94
|
-
specifier: sibling("rikalabs")
|
|
95
101
|
}
|
|
96
102
|
],
|
|
97
103
|
options: {
|
|
@@ -99,15 +105,18 @@ const lint = ({ ignores = [], domainPackages = [] } = {}) => ({
|
|
|
99
105
|
typeCheck: true
|
|
100
106
|
},
|
|
101
107
|
rules: {
|
|
108
|
+
...foldkitPreset.rules,
|
|
102
109
|
...staticRules,
|
|
103
110
|
"vite-plus/prefer-vite-plus-imports": "error",
|
|
104
|
-
...foldkitRules,
|
|
105
111
|
...effectRules,
|
|
106
112
|
...birbprophetRules,
|
|
107
|
-
...rikalabsRules,
|
|
108
113
|
...effectTsgoRules
|
|
109
114
|
},
|
|
110
|
-
overrides: [
|
|
115
|
+
overrides: [
|
|
116
|
+
...foldkitPreset.overrides,
|
|
117
|
+
...toolchainScopes,
|
|
118
|
+
...Arr.map(exceptions, exceptionTier)
|
|
119
|
+
],
|
|
111
120
|
ignorePatterns: [...coreIgnores, ...ignores]
|
|
112
121
|
});
|
|
113
|
-
export { birbprophetRules, effectRules,
|
|
122
|
+
export { birbprophetRules, effectRules, foldkitPreset, lint, toolchainScopes };
|