@r_masseater/oxlint-plugin-decision 0.6.0 → 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 +15 -3
- package/dist/{src-CknkhDKf.mjs → app-UakaWKAT.mjs} +69 -209
- package/dist/app-UakaWKAT.mjs.map +1 -0
- package/dist/cloudflare-worker.mjs +5 -182
- package/dist/cloudflare-worker.mjs.map +1 -1
- package/dist/decision-B7hahWHz.mjs +561 -0
- package/dist/decision-B7hahWHz.mjs.map +1 -0
- package/dist/{presets-CxYinkkJ.mjs → define-presets-yflVt8vT.mjs} +197 -17
- package/dist/define-presets-yflVt8vT.mjs.map +1 -0
- package/dist/{index-DiH-hZUS.d.mts → index-C0Twu0w7.d.mts} +26 -33
- package/dist/index-HOwrGbIA.d.mts +89 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/preset-plugin-ClpEFUN5.mjs +10 -0
- package/dist/preset-plugin-ClpEFUN5.mjs.map +1 -0
- package/dist/presets/ai-slop.d.mts +3 -13
- package/dist/presets/ai-slop.mjs +3 -183
- package/dist/presets/ai-slop.mjs.map +1 -1
- package/dist/presets/index.d.mts +2 -78
- package/dist/presets/index.mjs +1 -1
- package/dist/presets/recommended.d.mts +1 -1
- package/dist/presets/recommended.mjs +3 -2
- package/dist/presets/recommended.mjs.map +1 -1
- package/dist/presets/review-only.d.mts +1 -1
- package/dist/presets/review-only.mjs +3 -2
- package/dist/presets/review-only.mjs.map +1 -1
- package/dist/presets/strict.d.mts +1 -1
- package/dist/presets/strict.mjs +3 -2
- package/dist/presets/strict.mjs.map +1 -1
- package/dist/serve-decisions-DYGwLMft.mjs +287 -0
- package/dist/serve-decisions-DYGwLMft.mjs.map +1 -0
- package/dist/typesafe-worker.mjs +11 -0
- package/dist/typesafe-worker.mjs.map +1 -0
- package/package.json +7 -12
- package/skills/write-decision-rules/SKILL.md +18 -17
- package/skills/write-decision-rules/references/tuning.md +1 -3
- package/dist/openrouter-app.d.mts +0 -15
- package/dist/openrouter-app.mjs +0 -89
- package/dist/openrouter-app.mjs.map +0 -1
- package/dist/openrouter-worker.mjs +0 -46
- package/dist/openrouter-worker.mjs.map +0 -1
- package/dist/presets-CxYinkkJ.mjs.map +0 -1
- package/dist/runtime-CICpEidL.mjs +0 -271
- package/dist/runtime-CICpEidL.mjs.map +0 -1
- package/dist/select-bvQylrUt.mjs +0 -12
- package/dist/select-bvQylrUt.mjs.map +0 -1
- package/dist/serve-decisions-BM0bUWWe.mjs +0 -119
- package/dist/serve-decisions-BM0bUWWe.mjs.map +0 -1
- package/dist/src-CknkhDKf.mjs.map +0 -1
- package/dist/wire-CRD1mSAo.mjs +0 -251
- package/dist/wire-CRD1mSAo.mjs.map +0 -1
- package/skills/write-decision-rules/references/providers.md +0 -55
- /package/dist/{openrouter-worker.d.mts → typesafe-worker.d.mts} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import { ChoiceQuestion, DecisionsRequest, DecisionsResponse, NoulQuestion } from "@effect/ai-openrouter/OpenRouterSchema";
|
|
1
|
+
import { Array as Array$1, Effect, Option, Result, Schema } from "effect";
|
|
3
2
|
//#endregion
|
|
4
3
|
//#region src-js/plugins/globals.d.ts
|
|
5
4
|
/**
|
|
@@ -3253,6 +3252,7 @@ interface Context extends FileContext {
|
|
|
3253
3252
|
*/
|
|
3254
3253
|
report(this: void, diagnostic: Diagnostic): void;
|
|
3255
3254
|
}
|
|
3255
|
+
type DecisionModel = "typesafe/jev-latest" | `typesafe/jev-${number}.${number}` | "cloudflare/@cf/cloudflare/clef" | "cloudflare/@cf/cloudflare/clef-flash" | "cloudflare/@cf/cloudflare/clef-omni";
|
|
3256
3256
|
declare const TargetSchema: Schema.Literals<readonly ["function", "call", "jsx", "file"]>;
|
|
3257
3257
|
declare const CiBehaviorSchema: Schema.Literals<readonly ["skip", "fail"]>;
|
|
3258
3258
|
declare const ExplainSettingSchema: Schema.Union<readonly [Schema.Boolean, Schema.Literals<readonly ["text", "json"]>]>;
|
|
@@ -3286,7 +3286,7 @@ interface SelectMatch {
|
|
|
3286
3286
|
}
|
|
3287
3287
|
type Target = typeof TargetSchema.Type;
|
|
3288
3288
|
type CiBehavior = typeof CiBehaviorSchema.Type;
|
|
3289
|
-
type ModelSpec =
|
|
3289
|
+
type ModelSpec = DecisionModel | readonly DecisionModel[];
|
|
3290
3290
|
type ExplainSetting = typeof ExplainSettingSchema.Type;
|
|
3291
3291
|
interface RuleLocation {
|
|
3292
3292
|
readonly question: string;
|
|
@@ -3316,46 +3316,42 @@ interface DecisionOptions {
|
|
|
3316
3316
|
readonly env?: Readonly<Record<string, string>>;
|
|
3317
3317
|
readonly explain?: ExplainSetting;
|
|
3318
3318
|
}
|
|
3319
|
-
interface NoulQuestion
|
|
3319
|
+
interface NoulQuestion {
|
|
3320
|
+
readonly type: "noul";
|
|
3320
3321
|
readonly instructions: string;
|
|
3321
3322
|
}
|
|
3322
|
-
interface ChoiceQuestion
|
|
3323
|
+
interface ChoiceQuestion {
|
|
3324
|
+
readonly type: "choice";
|
|
3323
3325
|
readonly instructions: string;
|
|
3324
3326
|
readonly criteria: Readonly<Record<string, string | null>>;
|
|
3325
3327
|
}
|
|
3326
|
-
type Question = NoulQuestion
|
|
3327
|
-
interface DecisionRequest
|
|
3328
|
+
type Question = NoulQuestion | ChoiceQuestion;
|
|
3329
|
+
interface DecisionRequest {
|
|
3330
|
+
readonly model: string;
|
|
3328
3331
|
readonly state: {
|
|
3329
3332
|
readonly snippets: Readonly<Record<string, string>>;
|
|
3330
3333
|
readonly contexts?: Readonly<Record<string, string>>;
|
|
3331
3334
|
};
|
|
3332
3335
|
readonly questions: Readonly<Record<string, Question>>;
|
|
3333
3336
|
}
|
|
3334
|
-
|
|
3335
|
-
type
|
|
3336
|
-
readonly
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
readonly
|
|
3341
|
-
readonly
|
|
3342
|
-
}
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
readonly
|
|
3347
|
-
|
|
3348
|
-
interface DecisionProvider {
|
|
3349
|
-
readonly name: string;
|
|
3350
|
-
readonly requiredEnv: readonly string[];
|
|
3351
|
-
readonly yesNo?: boolean;
|
|
3352
|
-
readonly decide: (input: DecideInput) => DecideResult;
|
|
3353
|
-
readonly decideAll?: (inputs: readonly DecideInput[]) => readonly DecideResult[];
|
|
3337
|
+
interface NoulAnswer {
|
|
3338
|
+
readonly type: "noul";
|
|
3339
|
+
readonly noul: number;
|
|
3340
|
+
}
|
|
3341
|
+
interface ChoiceAnswer {
|
|
3342
|
+
readonly type: "choice";
|
|
3343
|
+
readonly choice: string;
|
|
3344
|
+
readonly probabilities?: Readonly<Record<string, number>> | undefined;
|
|
3345
|
+
}
|
|
3346
|
+
type Answer = NoulAnswer | ChoiceAnswer;
|
|
3347
|
+
type Answers = Readonly<Record<string, Answer>>;
|
|
3348
|
+
interface DecisionResponse {
|
|
3349
|
+
readonly model: string;
|
|
3350
|
+
readonly answers: Answers;
|
|
3354
3351
|
}
|
|
3355
3352
|
interface DecisionPluginSetup extends DecisionOptions {
|
|
3356
3353
|
readonly name?: string;
|
|
3357
3354
|
readonly rules: readonly DecisionRule[];
|
|
3358
|
-
readonly providers?: readonly DecisionProvider[];
|
|
3359
3355
|
}
|
|
3360
3356
|
interface DecisionPlugin {
|
|
3361
3357
|
readonly meta: {
|
|
@@ -3364,9 +3360,6 @@ interface DecisionPlugin {
|
|
|
3364
3360
|
readonly rules: Readonly<Record<string, object>>;
|
|
3365
3361
|
}
|
|
3366
3362
|
declare const defineDecisionRule: <const Rule extends DecisionRule>(rule: Rule) => Rule;
|
|
3367
|
-
declare const defineProvider: <const Provider extends DecisionProvider>(provider: Provider) => Provider;
|
|
3368
|
-
declare const cloudflare: DecisionProvider;
|
|
3369
|
-
declare const openRouter: DecisionProvider;
|
|
3370
3363
|
declare const createDecisionPlugin: (setup: DecisionPluginSetup) => DecisionPlugin;
|
|
3371
|
-
export {
|
|
3372
|
-
//# sourceMappingURL=index-
|
|
3364
|
+
export { Target as C, Severity as S, RuleAnswer as _, DecisionOptions as a, SelectMatch as b, DecisionRequest as c, EnclosingKind as d, ExplainSetting as f, Question as g, NoulQuestion as h, CiBehavior as i, DecisionResponse as l, ModelSpec as m, defineDecisionRule as n, DecisionPlugin as o, Frozen as p, ChoiceQuestion as r, DecisionPluginSetup as s, createDecisionPlugin as t, DecisionRule as u, RuleContext as v, DecisionModel as w, SelectedNode as x, RuleLocation as y };
|
|
3365
|
+
//# sourceMappingURL=index-C0Twu0w7.d.mts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { b as SelectMatch, u as DecisionRule, x as SelectedNode } from "./index-C0Twu0w7.mjs";
|
|
2
|
+
declare const redundantGuard: DecisionRule;
|
|
3
|
+
declare const defaultMasksMissingValue: DecisionRule;
|
|
4
|
+
declare const passThroughWrapper: DecisionRule;
|
|
5
|
+
declare const placeholderImplementation: DecisionRule;
|
|
6
|
+
declare const commentRestatesCode: DecisionRule;
|
|
7
|
+
declare const commentNarratesHistory: DecisionRule;
|
|
8
|
+
declare const docRestatesSignature: DecisionRule;
|
|
9
|
+
declare const castInsteadOfNarrowing: DecisionRule;
|
|
10
|
+
declare const suppressionInsteadOfFix: DecisionRule;
|
|
11
|
+
declare const reinventsBuiltin: DecisionRule;
|
|
12
|
+
declare const aiSlopRules: readonly [DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule];
|
|
13
|
+
declare const fnNamePromises: DecisionRule;
|
|
14
|
+
declare const pureNameIsPure: DecisionRule;
|
|
15
|
+
declare const safeNameIsSafe: DecisionRule;
|
|
16
|
+
declare const idempotentName: DecisionRule;
|
|
17
|
+
declare const catchHidesFailure: DecisionRule;
|
|
18
|
+
declare const errorMessageMatchesCondition: DecisionRule;
|
|
19
|
+
declare const logLevelMatchesEvent: DecisionRule;
|
|
20
|
+
declare const logMessageMatchesEvent: DecisionRule;
|
|
21
|
+
declare const commentDescribesBlock: DecisionRule;
|
|
22
|
+
declare const commentDescribesDeclaration: DecisionRule;
|
|
23
|
+
declare const docErrorsMatchBody: DecisionRule;
|
|
24
|
+
declare const varNameDescribesValue: DecisionRule;
|
|
25
|
+
declare const codeClaims: readonly [DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule];
|
|
26
|
+
type Preset = readonly [DecisionRule, ...DecisionRule[]];
|
|
27
|
+
declare const recommended: Preset;
|
|
28
|
+
declare const strict: Preset;
|
|
29
|
+
declare const reviewOnly: Preset;
|
|
30
|
+
declare const presets: {
|
|
31
|
+
readonly recommended: Preset;
|
|
32
|
+
readonly strict: Preset;
|
|
33
|
+
readonly reviewOnly: Preset;
|
|
34
|
+
};
|
|
35
|
+
declare const noPiiInLogs: {
|
|
36
|
+
readonly id: "no-pii-in-logs";
|
|
37
|
+
readonly target: "call";
|
|
38
|
+
readonly question: "Does this call write personal data, such as an email or phone number, to a log or console?";
|
|
39
|
+
readonly cutoff: 0.8;
|
|
40
|
+
};
|
|
41
|
+
declare const noPromptInjection: {
|
|
42
|
+
readonly id: "no-prompt-injection";
|
|
43
|
+
readonly target: "function";
|
|
44
|
+
readonly question: "Does this function build a language model prompt by concatenating untrusted user input into the instructions?";
|
|
45
|
+
readonly cutoff: 0.8;
|
|
46
|
+
};
|
|
47
|
+
declare const noHardcodedSecrets: {
|
|
48
|
+
readonly id: "no-hardcoded-secrets";
|
|
49
|
+
readonly target: "file";
|
|
50
|
+
readonly question: "Does this file contain a hard-coded secret, such as an API key, password, or private token, as a literal value?";
|
|
51
|
+
readonly cutoff: 0.8;
|
|
52
|
+
};
|
|
53
|
+
declare const nameMatchesBehavior: {
|
|
54
|
+
readonly id: "name-matches-behavior";
|
|
55
|
+
readonly target: "function";
|
|
56
|
+
readonly select: (node: SelectedNode, match: SelectMatch) => boolean;
|
|
57
|
+
readonly question: "Does this function's name describe only reading or fetching data (for example get, find, load or fetch), while its body also changes or announces something on the side, such as writing to a database or file, logging, or sending a message? Sending the request that fetches the data, such as calling an API or a model and reading its answer, is the fetching itself and does not count.";
|
|
58
|
+
readonly cutoff: 0.8;
|
|
59
|
+
};
|
|
60
|
+
declare const untrustedInputRisk: {
|
|
61
|
+
readonly id: "untrusted-input-risk";
|
|
62
|
+
readonly target: "function";
|
|
63
|
+
readonly question: "Does this function splice untrusted input, such as a user message or request parameter, into the same string as a SQL query, shell command, eval code, HTML, or language model instructions, instead of passing it as a separate parameter or field? Count input as untrusted only when it comes from outside the program, such as a request, a user message, a form, or a file or response the program does not control; a parameter whose origin is not shown counts when its name or type marks it as user or request data. Text taken from the program's own rule definitions, settings, constants or cache is not untrusted, and JSON.parse is not eval.";
|
|
64
|
+
readonly cutoff: 0.8;
|
|
65
|
+
readonly answer: {
|
|
66
|
+
readonly kind: "severity";
|
|
67
|
+
readonly minimum: "warn";
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
declare const domainNaming: {
|
|
71
|
+
readonly id: "domain-naming";
|
|
72
|
+
readonly target: "function";
|
|
73
|
+
readonly question: "Is this function named after a mechanism word such as Manager, Processor, Handler, Helper, Data, Info, handle, process, or do, while its body works on one specific business concept, such as an invoice, an order, or a refund, that the name should call by its domain name instead? Code whose subject is a generic mechanism, such as HTTP, files, the command line, or framework glue, does not count.";
|
|
74
|
+
readonly cutoff: 0.8;
|
|
75
|
+
};
|
|
76
|
+
declare const preferSchemaValidation: {
|
|
77
|
+
readonly id: "prefer-schema-validation";
|
|
78
|
+
readonly target: "function";
|
|
79
|
+
readonly question: "Does this function check the shape or values of untyped data, such as parsed JSON, a request body, config, or an API response, with a long hand-written chain of typeof, instanceof, in, or field checks joined by && or ||, where a schema from a validation library would state the same rules more simply? A single simple check does not count.";
|
|
80
|
+
readonly cutoff: 0.8;
|
|
81
|
+
};
|
|
82
|
+
declare const describeNamesSubject: DecisionRule;
|
|
83
|
+
declare const testNameDescribesCode: DecisionRule;
|
|
84
|
+
declare const testNameVerifiesClaim: DecisionRule;
|
|
85
|
+
declare const snapshotOnlyBehaviourClaim: DecisionRule;
|
|
86
|
+
declare const testMocksSubject: DecisionRule;
|
|
87
|
+
declare const testClaims: readonly [DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule];
|
|
88
|
+
export { safeNameIsSafe as A, redundantGuard as B, docErrorsMatchBody as C, logLevelMatchesEvent as D, idempotentName as E, commentRestatesCode as F, suppressionInsteadOfFix as H, defaultMasksMissingValue as I, docRestatesSignature as L, aiSlopRules as M, castInsteadOfNarrowing as N, logMessageMatchesEvent as O, commentNarratesHistory as P, passThroughWrapper as R, commentDescribesDeclaration as S, fnNamePromises as T, reinventsBuiltin as V, reviewOnly as _, testNameDescribesCode as a, codeClaims as b, nameMatchesBehavior as c, noPromptInjection as d, preferSchemaValidation as f, recommended as g, presets as h, testMocksSubject as i, varNameDescribesValue as j, pureNameIsPure as k, noHardcodedSecrets as l, Preset as m, snapshotOnlyBehaviourClaim as n, testNameVerifiesClaim as o, untrustedInputRisk as p, testClaims as r, domainNaming as s, describeNamesSubject as t, noPiiInLogs as u, strict as v, errorMessageMatchesCondition as w, commentDescribesBlock as x, catchHidesFailure as y, placeholderImplementation as z };
|
|
89
|
+
//# sourceMappingURL=index-HOwrGbIA.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { type ChoiceQuestion, type CiBehavior, type
|
|
1
|
+
import { C as Target, S as Severity, _ as RuleAnswer, a as DecisionOptions, b as SelectMatch, c as DecisionRequest, d as EnclosingKind, f as ExplainSetting, g as Question, h as NoulQuestion, i as CiBehavior, l as DecisionResponse, m as ModelSpec, n as defineDecisionRule, o as DecisionPlugin, p as Frozen, r as ChoiceQuestion, s as DecisionPluginSetup, t as createDecisionPlugin, u as DecisionRule, v as RuleContext, w as DecisionModel, x as SelectedNode, y as RuleLocation } from "./index-C0Twu0w7.mjs";
|
|
2
|
+
export { type ChoiceQuestion, type CiBehavior, type DecisionModel, type DecisionOptions, type DecisionPlugin, type DecisionPluginSetup, type DecisionRequest, type DecisionResponse, type DecisionRule, type EnclosingKind, type ExplainSetting, type Frozen, type ModelSpec, type NoulQuestion, type Question, type RuleAnswer, type RuleContext, type RuleLocation, type SelectMatch, type SelectedNode, type Severity, type Target, createDecisionPlugin, defineDecisionRule };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { t as createDecisionPlugin, n as defineDecisionRule } from "./app-UakaWKAT.mjs";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as createDecisionPlugin } from "./app-UakaWKAT.mjs";
|
|
2
|
+
// src/app/preset-plugin.ts
|
|
3
|
+
const PLUGIN_NAME = "decision-presets";
|
|
4
|
+
const presetPlugin = (rules) => createDecisionPlugin({
|
|
5
|
+
name: PLUGIN_NAME,
|
|
6
|
+
rules
|
|
7
|
+
});
|
|
8
|
+
export { presetPlugin as t };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=preset-plugin-ClpEFUN5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-plugin-ClpEFUN5.mjs","names":[],"sources":["../src/app/preset-plugin.ts"],"sourcesContent":["import { createDecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\nimport type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport type { Preset } from \"#/features/define-presets/index.ts\";\n\nconst PLUGIN_NAME = \"decision-presets\";\n\nexport const presetPlugin = (rules: Preset): DecisionPlugin =>\n createDecisionPlugin({ name: PLUGIN_NAME, rules });\n"],"mappings":";;AAKA,MAAM,cAAc;AAEpB,MAAa,gBAAgB,UAC3B,qBAAqB;CAAE,MAAM;CAAa;AAAM,CAAC"}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const defaultMasksMissingValue: DecisionRule;
|
|
4
|
-
export declare const passThroughWrapper: DecisionRule;
|
|
5
|
-
export declare const placeholderImplementation: DecisionRule;
|
|
6
|
-
export declare const commentRestatesCode: DecisionRule;
|
|
7
|
-
export declare const commentNarratesHistory: DecisionRule;
|
|
8
|
-
export declare const docRestatesSignature: DecisionRule;
|
|
9
|
-
export declare const castInsteadOfNarrowing: DecisionRule;
|
|
10
|
-
export declare const suppressionInsteadOfFix: DecisionRule;
|
|
11
|
-
export declare const reinventsBuiltin: DecisionRule;
|
|
12
|
-
export declare const aiSlopRules: readonly [DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule];
|
|
1
|
+
import { o as DecisionPlugin } from "../index-C0Twu0w7.mjs";
|
|
2
|
+
import { B as redundantGuard, F as commentRestatesCode, H as suppressionInsteadOfFix, I as defaultMasksMissingValue, L as docRestatesSignature, M as aiSlopRules, N as castInsteadOfNarrowing, P as commentNarratesHistory, R as passThroughWrapper, V as reinventsBuiltin, z as placeholderImplementation } from "../index-HOwrGbIA.mjs";
|
|
13
3
|
declare const plugin: DecisionPlugin;
|
|
14
|
-
export { plugin as default };
|
|
4
|
+
export { aiSlopRules, castInsteadOfNarrowing, commentNarratesHistory, commentRestatesCode, plugin as default, defaultMasksMissingValue, docRestatesSignature, passThroughWrapper, placeholderImplementation, redundantGuard, reinventsBuiltin, suppressionInsteadOfFix };
|
|
15
5
|
//# sourceMappingURL=ai-slop.d.mts.map
|
package/dist/presets/ai-slop.mjs
CHANGED
|
@@ -1,186 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
// src/presets/ai-slop-select.ts
|
|
5
|
-
const isPlaceholderValue = ofType("Literal", "TemplateLiteral", "ArrayExpression", "ObjectExpression");
|
|
6
|
-
const isFallbackOperator = (node) => Match.value(node).pipe(Match.when({
|
|
7
|
-
type: "LogicalExpression",
|
|
8
|
-
operator: "??"
|
|
9
|
-
}, () => true), Match.when({
|
|
10
|
-
type: "LogicalExpression",
|
|
11
|
-
operator: "||"
|
|
12
|
-
}, (logical) => isPlaceholderValue(logical.right)), Match.when({
|
|
13
|
-
type: "AssignmentExpression",
|
|
14
|
-
operator: "??="
|
|
15
|
-
}, () => true), Match.when({
|
|
16
|
-
type: "AssignmentExpression",
|
|
17
|
-
operator: "||="
|
|
18
|
-
}, () => true), Match.orElse(() => false));
|
|
19
|
-
const isTypeofCheck = (node) => Match.value(node).pipe(Match.when({
|
|
20
|
-
type: "UnaryExpression",
|
|
21
|
-
operator: "typeof"
|
|
22
|
-
}, () => true), Match.orElse(() => false));
|
|
23
|
-
const isConstAssertion = (annotation) => Match.value(annotation).pipe(Match.when({
|
|
24
|
-
type: "TSTypeReference",
|
|
25
|
-
typeName: {
|
|
26
|
-
type: "Identifier",
|
|
27
|
-
name: "const"
|
|
28
|
-
}
|
|
29
|
-
}, () => true), Match.orElse(() => false));
|
|
30
|
-
const isCast = (node) => Match.value(node).pipe(Match.when({ type: "TSAsExpression" }, (cast) => !isConstAssertion(cast.typeAnnotation)), Match.when({ type: "TSTypeAssertion" }, () => true), Match.when({ type: "TSNonNullExpression" }, () => true), Match.orElse(() => false));
|
|
31
|
-
const bodyOf = (node) => Match.value(node).pipe(Match.when({ type: "FunctionDeclaration" }, (fn) => Option.fromNullishOr(fn.body)), Match.when({ type: "FunctionExpression" }, (fn) => Option.fromNullishOr(fn.body)), Match.when({ type: "ArrowFunctionExpression" }, (fn) => Option.some(fn.body)), Match.orElse(() => Option.none()));
|
|
32
|
-
const statementsOf = (body) => Match.value(body).pipe(Match.when({ type: "BlockStatement" }, (block) => block.body), Match.orElse((expression) => [expression]));
|
|
33
|
-
const ONE_STATEMENT = 1;
|
|
34
|
-
const isCall = ofType("CallExpression", "NewExpression");
|
|
35
|
-
const parentOf = (node) => Option.fromNullishOr(node.parent);
|
|
36
|
-
const isArgument = (node) => Option.exists(parentOf(node), isCall);
|
|
37
|
-
const isOptionOfCall = (node) => parentOf(node).pipe(Option.filter(ofType("Property")), Option.flatMap(parentOf), Option.filter(ofType("ObjectExpression")), Option.exists(isArgument));
|
|
38
|
-
const isCallback = Predicate.or(isArgument, isOptionOfCall);
|
|
39
|
-
const isDeclared = Predicate.not(isCallback);
|
|
40
|
-
const isShort = (node) => Option.exists(bodyOf(node), (body) => statementsOf(body).length <= ONE_STATEMENT);
|
|
41
|
-
const hasAtMostOneStatement = Predicate.and(isDeclared, isShort);
|
|
42
|
-
const expressionOf = (statement) => Match.value(statement).pipe(Match.when({ type: "ReturnStatement" }, (returned) => Option.fromNullishOr(returned.argument)), Match.when({ type: "ExpressionStatement" }, (expression) => Option.some(expression.expression)), Match.orElse((other) => Option.some(other)));
|
|
43
|
-
const awaitedOf = (expression) => Match.value(expression).pipe(Match.when({ type: "AwaitExpression" }, (awaited) => awaited.argument), Match.orElse((plain) => plain));
|
|
44
|
-
const isForwardingStatement = (statements) => Option.exists(Option.flatMap(Array.head(statements), expressionOf), (expression) => awaitedOf(expression).type === "CallExpression");
|
|
45
|
-
const isSingleCall = (node) => Option.exists(bodyOf(node), (body) => isForwardingStatement(statementsOf(body)));
|
|
46
|
-
const paramsOf = (node) => Match.value(node).pipe(Match.when({ type: "FunctionDeclaration" }, (fn) => fn.params), Match.when({ type: "FunctionExpression" }, (fn) => fn.params), Match.when({ type: "ArrowFunctionExpression" }, (fn) => fn.params), Match.orElse(() => []));
|
|
47
|
-
const nameOf = (node) => Match.value(node).pipe(Match.when({ type: "SpreadElement" }, (spread) => identifierOf(spread.argument)), Match.when({ type: "RestElement" }, (rest) => identifierOf(rest.argument)), Match.orElse((plain) => identifierOf(plain)));
|
|
48
|
-
const argumentsOf = (node) => bodyOf(node).pipe(Option.flatMap((body) => Array.head(statementsOf(body))), Option.flatMap(expressionOf), Option.map(awaitedOf), Option.flatMap((expression) => Match.value(expression).pipe(Match.when({ type: "CallExpression" }, (call) => Option.some(call.arguments)), Match.orElse(() => Option.none()))));
|
|
49
|
-
const isForwardedArgument = (names) => (argument) => Match.value(argument).pipe(Match.when({ type: "Literal" }, () => true), Match.orElse((other) => Option.exists(nameOf(other), (name) => names.includes(name))));
|
|
50
|
-
const passesExactly = (names) => Predicate.and((passed) => pipe(passed, Array.every((argument) => isForwardedArgument(names)(argument))), (passed) => {
|
|
51
|
-
const passedNames = Array.getSomes(pipe(passed, Array.map((argument) => nameOf(argument))));
|
|
52
|
-
return pipe(names, Array.every((name) => passedNames.includes(name)));
|
|
53
|
-
});
|
|
54
|
-
const passesParamsUnchanged = (node) => pipe(paramsOf(node), Array.map((param) => nameOf(param)), Option.all, Option.exists((names) => Option.exists(argumentsOf(node), passesExactly(names))));
|
|
55
|
-
const forwardsOneCall = Predicate.and(Predicate.and(hasAtMostOneStatement, isSingleCall), passesParamsUnchanged);
|
|
56
|
-
const declaredTypeOf = (param) => Match.value(param).pipe(Match.when({ type: "AssignmentPattern" }, (assigned) => declaredTypeOf(assigned.left)), Match.when({ type: "TSParameterProperty" }, (property) => declaredTypeOf(property.parameter)), Match.when({ typeAnnotation: { type: "TSTypeAnnotation" } }, (typed) => Option.some(typed.typeAnnotation.typeAnnotation)), Match.orElse(() => Option.none()));
|
|
57
|
-
const isOpenType = ofType("TSUnknownKeyword", "TSAnyKeyword");
|
|
58
|
-
const hasNarrowParameter = (node) => pipe(paramsOf(node), Array.some((param) => Option.exists(declaredTypeOf(param), Predicate.not(isOpenType))));
|
|
59
|
-
const typeParameterNamesOf = (node) => Match.value(node).pipe(Match.when({ typeParameters: { type: "TSTypeParameterDeclaration" } }, (generic) => pipe(generic.typeParameters.params, Array.map((parameter) => parameter.name.name))), Match.orElse(() => []));
|
|
60
|
-
const referencedNameOf = (type) => Match.value(type).pipe(Match.when({
|
|
61
|
-
type: "TSTypeReference",
|
|
62
|
-
typeName: { type: "Identifier" }
|
|
63
|
-
}, (reference) => Option.some(reference.typeName.name)), Match.orElse(() => Option.none()));
|
|
64
|
-
const isGenericParameter = (node, param) => Option.exists(Option.flatMap(declaredTypeOf(param), referencedNameOf), (name) => typeParameterNamesOf(node).includes(name));
|
|
65
|
-
const returnedOf = (node) => Option.flatMap(bodyOf(node), (body) => Option.flatMap(Array.head(statementsOf(body)), expressionOf));
|
|
66
|
-
const returnedNameOf = (node) => Option.flatMap(returnedOf(node), identifierOf);
|
|
67
|
-
const returnsParameter = (node, param) => Option.exists(Option.all([returnedNameOf(node), identifierOf(param)]), ([returned, given]) => returned === given);
|
|
68
|
-
const ONE_PARAMETER = 1;
|
|
69
|
-
const onlyParameterOf = (node) => Option.liftPredicate(paramsOf(node), (params) => params.length === ONE_PARAMETER).pipe(Option.flatMap(Array.head));
|
|
70
|
-
const isGenericIdentity = (node) => onlyParameterOf(node).pipe(Option.filter((param) => isGenericParameter(node, param)), Option.exists((param) => returnsParameter(node, param)));
|
|
71
|
-
const mayBePlaceholder = Predicate.and(hasAtMostOneStatement, Predicate.not(isGenericIdentity));
|
|
72
|
-
const isGuard = Predicate.or(ofType("IfStatement", "ConditionalExpression", "ChainExpression", "TryStatement"), isTypeofCheck);
|
|
73
|
-
const hasGuard = Predicate.and(hasNarrowParameter, containing(isGuard));
|
|
74
|
-
const isFallback = Predicate.or(isFallbackOperator, ofType("AssignmentPattern"));
|
|
75
|
-
const hasFallback = dualSelect(containing(isFallback));
|
|
76
|
-
const hasCast = dualSelect(containing(isCast));
|
|
77
|
-
// src/presets/comment-select.ts
|
|
78
|
-
const commentsIn = (node, { context }) => {
|
|
79
|
-
const [start, end] = node.range;
|
|
80
|
-
return pipe(context.sourceCode.getAllComments(), Array.filter((comment) => comment.start >= start && comment.end <= end), Array.map((comment) => comment.value));
|
|
81
|
-
};
|
|
82
|
-
const hasCommentInside = dualSelect((node, match) => Array.isReadonlyArrayNonEmpty(commentsIn(node, match)));
|
|
83
|
-
const SUPPRESSIONS = [
|
|
84
|
-
"eslint-disable",
|
|
85
|
-
"oxlint-disable",
|
|
86
|
-
"@ts-ignore",
|
|
87
|
-
"@ts-expect-error",
|
|
88
|
-
"@ts-nocheck",
|
|
89
|
-
"fallow-ignore"
|
|
90
|
-
];
|
|
91
|
-
const hasSuppression = dualSelect((node, match) => pipe(commentsIn(node, match), Array.some((comment) => pipe(SUPPRESSIONS, Array.some((word) => String.includes(word)(comment))))));
|
|
92
|
-
// src/presets/ai-slop-rules.ts
|
|
93
|
-
const CUTOFF = .8;
|
|
94
|
-
const slopRule = ({ ask, flag, pass, ...rule }) => defineDecisionRule({
|
|
95
|
-
target: "function",
|
|
96
|
-
cutoff: CUTOFF,
|
|
97
|
-
...rule,
|
|
98
|
-
message: ask,
|
|
99
|
-
question: `${ask}\n\nAnswer yes when: ${flag}\n\nAnswer no when: ${pass}`
|
|
100
|
-
});
|
|
101
|
-
const redundantGuard = slopRule({
|
|
102
|
-
id: "redundant-guard",
|
|
103
|
-
select: hasGuard,
|
|
104
|
-
ask: "This function checks one of its own parameters for a case that the parameter's declared type already rules out, so the check can never change what happens.",
|
|
105
|
-
flag: "A parameter whose type annotation is non-optional and non-nullable, such as `user: User` or `name: string`, is compared with null or undefined, has its `typeof` tested against the type it is already declared as, or is read with `?.`.",
|
|
106
|
-
pass: "No parameter is checked against its own declared type. Checks on local variables do not count: a local that holds the result of `Map.get`, `find`, `JSON.parse` or any other call, or a value annotated `unknown`, can really be missing or of another type, so checking it is necessary. Parameters of plain JavaScript have no declared type, so any check on them is allowed."
|
|
107
|
-
});
|
|
108
|
-
const defaultMasksMissingValue = slopRule({
|
|
109
|
-
id: "default-masks-missing-value",
|
|
110
|
-
select: hasFallback,
|
|
111
|
-
ask: "This function replaces a value that should always be present with a made-up default, so a missing value is hidden instead of reported.",
|
|
112
|
-
flag: "A `??` or `||` default, or a default parameter, stands in for data the rest of the code treats as required, such as an id, a user, a price, a config entry or a response field, with a placeholder like 'unknown', '', 0, [] or {} that later code will use as if it were real; or a chain of two or more fallbacks (`a ?? b ?? c`) picks among sources with no sign of why that order is right.",
|
|
113
|
-
pass: "Every default is a value the domain genuinely allows when the input is absent, such as an optional setting with a documented default, an empty list for an optional filter, or a display label for an optional field; or the missing case is reported, thrown or returned to the caller instead of being filled in."
|
|
114
|
-
});
|
|
115
|
-
const passThroughWrapper = slopRule({
|
|
116
|
-
id: "pass-through-wrapper",
|
|
117
|
-
select: forwardsOneCall,
|
|
118
|
-
ask: "This function only forwards its arguments to another function and returns the result, adding no behaviour of its own.",
|
|
119
|
-
flag: "The body is a single call that receives every parameter exactly as it came in, in the same order, or with an extra argument that is always the same constant, and returns or awaits the result unchanged, so callers could call the inner function directly.",
|
|
120
|
-
pass: "The function changes something on the way: it transforms an argument before passing it on (for example trimming, lower-casing, converting or validating it), transforms the result, binds a dependency, adapts to a different signature a caller requires, or it is an entry point that a framework or another package calls by name."
|
|
121
|
-
});
|
|
122
|
-
const placeholderImplementation = slopRule({
|
|
123
|
-
id: "placeholder-implementation",
|
|
124
|
-
select: mayBePlaceholder,
|
|
125
|
-
ask: "This function is a stand-in that pretends to do its job: it returns a fixed value or does nothing where its name promises real work.",
|
|
126
|
-
flag: "The body is empty, only logs, or only holds a TODO while the name promises an action; a validator, checker or permission function always returns true or always returns false; a function named after a computation returns a hard-coded number, string or object; or a branch the name promises to handle silently does nothing.",
|
|
127
|
-
pass: "The body does the work its name promises, even simply. An intentional no-op whose name says so (noop, ignore, a default callback), an abstract method meant to be overridden, and a test double inside test code are not placeholders."
|
|
128
|
-
});
|
|
129
|
-
const commentRestatesCode = slopRule({
|
|
130
|
-
id: "comment-restates-code",
|
|
131
|
-
select: hasCommentInside,
|
|
132
|
-
ask: "A comment inside this function only translates the next line of code into words and adds no reason, unit, or constraint.",
|
|
133
|
-
flag: "A comment repeats the code in words, such as `// increment the counter` over `count += 1`, `// loop over the items` over a for loop, or `// return the total` over a return; deleting it would leave a reader knowing exactly as much.",
|
|
134
|
-
pass: "Every comment says something the code cannot say on its own: why it is done this way (often with `because` or `so`), a fact about the outside world such as a billing rule, an API quirk or a standard, a unit, or an invariant. Lint directive comments such as `eslint-disable` are not judged here."
|
|
135
|
-
});
|
|
136
|
-
const commentNarratesHistory = slopRule({
|
|
137
|
-
id: "comment-narrates-history",
|
|
138
|
-
select: hasCommentInside,
|
|
139
|
-
ask: "A comment inside this function records how the code came to be, or speaks to the person who asked for the change, instead of describing the code as it stands.",
|
|
140
|
-
flag: "A comment says what was added, changed, removed, fixed or kept for compatibility (`added X`, `changed to Y`, `previously`, `now uses`, `new:`), marks the code as a stopgap (`temporary`, `for now`, `quick fix`, `hack until`), mentions a date, a ticket in progress, a model or a conversation, or addresses a reader as if replying (`as requested`, `here we`, `note that I`).",
|
|
141
|
-
pass: "Every comment describes the code as it is now and would still be true and useful to a reader who never saw the earlier version or the conversation. A TODO that names a concrete missing case is a description of the code, not history."
|
|
142
|
-
});
|
|
143
|
-
const docRestatesSignature = slopRule({
|
|
144
|
-
id: "doc-restates-signature",
|
|
145
|
-
context: { scope: "comment" },
|
|
146
|
-
ask: "The comment above this function contains nothing except the function's name and parameter names reworded.",
|
|
147
|
-
flag: "Every sentence of the comment can be rebuilt from the signature alone, such as `Gets the order.`, `@param id - the id`, `@returns the order` or `Creates a new instance.`",
|
|
148
|
-
pass: "At least one sentence states behaviour the signature does not show, such as what is returned when nothing matches, when it fails, a unit or range, a side effect, or how values are compared."
|
|
149
|
-
});
|
|
150
|
-
const castInsteadOfNarrowing = slopRule({
|
|
151
|
-
id: "cast-instead-of-narrowing",
|
|
152
|
-
select: hasCast,
|
|
153
|
-
ask: "This function uses a type assertion (`as`, `<T>` or a non-null `!`) to silence the type checker where the value is not known to have that type.",
|
|
154
|
-
flag: "The asserted type is not established by anything on the path: data from parsing, I/O, `unknown`, `any` or a wider union is cast to a specific shape without a check, a possibly missing value gets `!` without a preceding check or a guarantee from the API, or the cast goes through `unknown` (`as unknown as T`) to force an unrelated type.",
|
|
155
|
-
pass: "Each assertion states something the code has just established or the API guarantees, such as a cast after a type guard, a DOM element looked up by a selector that the same module creates, or a literal narrowed for an overload; `as const` is not a cast."
|
|
156
|
-
});
|
|
157
|
-
const suppressionInsteadOfFix = slopRule({
|
|
158
|
-
id: "suppression-instead-of-fix",
|
|
159
|
-
select: hasSuppression,
|
|
160
|
-
ask: "A lint or type-check suppression comment inside this function hides a problem that the code next to it could simply fix.",
|
|
161
|
-
flag: "The directive gives no reason after the rule name, or the line it silences has a direct local fix, such as handling a floating promise, typing a value instead of `any`, removing an unused variable, or narrowing instead of `@ts-ignore`.",
|
|
162
|
-
pass: "Every directive is followed by `--` or a comment with a reason explaining why the rule does not fit this line, such as output a command-line tool prints on purpose, a wrong third-party type, or generated code."
|
|
163
|
-
});
|
|
164
|
-
const reinventsBuiltin = slopRule({
|
|
165
|
-
id: "reinvents-builtin",
|
|
166
|
-
select: isDeclared,
|
|
167
|
-
ask: "This function contains a hand-written loop or algorithm that re-implements something the JavaScript standard library or the platform already provides.",
|
|
168
|
-
flag: "A loop or manual algorithm in the body does what one built-in call does: de-duplicating with an array and includes instead of a Set, deep copying instead of structuredClone, grouping instead of Object.groupBy, building query strings instead of URLSearchParams, formatting numbers or dates instead of Intl, padding instead of padStart, flattening instead of flat, or finding the last match instead of findLast.",
|
|
169
|
-
pass: "The function has no such hand-written loop: it already calls the built-in directly (for example `new Set`, `structuredClone`, `reduce` or `Intl`), or its loop does domain work that no single built-in does. A chain of built-in array methods such as `filter`, `map`, `flatMap` and `flat` already uses the built-ins."
|
|
170
|
-
});
|
|
171
|
-
const aiSlopRules = [
|
|
172
|
-
redundantGuard,
|
|
173
|
-
defaultMasksMissingValue,
|
|
174
|
-
passThroughWrapper,
|
|
175
|
-
placeholderImplementation,
|
|
176
|
-
commentRestatesCode,
|
|
177
|
-
commentNarratesHistory,
|
|
178
|
-
docRestatesSignature,
|
|
179
|
-
castInsteadOfNarrowing,
|
|
180
|
-
suppressionInsteadOfFix,
|
|
181
|
-
reinventsBuiltin
|
|
182
|
-
];
|
|
183
|
-
// src/presets/ai-slop.ts
|
|
1
|
+
import { t as createDecisionPlugin } from "../app-UakaWKAT.mjs";
|
|
2
|
+
import { B as reinventsBuiltin, F as defaultMasksMissingValue, I as docRestatesSignature, L as passThroughWrapper, M as castInsteadOfNarrowing, N as commentNarratesHistory, P as commentRestatesCode, R as placeholderImplementation, V as suppressionInsteadOfFix, j as aiSlopRules, z as redundantGuard } from "../define-presets-yflVt8vT.mjs";
|
|
3
|
+
// src/app/ai-slop.ts
|
|
184
4
|
const plugin = createDecisionPlugin({
|
|
185
5
|
name: "decision-ai-slop",
|
|
186
6
|
rules: aiSlopRules
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-slop.mjs","names":["Arr","Arr","Str"],"sources":["../../src/presets/ai-slop-select.ts","../../src/presets/comment-select.ts","../../src/presets/ai-slop-rules.ts","../../src/presets/ai-slop.ts"],"sourcesContent":["import type { SelectedNode } from \"@r_masseater/oxlint-plugin-decision\";\nimport { Array as Arr, Match, Option, Predicate, pipe } from \"effect\";\n\nimport { containing, dualSelect, identifierOf, ofType } from \"./select.ts\";\nimport type { DualSelect, NodeTest } from \"./select.ts\";\n\nconst isPlaceholderValue = ofType(\n \"Literal\",\n \"TemplateLiteral\",\n \"ArrayExpression\",\n \"ObjectExpression\",\n);\n\nconst isFallbackOperator: NodeTest = (node) =>\n Match.value(node).pipe(\n Match.when({ type: \"LogicalExpression\", operator: \"??\" }, () => true),\n Match.when({ type: \"LogicalExpression\", operator: \"||\" }, (logical) =>\n isPlaceholderValue(logical.right),\n ),\n Match.when({ type: \"AssignmentExpression\", operator: \"??=\" }, () => true),\n Match.when({ type: \"AssignmentExpression\", operator: \"||=\" }, () => true),\n Match.orElse(() => false),\n );\n\nconst isTypeofCheck: NodeTest = (node) =>\n Match.value(node).pipe(\n Match.when({ type: \"UnaryExpression\", operator: \"typeof\" }, () => true),\n Match.orElse(() => false),\n );\n\nconst isConstAssertion = (annotation: SelectedNode): boolean =>\n Match.value(annotation).pipe(\n Match.when(\n { type: \"TSTypeReference\", typeName: { type: \"Identifier\", name: \"const\" } },\n () => true,\n ),\n Match.orElse(() => false),\n );\n\nconst isCast: NodeTest = (node) =>\n Match.value(node).pipe(\n Match.when({ type: \"TSAsExpression\" }, (cast) => !isConstAssertion(cast.typeAnnotation)),\n Match.when({ type: \"TSTypeAssertion\" }, () => true),\n Match.when({ type: \"TSNonNullExpression\" }, () => true),\n Match.orElse(() => false),\n );\n\nconst bodyOf = (node: SelectedNode): Option.Option<SelectedNode> =>\n Match.value(node).pipe(\n Match.when({ type: \"FunctionDeclaration\" }, (fn) => Option.fromNullishOr(fn.body)),\n Match.when({ type: \"FunctionExpression\" }, (fn) => Option.fromNullishOr(fn.body)),\n Match.when({ type: \"ArrowFunctionExpression\" }, (fn) => Option.some(fn.body)),\n Match.orElse(() => Option.none()),\n );\n\nconst statementsOf = (body: SelectedNode): readonly SelectedNode[] =>\n Match.value(body).pipe(\n Match.when({ type: \"BlockStatement\" }, (block) => block.body),\n Match.orElse((expression) => [expression]),\n );\n\nconst ONE_STATEMENT = 1;\n\nconst isCall = ofType(\"CallExpression\", \"NewExpression\");\n\nconst parentOf = (node: SelectedNode): Option.Option<SelectedNode> =>\n Option.fromNullishOr(node.parent);\n\nconst isArgument = (node: SelectedNode): boolean => Option.exists(parentOf(node), isCall);\n\nconst isOptionOfCall = (node: SelectedNode): boolean =>\n parentOf(node).pipe(\n Option.filter(ofType(\"Property\")),\n Option.flatMap(parentOf),\n Option.filter(ofType(\"ObjectExpression\")),\n Option.exists(isArgument),\n );\n\nconst isCallback: NodeTest = Predicate.or(isArgument, isOptionOfCall);\n\nexport const isDeclared: NodeTest = Predicate.not(isCallback);\n\nconst isShort: NodeTest = (node) =>\n Option.exists(bodyOf(node), (body) => statementsOf(body).length <= ONE_STATEMENT);\n\nconst hasAtMostOneStatement: NodeTest = Predicate.and(isDeclared, isShort);\n\nconst expressionOf = (statement: SelectedNode): Option.Option<SelectedNode> =>\n Match.value(statement).pipe(\n Match.when({ type: \"ReturnStatement\" }, (returned) => Option.fromNullishOr(returned.argument)),\n Match.when({ type: \"ExpressionStatement\" }, (expression) => Option.some(expression.expression)),\n Match.orElse((other) => Option.some(other)),\n );\n\nconst awaitedOf = (expression: SelectedNode): SelectedNode =>\n Match.value(expression).pipe(\n Match.when({ type: \"AwaitExpression\" }, (awaited) => awaited.argument),\n Match.orElse((plain) => plain),\n );\n\nconst isForwardingStatement = (statements: readonly SelectedNode[]): boolean =>\n Option.exists(\n Option.flatMap(Arr.head(statements), expressionOf),\n (expression) => awaitedOf(expression).type === \"CallExpression\",\n );\n\nconst isSingleCall: NodeTest = (node) =>\n Option.exists(bodyOf(node), (body) => isForwardingStatement(statementsOf(body)));\n\nconst paramsOf = (node: SelectedNode): readonly SelectedNode[] =>\n Match.value(node).pipe(\n Match.when({ type: \"FunctionDeclaration\" }, (fn) => fn.params),\n Match.when({ type: \"FunctionExpression\" }, (fn) => fn.params),\n Match.when({ type: \"ArrowFunctionExpression\" }, (fn) => fn.params),\n Match.orElse(() => []),\n );\n\nconst nameOf = (node: SelectedNode): Option.Option<string> =>\n Match.value(node).pipe(\n Match.when({ type: \"SpreadElement\" }, (spread) => identifierOf(spread.argument)),\n Match.when({ type: \"RestElement\" }, (rest) => identifierOf(rest.argument)),\n Match.orElse((plain) => identifierOf(plain)),\n );\n\nconst argumentsOf = (node: SelectedNode): Option.Option<readonly SelectedNode[]> =>\n bodyOf(node).pipe(\n Option.flatMap((body) => Arr.head(statementsOf(body))),\n Option.flatMap(expressionOf),\n Option.map(awaitedOf),\n Option.flatMap((expression) =>\n Match.value(expression).pipe(\n Match.when({ type: \"CallExpression\" }, (call) => Option.some(call.arguments)),\n Match.orElse(() => Option.none()),\n ),\n ),\n );\n\nconst isForwardedArgument =\n (names: readonly string[]) =>\n (argument: SelectedNode): boolean =>\n Match.value(argument).pipe(\n Match.when({ type: \"Literal\" }, () => true),\n Match.orElse((other) => Option.exists(nameOf(other), (name) => names.includes(name))),\n );\n\nconst passesExactly = (names: readonly string[]): Predicate.Predicate<readonly SelectedNode[]> =>\n Predicate.and(\n (passed) =>\n pipe(\n passed,\n Arr.every((argument) => isForwardedArgument(names)(argument)),\n ),\n (passed) => {\n const passedNames = Arr.getSomes(\n pipe(\n passed,\n Arr.map((argument) => nameOf(argument)),\n ),\n );\n return pipe(\n names,\n Arr.every((name) => passedNames.includes(name)),\n );\n },\n );\n\nconst passesParamsUnchanged: NodeTest = (node) =>\n pipe(\n paramsOf(node),\n Arr.map((param) => nameOf(param)),\n Option.all,\n Option.exists((names) => Option.exists(argumentsOf(node), passesExactly(names))),\n );\n\nexport const forwardsOneCall: NodeTest = Predicate.and(\n Predicate.and(hasAtMostOneStatement, isSingleCall),\n passesParamsUnchanged,\n);\n\nconst declaredTypeOf = (param: SelectedNode): Option.Option<SelectedNode> =>\n Match.value(param).pipe(\n Match.when({ type: \"AssignmentPattern\" }, (assigned) => declaredTypeOf(assigned.left)),\n Match.when({ type: \"TSParameterProperty\" }, (property) => declaredTypeOf(property.parameter)),\n Match.when({ typeAnnotation: { type: \"TSTypeAnnotation\" } }, (typed) =>\n Option.some(typed.typeAnnotation.typeAnnotation),\n ),\n Match.orElse(() => Option.none()),\n );\n\nconst isOpenType = ofType(\"TSUnknownKeyword\", \"TSAnyKeyword\");\n\nconst hasNarrowParameter: NodeTest = (node) =>\n pipe(\n paramsOf(node),\n Arr.some((param) => Option.exists(declaredTypeOf(param), Predicate.not(isOpenType))),\n );\n\nconst typeParameterNamesOf = (node: SelectedNode): readonly string[] =>\n Match.value(node).pipe(\n Match.when({ typeParameters: { type: \"TSTypeParameterDeclaration\" } }, (generic) =>\n pipe(\n generic.typeParameters.params,\n Arr.map((parameter) => parameter.name.name),\n ),\n ),\n Match.orElse(() => []),\n );\n\nconst referencedNameOf = (type: SelectedNode): Option.Option<string> =>\n Match.value(type).pipe(\n Match.when({ type: \"TSTypeReference\", typeName: { type: \"Identifier\" } }, (reference) =>\n Option.some(reference.typeName.name),\n ),\n Match.orElse(() => Option.none()),\n );\n\nconst isGenericParameter = (node: SelectedNode, param: SelectedNode): boolean =>\n Option.exists(Option.flatMap(declaredTypeOf(param), referencedNameOf), (name) =>\n typeParameterNamesOf(node).includes(name),\n );\n\nconst returnedOf = (node: SelectedNode): Option.Option<SelectedNode> =>\n Option.flatMap(bodyOf(node), (body) =>\n Option.flatMap(Arr.head(statementsOf(body)), expressionOf),\n );\n\nconst returnedNameOf = (node: SelectedNode): Option.Option<string> =>\n Option.flatMap(returnedOf(node), identifierOf);\n\nconst returnsParameter = (node: SelectedNode, param: SelectedNode): boolean =>\n Option.exists(\n Option.all([returnedNameOf(node), identifierOf(param)]),\n ([returned, given]) => returned === given,\n );\n\nconst ONE_PARAMETER = 1;\n\nconst onlyParameterOf = (node: SelectedNode): Option.Option<SelectedNode> =>\n Option.liftPredicate(paramsOf(node), (params) => params.length === ONE_PARAMETER).pipe(\n Option.flatMap(Arr.head),\n );\n\nconst isGenericIdentity: NodeTest = (node) =>\n onlyParameterOf(node).pipe(\n Option.filter((param) => isGenericParameter(node, param)),\n Option.exists((param) => returnsParameter(node, param)),\n );\n\nexport const mayBePlaceholder: NodeTest = Predicate.and(\n hasAtMostOneStatement,\n Predicate.not(isGenericIdentity),\n);\n\nconst isGuard: NodeTest = Predicate.or(\n ofType(\"IfStatement\", \"ConditionalExpression\", \"ChainExpression\", \"TryStatement\"),\n isTypeofCheck,\n);\n\nexport const hasGuard: NodeTest = Predicate.and(hasNarrowParameter, containing(isGuard));\n\nconst isFallback: NodeTest = Predicate.or(isFallbackOperator, ofType(\"AssignmentPattern\"));\n\nexport const hasFallback: DualSelect = dualSelect(containing(isFallback));\n\nexport const hasCast: DualSelect = dualSelect(containing(isCast));\n","import type { SelectMatch, SelectedNode } from \"@r_masseater/oxlint-plugin-decision\";\nimport { Array as Arr, String as Str, pipe } from \"effect\";\n\nimport { dualSelect } from \"./select.ts\";\nimport type { DualSelect } from \"./select.ts\";\n\nconst commentsIn = (node: SelectedNode, { context }: SelectMatch): readonly string[] => {\n const [start, end] = node.range;\n return pipe(\n context.sourceCode.getAllComments(),\n Arr.filter((comment) => comment.start >= start && comment.end <= end),\n Arr.map((comment) => comment.value),\n );\n};\n\nexport const hasCommentInside: DualSelect = dualSelect((node, match) =>\n Arr.isReadonlyArrayNonEmpty(commentsIn(node, match)),\n);\n\nconst SUPPRESSIONS = [\n \"eslint-disable\",\n \"oxlint-disable\",\n \"@ts-ignore\",\n \"@ts-expect-error\",\n \"@ts-nocheck\",\n \"fallow-ignore\",\n];\n\nexport const hasSuppression: DualSelect = dualSelect((node, match) =>\n pipe(\n commentsIn(node, match),\n Arr.some((comment) =>\n pipe(\n SUPPRESSIONS,\n Arr.some((word) => Str.includes(word)(comment)),\n ),\n ),\n ),\n);\n","import { defineDecisionRule } from \"@r_masseater/oxlint-plugin-decision\";\nimport type { DecisionRule } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport {\n forwardsOneCall,\n isDeclared,\n mayBePlaceholder,\n hasCast,\n hasFallback,\n hasGuard,\n} from \"./ai-slop-select.ts\";\nimport { hasCommentInside, hasSuppression } from \"./comment-select.ts\";\n\ninterface SlopRule extends Pick<DecisionRule, \"id\" | \"select\" | \"context\"> {\n readonly ask: string;\n readonly flag: string;\n readonly pass: string;\n}\n\nconst CUTOFF = 0.8;\n\nconst slopRule = ({ ask, flag, pass, ...rule }: SlopRule): DecisionRule =>\n defineDecisionRule({\n target: \"function\",\n cutoff: CUTOFF,\n ...rule,\n message: ask,\n question: `${ask}\\n\\nAnswer yes when: ${flag}\\n\\nAnswer no when: ${pass}`,\n });\n\nexport const redundantGuard = slopRule({\n id: \"redundant-guard\",\n select: hasGuard,\n ask: \"This function checks one of its own parameters for a case that the parameter's declared type already rules out, so the check can never change what happens.\",\n flag: \"A parameter whose type annotation is non-optional and non-nullable, such as `user: User` or `name: string`, is compared with null or undefined, has its `typeof` tested against the type it is already declared as, or is read with `?.`.\",\n pass: \"No parameter is checked against its own declared type. Checks on local variables do not count: a local that holds the result of `Map.get`, `find`, `JSON.parse` or any other call, or a value annotated `unknown`, can really be missing or of another type, so checking it is necessary. Parameters of plain JavaScript have no declared type, so any check on them is allowed.\",\n});\n\nexport const defaultMasksMissingValue = slopRule({\n id: \"default-masks-missing-value\",\n select: hasFallback,\n ask: \"This function replaces a value that should always be present with a made-up default, so a missing value is hidden instead of reported.\",\n flag: \"A `??` or `||` default, or a default parameter, stands in for data the rest of the code treats as required, such as an id, a user, a price, a config entry or a response field, with a placeholder like 'unknown', '', 0, [] or {} that later code will use as if it were real; or a chain of two or more fallbacks (`a ?? b ?? c`) picks among sources with no sign of why that order is right.\",\n pass: \"Every default is a value the domain genuinely allows when the input is absent, such as an optional setting with a documented default, an empty list for an optional filter, or a display label for an optional field; or the missing case is reported, thrown or returned to the caller instead of being filled in.\",\n});\n\nexport const passThroughWrapper = slopRule({\n id: \"pass-through-wrapper\",\n select: forwardsOneCall,\n ask: \"This function only forwards its arguments to another function and returns the result, adding no behaviour of its own.\",\n flag: \"The body is a single call that receives every parameter exactly as it came in, in the same order, or with an extra argument that is always the same constant, and returns or awaits the result unchanged, so callers could call the inner function directly.\",\n pass: \"The function changes something on the way: it transforms an argument before passing it on (for example trimming, lower-casing, converting or validating it), transforms the result, binds a dependency, adapts to a different signature a caller requires, or it is an entry point that a framework or another package calls by name.\",\n});\n\nexport const placeholderImplementation = slopRule({\n id: \"placeholder-implementation\",\n select: mayBePlaceholder,\n ask: \"This function is a stand-in that pretends to do its job: it returns a fixed value or does nothing where its name promises real work.\",\n flag: \"The body is empty, only logs, or only holds a TODO while the name promises an action; a validator, checker or permission function always returns true or always returns false; a function named after a computation returns a hard-coded number, string or object; or a branch the name promises to handle silently does nothing.\",\n pass: \"The body does the work its name promises, even simply. An intentional no-op whose name says so (noop, ignore, a default callback), an abstract method meant to be overridden, and a test double inside test code are not placeholders.\",\n});\n\nexport const commentRestatesCode = slopRule({\n id: \"comment-restates-code\",\n select: hasCommentInside,\n ask: \"A comment inside this function only translates the next line of code into words and adds no reason, unit, or constraint.\",\n flag: \"A comment repeats the code in words, such as `// increment the counter` over `count += 1`, `// loop over the items` over a for loop, or `// return the total` over a return; deleting it would leave a reader knowing exactly as much.\",\n pass: \"Every comment says something the code cannot say on its own: why it is done this way (often with `because` or `so`), a fact about the outside world such as a billing rule, an API quirk or a standard, a unit, or an invariant. Lint directive comments such as `eslint-disable` are not judged here.\",\n});\n\nexport const commentNarratesHistory = slopRule({\n id: \"comment-narrates-history\",\n select: hasCommentInside,\n ask: \"A comment inside this function records how the code came to be, or speaks to the person who asked for the change, instead of describing the code as it stands.\",\n flag: \"A comment says what was added, changed, removed, fixed or kept for compatibility (`added X`, `changed to Y`, `previously`, `now uses`, `new:`), marks the code as a stopgap (`temporary`, `for now`, `quick fix`, `hack until`), mentions a date, a ticket in progress, a model or a conversation, or addresses a reader as if replying (`as requested`, `here we`, `note that I`).\",\n pass: \"Every comment describes the code as it is now and would still be true and useful to a reader who never saw the earlier version or the conversation. A TODO that names a concrete missing case is a description of the code, not history.\",\n});\n\nexport const docRestatesSignature = slopRule({\n id: \"doc-restates-signature\",\n context: { scope: \"comment\" },\n ask: \"The comment above this function contains nothing except the function's name and parameter names reworded.\",\n flag: \"Every sentence of the comment can be rebuilt from the signature alone, such as `Gets the order.`, `@param id - the id`, `@returns the order` or `Creates a new instance.`\",\n pass: \"At least one sentence states behaviour the signature does not show, such as what is returned when nothing matches, when it fails, a unit or range, a side effect, or how values are compared.\",\n});\n\nexport const castInsteadOfNarrowing = slopRule({\n id: \"cast-instead-of-narrowing\",\n select: hasCast,\n ask: \"This function uses a type assertion (`as`, `<T>` or a non-null `!`) to silence the type checker where the value is not known to have that type.\",\n flag: \"The asserted type is not established by anything on the path: data from parsing, I/O, `unknown`, `any` or a wider union is cast to a specific shape without a check, a possibly missing value gets `!` without a preceding check or a guarantee from the API, or the cast goes through `unknown` (`as unknown as T`) to force an unrelated type.\",\n pass: \"Each assertion states something the code has just established or the API guarantees, such as a cast after a type guard, a DOM element looked up by a selector that the same module creates, or a literal narrowed for an overload; `as const` is not a cast.\",\n});\n\nexport const suppressionInsteadOfFix = slopRule({\n id: \"suppression-instead-of-fix\",\n select: hasSuppression,\n ask: \"A lint or type-check suppression comment inside this function hides a problem that the code next to it could simply fix.\",\n flag: \"The directive gives no reason after the rule name, or the line it silences has a direct local fix, such as handling a floating promise, typing a value instead of `any`, removing an unused variable, or narrowing instead of `@ts-ignore`.\",\n pass: \"Every directive is followed by `--` or a comment with a reason explaining why the rule does not fit this line, such as output a command-line tool prints on purpose, a wrong third-party type, or generated code.\",\n});\n\nexport const reinventsBuiltin = slopRule({\n id: \"reinvents-builtin\",\n select: isDeclared,\n ask: \"This function contains a hand-written loop or algorithm that re-implements something the JavaScript standard library or the platform already provides.\",\n flag: \"A loop or manual algorithm in the body does what one built-in call does: de-duplicating with an array and includes instead of a Set, deep copying instead of structuredClone, grouping instead of Object.groupBy, building query strings instead of URLSearchParams, formatting numbers or dates instead of Intl, padding instead of padStart, flattening instead of flat, or finding the last match instead of findLast.\",\n pass: \"The function has no such hand-written loop: it already calls the built-in directly (for example `new Set`, `structuredClone`, `reduce` or `Intl`), or its loop does domain work that no single built-in does. A chain of built-in array methods such as `filter`, `map`, `flatMap` and `flat` already uses the built-ins.\",\n});\n\nexport const aiSlopRules = [\n redundantGuard,\n defaultMasksMissingValue,\n passThroughWrapper,\n placeholderImplementation,\n commentRestatesCode,\n commentNarratesHistory,\n docRestatesSignature,\n castInsteadOfNarrowing,\n suppressionInsteadOfFix,\n reinventsBuiltin,\n] as const;\n","import { createDecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\nimport type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { aiSlopRules } from \"./ai-slop-rules.ts\";\n\nconst plugin: DecisionPlugin = createDecisionPlugin({\n name: \"decision-ai-slop\",\n rules: aiSlopRules,\n});\n\nexport default plugin;\nexport {\n aiSlopRules,\n castInsteadOfNarrowing,\n commentNarratesHistory,\n commentRestatesCode,\n defaultMasksMissingValue,\n docRestatesSignature,\n passThroughWrapper,\n placeholderImplementation,\n redundantGuard,\n reinventsBuiltin,\n suppressionInsteadOfFix,\n} from \"./ai-slop-rules.ts\";\n"],"mappings":";;;;AAMA,MAAM,qBAAqB,OACzB,WACA,mBACA,mBACA,kBACF;AAEA,MAAM,sBAAgC,SACpC,MAAM,MAAM,IAAI,CAAC,CAAC,KAChB,MAAM,KAAK;CAAE,MAAM;CAAqB,UAAU;AAAK,SAAS,IAAI,GACpE,MAAM,KAAK;CAAE,MAAM;CAAqB,UAAU;AAAK,IAAI,YACzD,mBAAmB,QAAQ,KAAK,CAClC,GACA,MAAM,KAAK;CAAE,MAAM;CAAwB,UAAU;AAAM,SAAS,IAAI,GACxE,MAAM,KAAK;CAAE,MAAM;CAAwB,UAAU;AAAM,SAAS,IAAI,GACxE,MAAM,aAAa,KAAK,CAC1B;AAEF,MAAM,iBAA2B,SAC/B,MAAM,MAAM,IAAI,CAAC,CAAC,KAChB,MAAM,KAAK;CAAE,MAAM;CAAmB,UAAU;AAAS,SAAS,IAAI,GACtE,MAAM,aAAa,KAAK,CAC1B;AAEF,MAAM,oBAAoB,eACxB,MAAM,MAAM,UAAU,CAAC,CAAC,KACtB,MAAM,KACJ;CAAE,MAAM;CAAmB,UAAU;EAAE,MAAM;EAAc,MAAM;CAAQ;AAAE,SACrE,IACR,GACA,MAAM,aAAa,KAAK,CAC1B;AAEF,MAAM,UAAoB,SACxB,MAAM,MAAM,IAAI,CAAC,CAAC,KAChB,MAAM,KAAK,EAAE,MAAM,iBAAiB,IAAI,SAAS,CAAC,iBAAiB,KAAK,cAAc,CAAC,GACvF,MAAM,KAAK,EAAE,MAAM,kBAAkB,SAAS,IAAI,GAClD,MAAM,KAAK,EAAE,MAAM,sBAAsB,SAAS,IAAI,GACtD,MAAM,aAAa,KAAK,CAC1B;AAEF,MAAM,UAAU,SACd,MAAM,MAAM,IAAI,CAAC,CAAC,KAChB,M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AAsB;AACrE,CAAC;AAEH,MAAa,iBAAiB,SAAS;CACrC,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,2BAA2B,SAAS;CAC/C,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,qBAAqB,SAAS;CACzC,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,4BAA4B,SAAS;CAChD,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,sBAAsB,SAAS;CAC1C,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,yBAAyB,SAAS;CAC7C,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,uBAAuB,SAAS;CAC3C,IAAI;CACJ,SAAS,EAAE,OAAO,UAAU;CAC5B,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,yBAAyB,SAAS;CAC7C,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,0BAA0B,SAAS;CAC9C,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,mBAAmB,SAAS;CACvC,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,MAAM;CACN,MAAM;AACR,CAAC;AAED,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;ACpHA,MAAM,SAAyB,qBAAqB;CAClD,MAAM;CACN,OAAO;AACT,CAAC"}
|
|
1
|
+
{"version":3,"file":"ai-slop.mjs","names":[],"sources":["../../src/app/ai-slop.ts"],"sourcesContent":["import { createDecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\nimport type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { aiSlopRules } from \"#/features/define-presets/index.ts\";\n\nconst plugin: DecisionPlugin = createDecisionPlugin({\n name: \"decision-ai-slop\",\n rules: aiSlopRules,\n});\n\nexport default plugin;\nexport {\n aiSlopRules,\n castInsteadOfNarrowing,\n commentNarratesHistory,\n commentRestatesCode,\n defaultMasksMissingValue,\n docRestatesSignature,\n passThroughWrapper,\n placeholderImplementation,\n redundantGuard,\n reinventsBuiltin,\n suppressionInsteadOfFix,\n} from \"#/features/define-presets/index.ts\";\n"],"mappings":";;;AAKA,MAAM,SAAyB,qBAAqB;CAClD,MAAM;CACN,OAAO;AACT,CAAC"}
|
package/dist/presets/index.d.mts
CHANGED
|
@@ -1,79 +1,3 @@
|
|
|
1
1
|
import plugin from "./recommended.mjs";
|
|
2
|
-
import { D as
|
|
3
|
-
type Preset
|
|
4
|
-
export declare const recommended: Preset;
|
|
5
|
-
export declare const strict: Preset;
|
|
6
|
-
export declare const reviewOnly: Preset;
|
|
7
|
-
export declare const presets: {
|
|
8
|
-
readonly recommended: Preset;
|
|
9
|
-
readonly strict: Preset;
|
|
10
|
-
readonly reviewOnly: Preset;
|
|
11
|
-
};
|
|
12
|
-
export declare const noPiiInLogs: {
|
|
13
|
-
readonly id: "no-pii-in-logs";
|
|
14
|
-
readonly target: "call";
|
|
15
|
-
readonly question: "Does this call write personal data, such as an email or phone number, to a log or console?";
|
|
16
|
-
readonly cutoff: 0.8;
|
|
17
|
-
};
|
|
18
|
-
export declare const noPromptInjection: {
|
|
19
|
-
readonly id: "no-prompt-injection";
|
|
20
|
-
readonly target: "function";
|
|
21
|
-
readonly question: "Does this function build a language model prompt by concatenating untrusted user input into the instructions?";
|
|
22
|
-
readonly cutoff: 0.8;
|
|
23
|
-
};
|
|
24
|
-
export declare const noHardcodedSecrets: {
|
|
25
|
-
readonly id: "no-hardcoded-secrets";
|
|
26
|
-
readonly target: "file";
|
|
27
|
-
readonly question: "Does this file contain a hard-coded secret, such as an API key, password, or private token, as a literal value?";
|
|
28
|
-
readonly cutoff: 0.8;
|
|
29
|
-
};
|
|
30
|
-
export declare const nameMatchesBehavior: {
|
|
31
|
-
readonly id: "name-matches-behavior";
|
|
32
|
-
readonly target: "function";
|
|
33
|
-
readonly select: (node: SelectedNode, match: SelectMatch) => boolean;
|
|
34
|
-
readonly question: "Does this function's name describe only reading or fetching data (for example get, find, load or fetch), while its body also changes or announces something on the side, such as writing to a database or file, logging, or sending a message? Sending the request that fetches the data, such as calling an API or a model and reading its answer, is the fetching itself and does not count.";
|
|
35
|
-
readonly cutoff: 0.8;
|
|
36
|
-
};
|
|
37
|
-
export declare const untrustedInputRisk: {
|
|
38
|
-
readonly id: "untrusted-input-risk";
|
|
39
|
-
readonly target: "function";
|
|
40
|
-
readonly question: "Does this function splice untrusted input, such as a user message or request parameter, into the same string as a SQL query, shell command, eval code, HTML, or language model instructions, instead of passing it as a separate parameter or field? Count input as untrusted only when it comes from outside the program, such as a request, a user message, a form, or a file or response the program does not control; a parameter whose origin is not shown counts when its name or type marks it as user or request data. Text taken from the program's own rule definitions, settings, constants or cache is not untrusted, and JSON.parse is not eval.";
|
|
41
|
-
readonly cutoff: 0.8;
|
|
42
|
-
readonly answer: {
|
|
43
|
-
readonly kind: "severity";
|
|
44
|
-
readonly minimum: "warn";
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export declare const domainNaming: {
|
|
48
|
-
readonly id: "domain-naming";
|
|
49
|
-
readonly target: "function";
|
|
50
|
-
readonly question: "Is this function named after a mechanism word such as Manager, Processor, Handler, Helper, Data, Info, handle, process, or do, while its body works on one specific business concept, such as an invoice, an order, or a refund, that the name should call by its domain name instead? Code whose subject is a generic mechanism, such as HTTP, files, the command line, or framework glue, does not count.";
|
|
51
|
-
readonly cutoff: 0.8;
|
|
52
|
-
};
|
|
53
|
-
export declare const preferSchemaValidation: {
|
|
54
|
-
readonly id: "prefer-schema-validation";
|
|
55
|
-
readonly target: "function";
|
|
56
|
-
readonly question: "Does this function check the shape or values of untyped data, such as parsed JSON, a request body, config, or an API response, with a long hand-written chain of typeof, instanceof, in, or field checks joined by && or ||, where a schema from a validation library would state the same rules more simply? A single simple check does not count.";
|
|
57
|
-
readonly cutoff: 0.8;
|
|
58
|
-
};
|
|
59
|
-
export declare const fnNamePromises: DecisionRule;
|
|
60
|
-
export declare const pureNameIsPure: DecisionRule;
|
|
61
|
-
export declare const safeNameIsSafe: DecisionRule;
|
|
62
|
-
export declare const idempotentName: DecisionRule;
|
|
63
|
-
export declare const catchHidesFailure: DecisionRule;
|
|
64
|
-
export declare const errorMessageMatchesCondition: DecisionRule;
|
|
65
|
-
export declare const logLevelMatchesEvent: DecisionRule;
|
|
66
|
-
export declare const logMessageMatchesEvent: DecisionRule;
|
|
67
|
-
export declare const commentDescribesBlock: DecisionRule;
|
|
68
|
-
export declare const commentDescribesDeclaration: DecisionRule;
|
|
69
|
-
export declare const docErrorsMatchBody: DecisionRule;
|
|
70
|
-
export declare const varNameDescribesValue: DecisionRule;
|
|
71
|
-
export declare const codeClaims: readonly [DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule];
|
|
72
|
-
export declare const describeNamesSubject: DecisionRule;
|
|
73
|
-
export declare const testNameDescribesCode: DecisionRule;
|
|
74
|
-
export declare const testNameVerifiesClaim: DecisionRule;
|
|
75
|
-
export declare const snapshotOnlyBehaviourClaim: DecisionRule;
|
|
76
|
-
export declare const testMocksSubject: DecisionRule;
|
|
77
|
-
export declare const testClaims: readonly [DecisionRule, DecisionRule, DecisionRule, DecisionRule, DecisionRule];
|
|
78
|
-
export { type Preset, plugin as default };
|
|
79
|
-
//# sourceMappingURL=index.d.mts.map
|
|
2
|
+
import { A as safeNameIsSafe, C as docErrorsMatchBody, D as logLevelMatchesEvent, E as idempotentName, O as logMessageMatchesEvent, S as commentDescribesDeclaration, T as fnNamePromises, _ as reviewOnly, a as testNameDescribesCode, b as codeClaims, c as nameMatchesBehavior, d as noPromptInjection, f as preferSchemaValidation, g as recommended, h as presets, i as testMocksSubject, j as varNameDescribesValue, k as pureNameIsPure, l as noHardcodedSecrets, m as Preset, n as snapshotOnlyBehaviourClaim, o as testNameVerifiesClaim, p as untrustedInputRisk, r as testClaims, s as domainNaming, t as describeNamesSubject, u as noPiiInLogs, v as strict, w as errorMessageMatchesCondition, x as commentDescribesBlock, y as catchHidesFailure } from "../index-HOwrGbIA.mjs";
|
|
3
|
+
export { type Preset, catchHidesFailure, codeClaims, commentDescribesBlock, commentDescribesDeclaration, plugin as default, describeNamesSubject, docErrorsMatchBody, domainNaming, errorMessageMatchesCondition, fnNamePromises, idempotentName, logLevelMatchesEvent, logMessageMatchesEvent, nameMatchesBehavior, noHardcodedSecrets, noPiiInLogs, noPromptInjection, preferSchemaValidation, presets, pureNameIsPure, recommended, reviewOnly, safeNameIsSafe, snapshotOnlyBehaviourClaim, strict, testClaims, testMocksSubject, testNameDescribesCode, testNameVerifiesClaim, untrustedInputRisk, varNameDescribesValue };
|
package/dist/presets/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import plugin from "./recommended.mjs";
|
|
2
|
-
import { A as varNameDescribesValue, C as errorMessageMatchesCondition, D as logMessageMatchesEvent, E as logLevelMatchesEvent, O as pureNameIsPure, S as docErrorsMatchBody, T as idempotentName, _ as untrustedInputRisk, a as describeNamesSubject, b as commentDescribesBlock, c as testMocksSubject, d as domainNaming, f as nameMatchesBehavior, g as preferSchemaValidation, h as noPromptInjection, i as strict, k as safeNameIsSafe, l as testNameDescribesCode, m as noPiiInLogs, n as recommended, o as snapshotOnlyBehaviourClaim, p as noHardcodedSecrets, r as reviewOnly, s as testClaims, t as presets, u as testNameVerifiesClaim, v as catchHidesFailure, w as fnNamePromises, x as commentDescribesDeclaration, y as codeClaims } from "../presets-
|
|
2
|
+
import { A as varNameDescribesValue, C as errorMessageMatchesCondition, D as logMessageMatchesEvent, E as logLevelMatchesEvent, O as pureNameIsPure, S as docErrorsMatchBody, T as idempotentName, _ as untrustedInputRisk, a as describeNamesSubject, b as commentDescribesBlock, c as testMocksSubject, d as domainNaming, f as nameMatchesBehavior, g as preferSchemaValidation, h as noPromptInjection, i as strict, k as safeNameIsSafe, l as testNameDescribesCode, m as noPiiInLogs, n as recommended, o as snapshotOnlyBehaviourClaim, p as noHardcodedSecrets, r as reviewOnly, s as testClaims, t as presets, u as testNameVerifiesClaim, v as catchHidesFailure, w as fnNamePromises, x as commentDescribesDeclaration, y as codeClaims } from "../define-presets-yflVt8vT.mjs";
|
|
3
3
|
export { catchHidesFailure, codeClaims, commentDescribesBlock, commentDescribesDeclaration, plugin as default, describeNamesSubject, docErrorsMatchBody, domainNaming, errorMessageMatchesCondition, fnNamePromises, idempotentName, logLevelMatchesEvent, logMessageMatchesEvent, nameMatchesBehavior, noHardcodedSecrets, noPiiInLogs, noPromptInjection, preferSchemaValidation, presets, pureNameIsPure, recommended, reviewOnly, safeNameIsSafe, snapshotOnlyBehaviourClaim, strict, testClaims, testMocksSubject, testNameDescribesCode, testNameVerifiesClaim, untrustedInputRisk, varNameDescribesValue };
|