@r_masseater/msch 0.98.0 → 0.100.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 +1 -18
- package/dist/cargo-inputs.mjs +2 -2
- package/dist/cli.mjs +5215 -1075
- package/dist/cli.mjs.map +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +2 -2
- package/dist/decision-rules.d.mts +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{define-lint-preset-YcRo_ZW9.mjs → define-lint-preset-BnOZuTNT.mjs} +29 -133
- package/dist/define-lint-preset-BnOZuTNT.mjs.map +1 -0
- package/dist/{ignored-directories-D-7Rm_2X.mjs → ignored-directories-DVyp8bfD.mjs} +2 -2
- package/dist/{ignored-directories-D-7Rm_2X.mjs.map → ignored-directories-DVyp8bfD.mjs.map} +1 -1
- package/dist/{index-Dm0Gg9wS.d.mts → index-Cdap8t_F.d.mts} +2 -2
- package/dist/{index-CUrewm-i.d.mts → index-DbmdHsLx.d.mts} +43 -21
- package/dist/lint-rules.mjs +145 -17
- package/dist/lint-rules.mjs.map +1 -1
- package/dist/lint.d.mts +2 -2
- package/dist/lint.mjs +1 -1
- package/dist/oxlint.mjs +4 -3
- package/dist/oxlint.mjs.map +1 -1
- package/dist/{problem-DbuTeNvL.mjs → problem-BTQ96CJ5.mjs} +2 -2
- package/dist/{problem-DbuTeNvL.mjs.map → problem-BTQ96CJ5.mjs.map} +1 -1
- package/dist/{published-3eokcs_D.mjs → published-O6THHxdC.mjs} +172 -6
- package/dist/published-O6THHxdC.mjs.map +1 -0
- package/dist/{repository-files-DSwKJnrj.mjs → repository-files-BwjF-kJ8.mjs} +2 -2
- package/dist/{repository-files-DSwKJnrj.mjs.map → repository-files-BwjF-kJ8.mjs.map} +1 -1
- package/dist/{repository-text-DE4rRWEZ.mjs → repository-text-qZQSVg9L.mjs} +8 -8
- package/dist/repository-text-qZQSVg9L.mjs.map +1 -0
- package/dist/workspace-settings.d.mts +1 -1
- package/dist/workspace-settings.mjs +3 -4
- package/dist/workspace-settings.mjs.map +1 -1
- package/package.json +5 -13
- package/skills/msch-checks/SKILL.md +10 -10
- package/skills/msch-publishing/SKILL.md +12 -12
- package/skills/msch-repository-config/SKILL.md +2 -2
- package/dist/base-revision-Bl-4nxAd.mjs +0 -15
- package/dist/base-revision-Bl-4nxAd.mjs.map +0 -1
- package/dist/changed.d.mts +0 -1
- package/dist/changed.mjs +0 -245
- package/dist/changed.mjs.map +0 -1
- package/dist/cli-contract-D7btWrEu.mjs +0 -5
- package/dist/cli-contract-D7btWrEu.mjs.map +0 -1
- package/dist/define-lint-preset-YcRo_ZW9.mjs.map +0 -1
- package/dist/exits.d.mts +0 -1
- package/dist/exits.mjs +0 -40
- package/dist/exits.mjs.map +0 -1
- package/dist/judge.d.mts +0 -1
- package/dist/judge.mjs +0 -415
- package/dist/judge.mjs.map +0 -1
- package/dist/lookup-report-L5OLXRMf.mjs +0 -29
- package/dist/lookup-report-L5OLXRMf.mjs.map +0 -1
- package/dist/manifest-texts-DPgsV8kj.mjs +0 -19
- package/dist/manifest-texts-DPgsV8kj.mjs.map +0 -1
- package/dist/output-DAvdel9H.mjs +0 -33
- package/dist/output-DAvdel9H.mjs.map +0 -1
- package/dist/package-routes-BQWX5ttU.mjs +0 -73
- package/dist/package-routes-BQWX5ttU.mjs.map +0 -1
- package/dist/package-versions-sx15IGwA.mjs +0 -92
- package/dist/package-versions-sx15IGwA.mjs.map +0 -1
- package/dist/pass-records-BcAAWgiQ.mjs +0 -437
- package/dist/pass-records-BcAAWgiQ.mjs.map +0 -1
- package/dist/publish.d.mts +0 -1
- package/dist/publish.mjs +0 -1596
- package/dist/publish.mjs.map +0 -1
- package/dist/published-3eokcs_D.mjs.map +0 -1
- package/dist/published.d.mts +0 -1
- package/dist/published.mjs +0 -134
- package/dist/published.mjs.map +0 -1
- package/dist/refs.d.mts +0 -1
- package/dist/refs.mjs +0 -232
- package/dist/refs.mjs.map +0 -1
- package/dist/registries-DePiYd3D.mjs +0 -11
- package/dist/registries-DePiYd3D.mjs.map +0 -1
- package/dist/registry-releases-BBtz4wGE.mjs +0 -62
- package/dist/registry-releases-BBtz4wGE.mjs.map +0 -1
- package/dist/repository-text-DE4rRWEZ.mjs.map +0 -1
- package/dist/runtime-Djm7zMwu.mjs +0 -13
- package/dist/runtime-Djm7zMwu.mjs.map +0 -1
- package/dist/specifiers-BrCyPubD.mjs +0 -32
- package/dist/specifiers-BrCyPubD.mjs.map +0 -1
- package/dist/tree-sitter-BfzHNwTR.mjs +0 -41
- package/dist/tree-sitter-BfzHNwTR.mjs.map +0 -1
- package/dist/unbumped.d.mts +0 -1
- package/dist/unbumped.mjs +0 -19
- package/dist/unbumped.mjs.map +0 -1
- package/dist/upstream-exits-4bn4gblF.mjs +0 -357
- package/dist/upstream-exits-4bn4gblF.mjs.map +0 -1
- package/dist/upstream-record-DRNGym9S.mjs +0 -136
- package/dist/upstream-record-DRNGym9S.mjs.map +0 -1
- package/dist/upstream.d.mts +0 -1
- package/dist/upstream.mjs +0 -104
- package/dist/upstream.mjs.map +0 -1
- package/dist/workspace-manifest-BAVyPzbA.mjs +0 -8
- package/dist/workspace-manifest-BAVyPzbA.mjs.map +0 -1
- package/dist/workspace-projects-MpL8K7Nz.mjs +0 -172
- package/dist/workspace-projects-MpL8K7Nz.mjs.map +0 -1
package/dist/lint-rules.mjs
CHANGED
|
@@ -78,7 +78,7 @@ const childrenOf = (keys, node) => pipe(Option.liftPredicate(node, Predicate.isO
|
|
|
78
78
|
const descendants = (keys) => (node) => [node, ...pipe(childrenOf(keys, node), Array.flatMap(descendants(keys)))];
|
|
79
79
|
const accessesIn = (scope) => (method) => (node) => pipe(descendants(scope.keys)(node), Array.map(accessOf(scope)(method)), Array.getSomes);
|
|
80
80
|
// src/features/define-lint-rules/model/array-from-async.ts
|
|
81
|
-
const MESSAGE$
|
|
81
|
+
const MESSAGE$7 = "Collect an async iterable with Array.fromAsync, passing the mapping as its second argument. Do not push each item from a for await loop.";
|
|
82
82
|
const ONE$1 = 1;
|
|
83
83
|
const DeclarationSchema = Schema.Struct({
|
|
84
84
|
type: Schema.Literal("VariableDeclaration"),
|
|
@@ -112,7 +112,7 @@ const arrayFromAsync = {
|
|
|
112
112
|
create: (context) => ({ ForOfStatement: (node) => {
|
|
113
113
|
if (collectsByHand(node)) context.report({
|
|
114
114
|
node,
|
|
115
|
-
message: MESSAGE$
|
|
115
|
+
message: MESSAGE$7
|
|
116
116
|
});
|
|
117
117
|
} })
|
|
118
118
|
};
|
|
@@ -211,7 +211,7 @@ const typedRuleOf = ({ meta, visitorOf }) => withTypeInformation({
|
|
|
211
211
|
});
|
|
212
212
|
// src/features/define-lint-rules/model/explicit-import-path.ts
|
|
213
213
|
const MESSAGE_ID$1 = "spellOut";
|
|
214
|
-
const MESSAGE$
|
|
214
|
+
const MESSAGE$6 = "`{{specifier}}` does not name a file. Write `{{fixed}}`: Node ESM and TypeScript nodenext resolve neither a missing extension nor a directory index, so spelling out the file works under every resolver.";
|
|
215
215
|
const RELATIVE = /^\.{1,2}(?:\/|$)/u;
|
|
216
216
|
const PARTS = /^(?<path>[^?]*)(?<query>.*)$/su;
|
|
217
217
|
const TRAILING_SEPARATORS = /\/+$/u;
|
|
@@ -268,12 +268,12 @@ const explicitImportPath = typedRuleOf({
|
|
|
268
268
|
meta: {
|
|
269
269
|
type: "suggestion",
|
|
270
270
|
fixable: "code",
|
|
271
|
-
messages: { [MESSAGE_ID$1]: MESSAGE$
|
|
271
|
+
messages: { [MESSAGE_ID$1]: MESSAGE$6 }
|
|
272
272
|
},
|
|
273
273
|
visitorOf: visitorOf$1
|
|
274
274
|
});
|
|
275
275
|
// src/features/define-lint-rules/model/get-or-insert.ts
|
|
276
|
-
const MESSAGE$
|
|
276
|
+
const MESSAGE$5 = "Use getOrInsert or getOrInsertComputed on the Map or WeakMap, so that reading a key and storing its first value is one call. Do not read the key and then set it by hand.";
|
|
277
277
|
const ONE = 1;
|
|
278
278
|
const TWO = 2;
|
|
279
279
|
const OPTION_FROM = /^(?:Option\.)?from(?:NullishOr|UndefinedOr|Nullable)$/u;
|
|
@@ -382,24 +382,24 @@ const getOrInsert = {
|
|
|
382
382
|
IfStatement: (node) => {
|
|
383
383
|
if (isHasGuard(scope, node)) context.report({
|
|
384
384
|
node,
|
|
385
|
-
message: MESSAGE$
|
|
385
|
+
message: MESSAGE$5
|
|
386
386
|
});
|
|
387
387
|
},
|
|
388
388
|
BlockStatement: (node) => {
|
|
389
389
|
for (const index of fallbackIndices(scope, node.body)) for (const statement of Option.toArray(Array.get(node.body, index))) context.report({
|
|
390
390
|
node: statement,
|
|
391
|
-
message: MESSAGE$
|
|
391
|
+
message: MESSAGE$5
|
|
392
392
|
});
|
|
393
393
|
if (isMemoized(scope, node)) context.report({
|
|
394
394
|
node,
|
|
395
|
-
message: MESSAGE$
|
|
395
|
+
message: MESSAGE$5
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
// src/features/define-lint-rules/model/inline-exports.ts
|
|
402
|
-
const MESSAGE$
|
|
402
|
+
const MESSAGE$4 = "export は宣言に付ける(export const・export function など)。ファイルの末尾で export { … } にまとめない。";
|
|
403
403
|
const TYPE = "type";
|
|
404
404
|
const CLASS_NAME = "ClassName";
|
|
405
405
|
const isList = (node) => node.declaration === null && node.source === null && !Array.isReadonlyArrayEmpty(node.specifiers);
|
|
@@ -414,7 +414,7 @@ const inlineExports = {
|
|
|
414
414
|
create: (context) => ({ ExportNamedDeclaration: (node) => {
|
|
415
415
|
if (isList(node) && !pipe(node.specifiers, Array.every(isTypeOnlyClass(context, node)))) context.report({
|
|
416
416
|
node,
|
|
417
|
-
message: MESSAGE$
|
|
417
|
+
message: MESSAGE$4
|
|
418
418
|
});
|
|
419
419
|
} })
|
|
420
420
|
};
|
|
@@ -423,7 +423,7 @@ const SOURCE = "/src/";
|
|
|
423
423
|
const TOOL_LAYERS = ["features", "shared"];
|
|
424
424
|
const TEST_FILE = /\.test(?:\.support)?\.[cm]?[jt]sx?$/u;
|
|
425
425
|
const METHOD = "registerTool";
|
|
426
|
-
const MESSAGE$
|
|
426
|
+
const MESSAGE$3 = "Register an MCP tool in the features slice of the operation it performs. A tool is one operation, so app/ only composes the slices' register functions and entities/ only holds the data they share.";
|
|
427
427
|
const layerIn = (path) => pipe(String$1.lastIndexOf(SOURCE)(path), Option.map((index) => Array.headNonEmpty(segments(String$1.slice(index + 5)(path)))));
|
|
428
428
|
const layerOf = (filename) => layerIn(toPosix(filename));
|
|
429
429
|
const outsideToolLayers = (filename) => !TEST_FILE.test(filename) && Option.exists(layerOf(filename), (layer) => !Array.contains(TOOL_LAYERS, layer));
|
|
@@ -435,7 +435,7 @@ const mcpToolLayer = {
|
|
|
435
435
|
const { callee } = node;
|
|
436
436
|
if (callee.type === "MemberExpression" && callee.property.type === "Identifier" && callee.property.name === METHOD) context.report({
|
|
437
437
|
node: callee.property,
|
|
438
|
-
message: MESSAGE$
|
|
438
|
+
message: MESSAGE$3
|
|
439
439
|
});
|
|
440
440
|
} };
|
|
441
441
|
}
|
|
@@ -559,7 +559,7 @@ const writablePartOf = (project) => (type) => {
|
|
|
559
559
|
return partOf(type);
|
|
560
560
|
};
|
|
561
561
|
// src/features/define-lint-rules/model/readonly-parameters.ts
|
|
562
|
-
const MESSAGE$
|
|
562
|
+
const MESSAGE$2 = "A function must not be able to change its arguments, but {{part}}. Declare the parameter with a read-only type. Types declared by a package or by the language are exempt unless the language has a read-only form of them.";
|
|
563
563
|
const MESSAGE_ID = "shouldBeReadonly";
|
|
564
564
|
const WHOLE = "the type";
|
|
565
565
|
const SEPARATOR = ".";
|
|
@@ -633,12 +633,12 @@ const visitorOf = (context, services) => {
|
|
|
633
633
|
const readonlyParameters = typedRuleOf({
|
|
634
634
|
meta: {
|
|
635
635
|
type: "suggestion",
|
|
636
|
-
messages: { [MESSAGE_ID]: MESSAGE$
|
|
636
|
+
messages: { [MESSAGE_ID]: MESSAGE$2 }
|
|
637
637
|
},
|
|
638
638
|
visitorOf
|
|
639
639
|
});
|
|
640
640
|
// src/features/define-lint-rules/model/separate-min-max.ts
|
|
641
|
-
const MESSAGE = "Select min and max in separate queries. SQLite uses an index for a lone min or max only, so one select with both reads every row in the range, and D1 bills each row read.";
|
|
641
|
+
const MESSAGE$1 = "Select min and max in separate queries. SQLite uses an index for a lone min or max only, so one select with both reads every row in the range, and D1 bills each row read.";
|
|
642
642
|
const AggregateCallSchema = Schema.Struct({
|
|
643
643
|
type: Schema.Literal("CallExpression"),
|
|
644
644
|
callee: Schema.Struct({
|
|
@@ -677,7 +677,7 @@ const separateMinMax = {
|
|
|
677
677
|
create: (context) => ({ CallExpression: (node) => {
|
|
678
678
|
if (selectsBoth(node)) context.report({
|
|
679
679
|
node,
|
|
680
|
-
message: MESSAGE
|
|
680
|
+
message: MESSAGE$1
|
|
681
681
|
});
|
|
682
682
|
} })
|
|
683
683
|
};
|
|
@@ -1323,6 +1323,128 @@ const INTENTS = {
|
|
|
1323
1323
|
"run"
|
|
1324
1324
|
]
|
|
1325
1325
|
}]
|
|
1326
|
+
},
|
|
1327
|
+
"declared-arguments": {
|
|
1328
|
+
message: "Declare what a command takes with Command, Flag and Argument from effect/cli, and pass the typed input to a function. Do not read the argument list by hand: hand-written parsing is code that only an entry has, so no other rule or test covers it.",
|
|
1329
|
+
imports: [],
|
|
1330
|
+
members: [{
|
|
1331
|
+
object: "process",
|
|
1332
|
+
properties: ["argv"]
|
|
1333
|
+
}, {
|
|
1334
|
+
object: "stdio",
|
|
1335
|
+
properties: ["args"]
|
|
1336
|
+
}],
|
|
1337
|
+
home: Option.none()
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1340
|
+
// src/features/define-lint-rules/model/model-call-rules.ts
|
|
1341
|
+
const UNGATED = "モデルの呼び出しは AI Gateway を通す。通らない呼び出しには日ごとの費用の上限が掛からず、無料枠を超えた分がそのまま請求される";
|
|
1342
|
+
const MODEL_RUN = "CallExpression[callee.property.name=\"run\"]:matches([callee.object.name=\"AI\"], [callee.object.property.name=\"AI\"])";
|
|
1343
|
+
const AI_RUN_REQUEST = `CallExpression:has(> :matches(Literal[value=/ai.run/], TemplateLiteral:has(TemplateElement[value.raw=/ai.run/])))`;
|
|
1344
|
+
const GATEWAY = "CallExpression[callee.object.name=\"AI\"][callee.property.name=\"Gateway\"]";
|
|
1345
|
+
const MODEL_CALL_RULES = {
|
|
1346
|
+
"attributed-model-call": {
|
|
1347
|
+
message: "モデルの呼び出しは AI Gateway を通し、呼び出し元を metadata に載せる。載せないと、費用やエラーを後から呼び出し元で引けない",
|
|
1348
|
+
selectors: [
|
|
1349
|
+
`${MODEL_RUN}[arguments.length<3]`,
|
|
1350
|
+
"CallExpression[callee.name=\"runWorkersAi\"] > ObjectExpression > Property[key.name=\"call\"] > ArrowFunctionExpression[params.length=0]",
|
|
1351
|
+
"CallExpression[callee.name=\"createAI\"] > ObjectExpression.arguments:not(:has(Property[key.name=\"metadata\"]))",
|
|
1352
|
+
"ObjectExpression:has(Property[key.value=\"cf-aig-gateway-id\"]):not(:has(Property[key.value=\"cf-aig-metadata\"]))"
|
|
1353
|
+
]
|
|
1354
|
+
},
|
|
1355
|
+
"gated-model-call": {
|
|
1356
|
+
message: `${UNGATED}。AI.run の第 3 引数には、runWorkersAi の call が受け取る options をそのまま渡す`,
|
|
1357
|
+
selectors: [`${MODEL_RUN} > .arguments:nth-child(3):not(Identifier[name="options"])`]
|
|
1358
|
+
},
|
|
1359
|
+
"gated-model-request": {
|
|
1360
|
+
message: `${UNGATED}。REST の /ai/run を呼ぶときは、headers に cf-aig-gateway-id を付ける`,
|
|
1361
|
+
selectors: [`${AI_RUN_REQUEST} > ObjectExpression.arguments:not(:has(Property[key.name="headers"]))`, `${AI_RUN_REQUEST} > ObjectExpression.arguments > Property[key.name="headers"] > ObjectExpression:not(:has(Property[key.value="cf-aig-gateway-id"]))`]
|
|
1362
|
+
},
|
|
1363
|
+
"workers-ai-through-runner": {
|
|
1364
|
+
message: "Workers AI は @r_masseater/masseater-utils/workers-tracing/workers-ai の runWorkersAi の中で呼ぶ。外で呼ぶと、容量不足のエラーが再試行されず、途中で切れた答えもログに残らない",
|
|
1365
|
+
selectors: [`${MODEL_RUN}:not(CallExpression[callee.name="runWorkersAi"] *)`]
|
|
1366
|
+
},
|
|
1367
|
+
"ai-gateway-logs": {
|
|
1368
|
+
message: "AI Gateway には collectLogs: true を付ける。付けないと、モデルの呼び出しが後から引けない",
|
|
1369
|
+
selectors: [`${GATEWAY} > ObjectExpression.arguments:not(:has(Property[key.name="collectLogs"][value.value=true]))`]
|
|
1370
|
+
},
|
|
1371
|
+
"ai-gateway-spend-limit": {
|
|
1372
|
+
message: "AI Gateway には spendLimits を enabled: true で付け、日ごとの費用の上限を掛ける。付けないと、従量課金のモデルの呼び出しが上限なく請求される",
|
|
1373
|
+
selectors: [`${GATEWAY} > ObjectExpression.arguments:not(:has(Property[key.name="spendLimits"] > ObjectExpression > Property[key.name="enabled"][value.value=true]))`]
|
|
1374
|
+
},
|
|
1375
|
+
"ai-gateway-cache": {
|
|
1376
|
+
message: "AI Gateway には cacheTtl を付け、同じ問いの答えをキャッシュする。付けないと、同じ問いにも毎回課金される",
|
|
1377
|
+
selectors: [`${GATEWAY} > ObjectExpression.arguments:not(:has(Property[key.name="cacheTtl"]))`]
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
// src/features/define-lint-rules/model/resource-rules.ts
|
|
1381
|
+
const LOGPUSH = "Property[key.name=\"logpush\"]:not([value.value=false])";
|
|
1382
|
+
const CPU_LIMIT = "Property[key.name=\"limits\"]:has(Property[key.name=\"cpuMs\"])";
|
|
1383
|
+
const RESOURCE_RULES = {
|
|
1384
|
+
"worker-logpush": {
|
|
1385
|
+
message: "Worker には logpush: true を付ける。付けないと、その Worker のログが Logpush に流れない",
|
|
1386
|
+
selectors: [`CallExpression[callee.object.name="Workers"][callee.property.name="Worker"] > ObjectExpression.arguments:not(:has(${LOGPUSH}))`, `CallExpression[callee.object.name="Website"] > ObjectExpression.arguments:not(:has(${LOGPUSH}))`]
|
|
1387
|
+
},
|
|
1388
|
+
"worker-cpu-limit": {
|
|
1389
|
+
message: "コードを動かす Worker には limits.cpuMs を付け、本番の CPU 時間の最大値をわずかに上回る値にする。付けないと、1 回の暴走が上限の CPU 時間まで請求される",
|
|
1390
|
+
selectors: [`CallExpression[callee.object.name=/^(Workers|Website)$/] > ObjectExpression.arguments:has(Property[key.name="main"]):not(:has(${CPU_LIMIT}))`, `CallExpression[callee.object.name="Website"]:not([callee.property.name="StaticSite"]) > ObjectExpression.arguments:not(:has(${CPU_LIMIT}))`]
|
|
1391
|
+
},
|
|
1392
|
+
"protected-storage": {
|
|
1393
|
+
message: "D1 と R2 は作り直すと中身が消えるので、alchemy の RemovalPolicy.protect() を .pipe で付けて置き換えと削除を止める",
|
|
1394
|
+
selectors: ["CallExpression[callee.object.name=/^(D1|R2)$/][callee.property.name=/^(Database|Bucket)$/]:not(CallExpression[callee.property.name=\"pipe\"][arguments.0.callee.object.name=\"RemovalPolicy\"] > MemberExpression.callee > CallExpression.object)"]
|
|
1395
|
+
},
|
|
1396
|
+
"stack-named-by-app": {
|
|
1397
|
+
message: "スタック名には app-name.ts の APP_NAME を渡す",
|
|
1398
|
+
selectors: ["CallExpression[callee.name=\"Stack\"]:not([arguments.0.name=\"APP_NAME\"])"]
|
|
1399
|
+
},
|
|
1400
|
+
"stack-checks-app-prefix": {
|
|
1401
|
+
message: "スタックの最後で app-name.ts の requireAppPrefix を yield* して、リソース名の prefix を検査する",
|
|
1402
|
+
selectors: ["Program:not(:has(YieldExpression[delegate=true] > Identifier.argument[name=\"requireAppPrefix\"]))", "CallExpression[callee.name=\"Stack\"] > .arguments:nth-child(3):not(:has(FunctionExpression > BlockStatement > ExpressionStatement:nth-last-child(2) > YieldExpression[delegate=true] > Identifier.argument[name=\"requireAppPrefix\"]))"]
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
// src/features/define-lint-rules/model/selector-rule.ts
|
|
1406
|
+
const selectorRule = (restriction) => ({
|
|
1407
|
+
meta: { type: "problem" },
|
|
1408
|
+
create: (context) => pipe(Array.dedupe(restriction.selectors), Array.map((selector) => [selector, selector]), Record.fromEntries, Record.map(() => (node) => {
|
|
1409
|
+
context.report({
|
|
1410
|
+
node,
|
|
1411
|
+
message: restriction.message
|
|
1412
|
+
});
|
|
1413
|
+
}))
|
|
1414
|
+
});
|
|
1415
|
+
// src/features/define-lint-rules/model/test-honesty-rules.ts
|
|
1416
|
+
const TEST_HONESTY_RULES = {
|
|
1417
|
+
"no-test-doubles": {
|
|
1418
|
+
message: "依存の振る舞いを差し替えない。Effect の Layer を差し替えるか、本物の実装を使う",
|
|
1419
|
+
selectors: ["CallExpression[callee.object.name=\"vi\"][callee.property.name=/^(mock|doMock)$/]", "CallExpression[callee.object.name=\"vi\"][callee.property.name=\"stubGlobal\"]"]
|
|
1420
|
+
},
|
|
1421
|
+
"no-flake-masking": {
|
|
1422
|
+
message: "再試行や flakyTest で不安定なテストを隠さない。待つ対象のイベントを await して直す",
|
|
1423
|
+
selectors: [
|
|
1424
|
+
"Property[key.name=\"retry\"]",
|
|
1425
|
+
"MemberExpression[property.name=\"retry\"]",
|
|
1426
|
+
"MemberExpression[property.name=\"flakyTest\"]"
|
|
1427
|
+
]
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
// src/features/define-lint-rules/model/wiring-only-commands.ts
|
|
1431
|
+
const MESSAGE = "Keep a command file to its imports and the call that starts the command. Put functions and classes in a slice under src, where the same lint rules, tests and unused-code checks cover them as any other code.";
|
|
1432
|
+
const wiringOnlyCommands = {
|
|
1433
|
+
meta: { type: "problem" },
|
|
1434
|
+
create: (context) => {
|
|
1435
|
+
const report = (node) => {
|
|
1436
|
+
context.report({
|
|
1437
|
+
node,
|
|
1438
|
+
message: MESSAGE
|
|
1439
|
+
});
|
|
1440
|
+
};
|
|
1441
|
+
return {
|
|
1442
|
+
FunctionDeclaration: report,
|
|
1443
|
+
FunctionExpression: report,
|
|
1444
|
+
ArrowFunctionExpression: report,
|
|
1445
|
+
ClassDeclaration: report,
|
|
1446
|
+
ClassExpression: report
|
|
1447
|
+
};
|
|
1326
1448
|
}
|
|
1327
1449
|
};
|
|
1328
1450
|
// src/features/define-lint-rules/model/plugin.ts
|
|
@@ -1330,7 +1452,13 @@ const mschLintPlugin = {
|
|
|
1330
1452
|
meta: { name: "msch-lint" },
|
|
1331
1453
|
rules: {
|
|
1332
1454
|
...CODED_RULES,
|
|
1333
|
-
|
|
1455
|
+
"wiring-only-commands": wiringOnlyCommands,
|
|
1456
|
+
...pipe(INTENTS, Record.map(ruleOf)),
|
|
1457
|
+
...pipe({
|
|
1458
|
+
...RESOURCE_RULES,
|
|
1459
|
+
...MODEL_CALL_RULES,
|
|
1460
|
+
...TEST_HONESTY_RULES
|
|
1461
|
+
}, Record.map(selectorRule))
|
|
1334
1462
|
}
|
|
1335
1463
|
};
|
|
1336
1464
|
export { mschLintPlugin as default };
|