@warlock.js/grimoire 5.63.0 → 5.64.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/CHANGELOG.md +44 -0
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs +24 -2
- package/esm/book/build.mjs.map +1 -1
- package/esm/check/check-grimoire.d.mts.map +1 -1
- package/esm/check/check-grimoire.mjs +11 -1
- package/esm/check/check-grimoire.mjs.map +1 -1
- package/esm/check/rules/api-snapshot.mjs +39 -0
- package/esm/check/rules/api-snapshot.mjs.map +1 -0
- package/esm/check/rules/code-rules.mjs +45 -0
- package/esm/check/rules/code-rules.mjs.map +1 -0
- package/esm/check/rules/drift.mjs +54 -0
- package/esm/check/rules/drift.mjs.map +1 -0
- package/esm/check/rules/focused-tests.mjs +39 -0
- package/esm/check/rules/focused-tests.mjs.map +1 -0
- package/esm/check/rules/shows.mjs +52 -0
- package/esm/check/rules/shows.mjs.map +1 -0
- package/esm/codes/codes.d.mts +48 -0
- package/esm/codes/codes.d.mts.map +1 -1
- package/esm/codes/codes.mjs +26 -1
- package/esm/codes/codes.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +6 -0
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/guard.d.mts +104 -0
- package/esm/contracts/guard.d.mts.map +1 -0
- package/esm/contracts/index.mjs +5 -0
- package/esm/contracts/matrix.d.mts +75 -0
- package/esm/contracts/matrix.d.mts.map +1 -0
- package/esm/contracts/scry.d.mts +21 -0
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/contracts/settings.d.mts +71 -0
- package/esm/contracts/settings.d.mts.map +1 -0
- package/esm/contracts/settings.mjs +67 -0
- package/esm/contracts/settings.mjs.map +1 -0
- package/esm/contracts/shots.d.mts +146 -0
- package/esm/contracts/shots.d.mts.map +1 -0
- package/esm/contracts/snapshot.d.mts +10 -0
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/contracts/written.d.mts +13 -0
- package/esm/contracts/written.d.mts.map +1 -1
- package/esm/contracts/written.mjs +7 -1
- package/esm/contracts/written.mjs.map +1 -1
- package/esm/devtools/approvals.mjs +59 -0
- package/esm/devtools/approvals.mjs.map +1 -0
- package/esm/devtools/data.mjs +2 -0
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/graphs.mjs +13 -3
- package/esm/devtools/graphs.mjs.map +1 -1
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +32 -2
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/matrix.mjs +207 -0
- package/esm/devtools/matrix.mjs.map +1 -0
- package/esm/devtools/product-map.d.mts.map +1 -1
- package/esm/devtools/product-map.mjs +87 -1
- package/esm/devtools/product-map.mjs.map +1 -1
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +12 -3
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +5 -1
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/git/index.d.mts +20 -0
- package/esm/git/index.d.mts.map +1 -0
- package/esm/git/index.mjs +280 -0
- package/esm/git/index.mjs.map +1 -0
- package/esm/guard/api.mjs +70 -0
- package/esm/guard/api.mjs.map +1 -0
- package/esm/guard/assertions.mjs +18 -0
- package/esm/guard/assertions.mjs.map +1 -0
- package/esm/guard/collect.mjs +139 -0
- package/esm/guard/collect.mjs.map +1 -0
- package/esm/guard/format.mjs +27 -0
- package/esm/guard/format.mjs.map +1 -0
- package/esm/guard/glob.mjs +79 -0
- package/esm/guard/glob.mjs.map +1 -0
- package/esm/guard/index.mjs +9 -0
- package/esm/guard/rules.mjs +310 -0
- package/esm/guard/rules.mjs.map +1 -0
- package/esm/guard/scope.mjs +95 -0
- package/esm/guard/scope.mjs.map +1 -0
- package/esm/index.d.mts +10 -3
- package/esm/index.mjs +6 -2
- package/esm/paths/index.d.mts +15 -1
- package/esm/paths/index.d.mts.map +1 -1
- package/esm/paths/index.mjs +27 -3
- package/esm/paths/index.mjs.map +1 -1
- package/esm/proves/index.mjs +2 -1
- package/esm/proves/scan-proofs.mjs +1 -1
- package/esm/proves/scan-proofs.mjs.map +1 -1
- package/esm/proves/scan-shows.d.mts +21 -0
- package/esm/proves/scan-shows.d.mts.map +1 -0
- package/esm/proves/scan-shows.mjs +168 -0
- package/esm/proves/scan-shows.mjs.map +1 -0
- package/esm/releases/index.d.mts.map +1 -1
- package/esm/releases/index.mjs +5 -3
- package/esm/releases/index.mjs.map +1 -1
- package/esm/releases/stamp.mjs +121 -0
- package/esm/releases/stamp.mjs.map +1 -0
- package/esm/rules/focused.mjs +26 -0
- package/esm/rules/focused.mjs.map +1 -0
- package/esm/rules/index.mjs +88 -0
- package/esm/rules/index.mjs.map +1 -0
- package/esm/rules/logical-css.mjs +112 -0
- package/esm/rules/logical-css.mjs.map +1 -0
- package/esm/rules/no-js-imports.mjs +22 -0
- package/esm/rules/no-js-imports.mjs.map +1 -0
- package/esm/rules/scan.mjs +196 -0
- package/esm/rules/scan.mjs.map +1 -0
- package/esm/rules/specific-errors.mjs +51 -0
- package/esm/rules/specific-errors.mjs.map +1 -0
- package/esm/rules/type-discriminator.mjs +27 -0
- package/esm/rules/type-discriminator.mjs.map +1 -0
- package/esm/scry/also-changes.mjs +106 -0
- package/esm/scry/also-changes.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +22 -0
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +7 -2
- package/esm/scry/query.mjs.map +1 -1
- package/esm/scry/search.d.mts.map +1 -1
- package/esm/scry/search.mjs +43 -11
- package/esm/scry/search.mjs.map +1 -1
- package/esm/shots/approve.mjs +195 -0
- package/esm/shots/approve.mjs.map +1 -0
- package/esm/shots/drift.mjs +174 -0
- package/esm/shots/drift.mjs.map +1 -0
- package/esm/shots/png.mjs +166 -0
- package/esm/shots/png.mjs.map +1 -0
- package/esm/shots/state.mjs +43 -0
- package/esm/shots/state.mjs.map +1 -0
- package/esm/shots/store.mjs +66 -0
- package/esm/shots/store.mjs.map +1 -0
- package/esm/shots/touched.mjs +38 -0
- package/esm/shots/touched.mjs.map +1 -0
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +15 -2
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/api-command.mjs +41 -0
- package/esm/warlock/api-command.mjs.map +1 -0
- package/esm/warlock/approve-command.mjs +80 -0
- package/esm/warlock/approve-command.mjs.map +1 -0
- package/esm/warlock/commands.d.mts +1 -1
- package/esm/warlock/commands.d.mts.map +1 -1
- package/esm/warlock/commands.mjs +61 -8
- package/esm/warlock/commands.mjs.map +1 -1
- package/esm/warlock/guard-command.mjs +116 -0
- package/esm/warlock/guard-command.mjs.map +1 -0
- package/esm/warlock/index.d.mts +2 -1
- package/esm/warlock/index.mjs +2 -1
- package/esm/warlock/languages.mjs +75 -0
- package/esm/warlock/languages.mjs.map +1 -0
- package/esm/warlock/mcp-tools.mjs +2 -2
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/warlock/release-command.mjs +65 -0
- package/esm/warlock/release-command.mjs.map +1 -0
- package/esm/warlock/shows.d.mts +35 -0
- package/esm/warlock/shows.d.mts.map +1 -0
- package/esm/warlock/shows.mjs +195 -0
- package/esm/warlock/shows.mjs.map +1 -0
- package/esm/workspace/cache.mjs +4 -1
- package/esm/workspace/cache.mjs.map +1 -1
- package/esm/workspace/derived.mjs +11 -6
- package/esm/workspace/derived.mjs.map +1 -1
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +8 -1
- package/esm/workspace/index.mjs.map +1 -1
- package/esm/workspace/stored.mjs +4 -1
- package/esm/workspace/stored.mjs.map +1 -1
- package/esm/written/features.mjs +21 -5
- package/esm/written/features.mjs.map +1 -1
- package/esm/written/index.mjs +2 -1
- package/esm/written/parse-grimoire.d.mts.map +1 -1
- package/esm/written/parse-grimoire.mjs +16 -3
- package/esm/written/parse-grimoire.mjs.map +1 -1
- package/esm/written/settings.d.mts +11 -0
- package/esm/written/settings.d.mts.map +1 -0
- package/esm/written/settings.mjs +88 -0
- package/esm/written/settings.mjs.map +1 -0
- package/llms-full.txt +276 -39
- package/llms.txt +2 -0
- package/package.json +3 -3
- package/skills/backfill-a-grimoire/SKILL.md +4 -0
- package/skills/describe-an-app/SKILL.md +4 -1
- package/skills/guard-a-change/SKILL.md +85 -0
- package/skills/index.md +7 -3
- package/skills/record-a-change/SKILL.md +52 -16
- package/skills/review-a-change/SKILL.md +53 -0
- package/skills/use-the-grimoire/SKILL.md +21 -18
- package/skills/write-a-feature/SKILL.md +42 -1
- package/ui/grimoire-view.js +756 -40
- package/ui/grimoire.css +303 -28
- package/ui/product-map.css +43 -7
- package/ui/product-map.js +212 -37
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
//#region ../../packages/grimoire/src/rules/logical-css.ts
|
|
2
|
+
/** CSS property names that are physical, matched in CSS files and in strings (`margin-left:`). */
|
|
3
|
+
const PHYSICAL_PROPERTY = new RegExp([
|
|
4
|
+
String.raw`(?:margin|padding|scroll-margin|scroll-padding)-(?:left|right)`,
|
|
5
|
+
String.raw`border-(?:left|right)(?:-(?:width|style|color))?`,
|
|
6
|
+
String.raw`border-(?:top|bottom)-(?:left|right)-radius`
|
|
7
|
+
].join("|"));
|
|
8
|
+
const PHYSICAL_PROPERTY_DECLARATION = new RegExp(`(?<![\\w-])(${PHYSICAL_PROPERTY.source})\\s*:`, "g");
|
|
9
|
+
/** `left:` and `right:` as properties (CSS files only). */
|
|
10
|
+
const POSITION_DECLARATION = /(?<![\w-])(left|right)\s*:(?!:)/g;
|
|
11
|
+
const DIRECTION_VALUE = /(?<![\w-])(text-align|float|clear)\s*:\s*(left|right)\b/g;
|
|
12
|
+
/** Camel-case style keys (`style={{ marginLeft: 4 }}`). */
|
|
13
|
+
const CAMEL_KEY = /(?<![\w$.])(marginLeft|marginRight|paddingLeft|paddingRight|borderLeft(?:Width|Style|Color)?|borderRight(?:Width|Style|Color)?|borderTopLeftRadius|borderTopRightRadius|borderBottomLeftRadius|borderBottomRightRadius|scrollMarginLeft|scrollMarginRight|scrollPaddingLeft|scrollPaddingRight)\s*:/g;
|
|
14
|
+
const CAMEL_DIRECTION_VALUE = /(?<![\w$.])(textAlign|float|clear)\s*:\s*["'`](left|right)["'`]/g;
|
|
15
|
+
/** `left: 0`, `right: "8px"`: a bare key counts only with a length-like value, so data objects with `left`/`right` fields pass. */
|
|
16
|
+
const POSITION_KEY = /(?<![\w$.-])(left|right)\s*:\s*(?:-?\d[\d.]*|["'`]-?[\d.]+(?:px|rem|em|%|vw|vh)?["'`]|["'`]auto["'`])/g;
|
|
17
|
+
const VARIANTS = String.raw`(?:(?:[a-z0-9_-]+|\[[^\]\s]+\]):)*`;
|
|
18
|
+
const LENGTH = String.raw`(?:\d[\d./]*|px|auto|full|\[[^\]]+\]|\([^)]+\))`;
|
|
19
|
+
/** A Tailwind-style class token with a physical direction. */
|
|
20
|
+
const CLASS_TOKEN = new RegExp(`^${VARIANTS}!?(?:-?m[lr]-${LENGTH}|-?p[lr]-${LENGTH}|-?(?:left|right)-${LENGTH}|text-(?:left|right)|float-(?:left|right)|border-[lr](?:-\\S+)?|rounded-(?:[lr]|t[lr]|b[lr])(?:-\\S+)?|scroll-m[lr]-${LENGTH}|scroll-p[lr]-${LENGTH})!?$`);
|
|
21
|
+
const LOGICAL = {
|
|
22
|
+
"margin-left": "margin-inline-start",
|
|
23
|
+
"margin-right": "margin-inline-end",
|
|
24
|
+
"padding-left": "padding-inline-start",
|
|
25
|
+
"padding-right": "padding-inline-end",
|
|
26
|
+
left: "inset-inline-start",
|
|
27
|
+
right: "inset-inline-end"
|
|
28
|
+
};
|
|
29
|
+
function suggestion(text) {
|
|
30
|
+
const property = text.toLowerCase().replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
31
|
+
const logical = LOGICAL[property];
|
|
32
|
+
return logical ? ` (use ${logical})` : "";
|
|
33
|
+
}
|
|
34
|
+
function classSuggestion(token) {
|
|
35
|
+
const base = token.slice(token.lastIndexOf(":") + 1).replace(/^!/, "");
|
|
36
|
+
if (/^-?m[lr]-/.test(base)) return base.replace(/m([lr])-/, (_all, side) => `m${side === "l" ? "s" : "e"}-`);
|
|
37
|
+
if (/^-?p[lr]-/.test(base)) return base.replace(/p([lr])-/, (_all, side) => `p${side === "l" ? "s" : "e"}-`);
|
|
38
|
+
if (/^-?(?:left|right)-/.test(base)) return base.replace(/(left|right)-/, (_all, side) => `${side === "left" ? "start" : "end"}-`);
|
|
39
|
+
if (/^text-/.test(base)) return base.replace(/left|right/, (side) => side === "left" ? "start" : "end");
|
|
40
|
+
if (/^float-/.test(base)) return base.replace(/left|right/, (side) => side === "left" ? "start" : "end");
|
|
41
|
+
if (/^border-[lr]/.test(base)) return base.replace(/^border-([lr])/, (_all, side) => `border-${side === "l" ? "s" : "e"}`);
|
|
42
|
+
if (/^rounded-[lr]/.test(base)) return base.replace(/^rounded-([lr])/, (_all, side) => `rounded-${side === "l" ? "s" : "e"}`);
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
function hit(line, column, found, hint) {
|
|
46
|
+
return {
|
|
47
|
+
line,
|
|
48
|
+
column,
|
|
49
|
+
message: `${JSON.stringify(found)} is a physical direction${hint}; right-to-left layouts need the logical form`
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function lineColumn(text, offset) {
|
|
53
|
+
const before = text.slice(0, offset);
|
|
54
|
+
return {
|
|
55
|
+
line: before.split("\n").length,
|
|
56
|
+
column: offset - (before.lastIndexOf("\n") + 1) + 1
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function eachMatch(text, pattern, visit) {
|
|
60
|
+
for (const match of text.matchAll(pattern)) visit(match);
|
|
61
|
+
}
|
|
62
|
+
/** The hits of the rule in one scanned file. `style` says whether the file is CSS (`css`) or code. */
|
|
63
|
+
function logicalCss(scanned, style) {
|
|
64
|
+
const hits = [];
|
|
65
|
+
const declarations = style === "css" ? scanned.stripped : null;
|
|
66
|
+
if (declarations !== null) {
|
|
67
|
+
eachMatch(declarations, PHYSICAL_PROPERTY_DECLARATION, (match) => {
|
|
68
|
+
const place = lineColumn(declarations, match.index ?? 0);
|
|
69
|
+
hits.push(hit(place.line, place.column, match[1] ?? "", suggestion(match[1] ?? "")));
|
|
70
|
+
});
|
|
71
|
+
eachMatch(declarations, POSITION_DECLARATION, (match) => {
|
|
72
|
+
const place = lineColumn(declarations, match.index ?? 0);
|
|
73
|
+
hits.push(hit(place.line, place.column, match[1] ?? "", suggestion(match[1] ?? "")));
|
|
74
|
+
});
|
|
75
|
+
eachMatch(declarations, DIRECTION_VALUE, (match) => {
|
|
76
|
+
const place = lineColumn(declarations, match.index ?? 0);
|
|
77
|
+
const side = match[2] === "left" ? "start" : "end";
|
|
78
|
+
hits.push(hit(place.line, place.column, `${match[1]}: ${match[2]}`, ` (use ${match[1]}: ${side})`));
|
|
79
|
+
});
|
|
80
|
+
return hits;
|
|
81
|
+
}
|
|
82
|
+
for (const part of scanned.strings) {
|
|
83
|
+
for (const match of part.text.matchAll(PHYSICAL_PROPERTY_DECLARATION)) hits.push(hit(part.line, part.column, match[1] ?? "", suggestion(match[1] ?? "")));
|
|
84
|
+
for (const match of part.text.matchAll(DIRECTION_VALUE)) {
|
|
85
|
+
const side = match[2] === "left" ? "start" : "end";
|
|
86
|
+
hits.push(hit(part.line, part.column, `${match[1]}: ${match[2]}`, ` (use ${match[1]}: ${side})`));
|
|
87
|
+
}
|
|
88
|
+
for (const token of part.text.split(/\s+/)) if (token !== "" && CLASS_TOKEN.test(token)) {
|
|
89
|
+
const fix = classSuggestion(token);
|
|
90
|
+
hits.push(hit(part.line, part.column, token, fix === "" ? "" : ` (use ${fix})`));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const code = scanned.bare;
|
|
94
|
+
eachMatch(code, CAMEL_KEY, (match) => {
|
|
95
|
+
const place = lineColumn(code, match.index ?? 0);
|
|
96
|
+
hits.push(hit(place.line, place.column, match[1] ?? "", ""));
|
|
97
|
+
});
|
|
98
|
+
eachMatch(scanned.stripped, CAMEL_DIRECTION_VALUE, (match) => {
|
|
99
|
+
const place = lineColumn(scanned.stripped, match.index ?? 0);
|
|
100
|
+
const side = match[2] === "left" ? "start" : "end";
|
|
101
|
+
hits.push(hit(place.line, place.column, `${match[1]}: "${match[2]}"`, ` (use "${side}")`));
|
|
102
|
+
});
|
|
103
|
+
eachMatch(scanned.stripped, POSITION_KEY, (match) => {
|
|
104
|
+
const place = lineColumn(scanned.stripped, match.index ?? 0);
|
|
105
|
+
hits.push(hit(place.line, place.column, match[1] ?? "", suggestion(match[1] ?? "")));
|
|
106
|
+
});
|
|
107
|
+
return hits;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
export { logicalCss };
|
|
112
|
+
//# sourceMappingURL=logical-css.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logical-css.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/rules/logical-css.ts"],"sourcesContent":["/**\n * GR3007 `logical-css`: no physical directions in styles, so right-to-left\n * languages work. Reads CSS declarations, Tailwind class tokens in string\n * literals, and inline style keys.\n */\nimport type { ScannedSource } from \"./scan\";\nimport type { RuleHit } from \"./types\";\n\n/** CSS property names that are physical, matched in CSS files and in strings (`margin-left:`). */\nconst PHYSICAL_PROPERTY = new RegExp(\n [\n String.raw`(?:margin|padding|scroll-margin|scroll-padding)-(?:left|right)`,\n String.raw`border-(?:left|right)(?:-(?:width|style|color))?`,\n String.raw`border-(?:top|bottom)-(?:left|right)-radius`,\n ].join(\"|\"),\n);\nconst PHYSICAL_PROPERTY_DECLARATION = new RegExp(\n `(?<![\\\\w-])(${PHYSICAL_PROPERTY.source})\\\\s*:`,\n \"g\",\n);\n/** `left:` and `right:` as properties (CSS files only). */\nconst POSITION_DECLARATION = /(?<![\\w-])(left|right)\\s*:(?!:)/g;\nconst DIRECTION_VALUE = /(?<![\\w-])(text-align|float|clear)\\s*:\\s*(left|right)\\b/g;\n\n/** Camel-case style keys (`style={{ marginLeft: 4 }}`). */\nconst CAMEL_KEY =\n /(?<![\\w$.])(marginLeft|marginRight|paddingLeft|paddingRight|borderLeft(?:Width|Style|Color)?|borderRight(?:Width|Style|Color)?|borderTopLeftRadius|borderTopRightRadius|borderBottomLeftRadius|borderBottomRightRadius|scrollMarginLeft|scrollMarginRight|scrollPaddingLeft|scrollPaddingRight)\\s*:/g;\nconst CAMEL_DIRECTION_VALUE = /(?<![\\w$.])(textAlign|float|clear)\\s*:\\s*[\"'`](left|right)[\"'`]/g;\n/** `left: 0`, `right: \"8px\"`: a bare key counts only with a length-like value, so data objects with `left`/`right` fields pass. */\nconst POSITION_KEY =\n /(?<![\\w$.-])(left|right)\\s*:\\s*(?:-?\\d[\\d.]*|[\"'`]-?[\\d.]+(?:px|rem|em|%|vw|vh)?[\"'`]|[\"'`]auto[\"'`])/g;\n\nconst VARIANTS = String.raw`(?:(?:[a-z0-9_-]+|\\[[^\\]\\s]+\\]):)*`;\nconst LENGTH = String.raw`(?:\\d[\\d./]*|px|auto|full|\\[[^\\]]+\\]|\\([^)]+\\))`;\n/** A Tailwind-style class token with a physical direction. */\nconst CLASS_TOKEN = new RegExp(\n `^${VARIANTS}!?(?:-?m[lr]-${LENGTH}|-?p[lr]-${LENGTH}|-?(?:left|right)-${LENGTH}|text-(?:left|right)|float-(?:left|right)|border-[lr](?:-\\\\S+)?|rounded-(?:[lr]|t[lr]|b[lr])(?:-\\\\S+)?|scroll-m[lr]-${LENGTH}|scroll-p[lr]-${LENGTH})!?$`,\n);\n\nconst LOGICAL: Record<string, string> = {\n \"margin-left\": \"margin-inline-start\",\n \"margin-right\": \"margin-inline-end\",\n \"padding-left\": \"padding-inline-start\",\n \"padding-right\": \"padding-inline-end\",\n left: \"inset-inline-start\",\n right: \"inset-inline-end\",\n};\n\nfunction suggestion(text: string): string {\n const property = text.toLowerCase().replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n const logical = LOGICAL[property];\n\n return logical ? ` (use ${logical})` : \"\";\n}\n\nfunction classSuggestion(token: string): string {\n const base = token.slice(token.lastIndexOf(\":\") + 1).replace(/^!/, \"\");\n\n if (/^-?m[lr]-/.test(base))\n return base.replace(/m([lr])-/, (_all, side: string) => `m${side === \"l\" ? \"s\" : \"e\"}-`);\n if (/^-?p[lr]-/.test(base))\n return base.replace(/p([lr])-/, (_all, side: string) => `p${side === \"l\" ? \"s\" : \"e\"}-`);\n if (/^-?(?:left|right)-/.test(base))\n return base.replace(\n /(left|right)-/,\n (_all, side: string) => `${side === \"left\" ? \"start\" : \"end\"}-`,\n );\n if (/^text-/.test(base))\n return base.replace(/left|right/, (side) => (side === \"left\" ? \"start\" : \"end\"));\n if (/^float-/.test(base))\n return base.replace(/left|right/, (side) => (side === \"left\" ? \"start\" : \"end\"));\n if (/^border-[lr]/.test(base))\n return base.replace(\n /^border-([lr])/,\n (_all, side: string) => `border-${side === \"l\" ? \"s\" : \"e\"}`,\n );\n if (/^rounded-[lr]/.test(base))\n return base.replace(\n /^rounded-([lr])/,\n (_all, side: string) => `rounded-${side === \"l\" ? \"s\" : \"e\"}`,\n );\n\n return \"\";\n}\n\nfunction hit(line: number, column: number, found: string, hint: string): RuleHit {\n return {\n line,\n column,\n message: `${JSON.stringify(found)} is a physical direction${hint}; right-to-left layouts need the logical form`,\n };\n}\n\nfunction lineColumn(text: string, offset: number): { line: number; column: number } {\n const before = text.slice(0, offset);\n const line = before.split(\"\\n\").length;\n\n return { line, column: offset - (before.lastIndexOf(\"\\n\") + 1) + 1 };\n}\n\nfunction eachMatch(text: string, pattern: RegExp, visit: (match: RegExpExecArray) => void): void {\n for (const match of text.matchAll(pattern)) visit(match);\n}\n\n/** The hits of the rule in one scanned file. `style` says whether the file is CSS (`css`) or code. */\nexport function logicalCss(scanned: ScannedSource, style: \"css\" | \"code\"): RuleHit[] {\n const hits: RuleHit[] = [];\n const declarations = style === \"css\" ? scanned.stripped : null;\n\n if (declarations !== null) {\n eachMatch(declarations, PHYSICAL_PROPERTY_DECLARATION, (match) => {\n const place = lineColumn(declarations, match.index ?? 0);\n\n hits.push(hit(place.line, place.column, match[1] ?? \"\", suggestion(match[1] ?? \"\")));\n });\n eachMatch(declarations, POSITION_DECLARATION, (match) => {\n const place = lineColumn(declarations, match.index ?? 0);\n\n hits.push(hit(place.line, place.column, match[1] ?? \"\", suggestion(match[1] ?? \"\")));\n });\n eachMatch(declarations, DIRECTION_VALUE, (match) => {\n const place = lineColumn(declarations, match.index ?? 0);\n const side = match[2] === \"left\" ? \"start\" : \"end\";\n\n hits.push(\n hit(place.line, place.column, `${match[1]}: ${match[2]}`, ` (use ${match[1]}: ${side})`),\n );\n });\n\n return hits;\n }\n\n for (const part of scanned.strings) {\n // CSS written inside a string (`style=\"margin-left: 4px\"`, a css`…` template).\n for (const match of part.text.matchAll(PHYSICAL_PROPERTY_DECLARATION)) {\n hits.push(hit(part.line, part.column, match[1] ?? \"\", suggestion(match[1] ?? \"\")));\n }\n\n for (const match of part.text.matchAll(DIRECTION_VALUE)) {\n const side = match[2] === \"left\" ? \"start\" : \"end\";\n\n hits.push(\n hit(part.line, part.column, `${match[1]}: ${match[2]}`, ` (use ${match[1]}: ${side})`),\n );\n }\n\n for (const token of part.text.split(/\\s+/)) {\n if (token !== \"\" && CLASS_TOKEN.test(token)) {\n const fix = classSuggestion(token);\n\n hits.push(hit(part.line, part.column, token, fix === \"\" ? \"\" : ` (use ${fix})`));\n }\n }\n }\n\n // Inline style keys live in code, not in strings.\n const code = scanned.bare;\n\n eachMatch(code, CAMEL_KEY, (match) => {\n const place = lineColumn(code, match.index ?? 0);\n\n hits.push(hit(place.line, place.column, match[1] ?? \"\", \"\"));\n });\n eachMatch(scanned.stripped, CAMEL_DIRECTION_VALUE, (match) => {\n const place = lineColumn(scanned.stripped, match.index ?? 0);\n const side = match[2] === \"left\" ? \"start\" : \"end\";\n\n hits.push(hit(place.line, place.column, `${match[1]}: \"${match[2]}\"`, ` (use \"${side}\")`));\n });\n eachMatch(scanned.stripped, POSITION_KEY, (match) => {\n const place = lineColumn(scanned.stripped, match.index ?? 0);\n\n hits.push(hit(place.line, place.column, match[1] ?? \"\", suggestion(match[1] ?? \"\")));\n });\n\n return hits;\n}\n"],"mappings":";;AASA,MAAM,oBAAoB,IAAI,OAC5B;CACE,OAAO,GAAG;CACV,OAAO,GAAG;CACV,OAAO,GAAG;AACZ,CAAC,CAAC,KAAK,GAAG,CACZ;AACA,MAAM,gCAAgC,IAAI,OACxC,eAAe,kBAAkB,OAAO,SACxC,GACF;;AAEA,MAAM,uBAAuB;AAC7B,MAAM,kBAAkB;;AAGxB,MAAM,YACJ;AACF,MAAM,wBAAwB;;AAE9B,MAAM,eACJ;AAEF,MAAM,WAAW,OAAO,GAAG;AAC3B,MAAM,SAAS,OAAO,GAAG;;AAEzB,MAAM,cAAc,IAAI,OACtB,IAAI,SAAS,eAAe,OAAO,WAAW,OAAO,oBAAoB,OAAO,sHAAsH,OAAO,gBAAgB,OAAO,KACtO;AAEA,MAAM,UAAkC;CACtC,eAAe;CACf,gBAAgB;CAChB,gBAAgB;CAChB,iBAAiB;CACjB,MAAM;CACN,OAAO;AACT;AAEA,SAAS,WAAW,MAAsB;CACxC,MAAM,WAAW,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,WAAW,IAAI,OAAO,YAAY,GAAG;CAC5F,MAAM,UAAU,QAAQ;CAExB,OAAO,UAAU,SAAS,QAAQ,KAAK;AACzC;AAEA,SAAS,gBAAgB,OAAuB;CAC9C,MAAM,OAAO,MAAM,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,MAAM,EAAE;CAErE,IAAI,YAAY,KAAK,IAAI,GACvB,OAAO,KAAK,QAAQ,aAAa,MAAM,SAAiB,IAAI,SAAS,MA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,KAAK,MAAM,KAAK,QAAQ,OAAO,QAAQ,KAAK,KAAK,SAAS,IAAI,EAAE,CAAC;EACjF;CAEJ;CAGA,MAAM,OAAO,QAAQ;CAErB,UAAU,MAAM,YAAY,UAAU;EACpC,MAAM,QAAQ,WAAW,MAAM,MAAM,SAAS,CAAC;EAE/C,KAAK,KAAK,IAAI,MAAM,MAAM,MAAM,QAAQ,MAAM,MAAM,IAAI,EAAE,CAAC;CAC7D,CAAC;CACD,UAAU,QAAQ,UAAU,wBAAwB,UAAU;EAC5D,MAAM,QAAQ,WAAW,QAAQ,UAAU,MAAM,SAAS,CAAC;EAC3D,MAAM,OAAO,MAAM,OAAO,SAAS,UAAU;EAE7C,KAAK,KAAK,IAAI,MAAM,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,MAAM,GAAG,IAAI,UAAU,KAAK,GAAG,CAAC;CAC3F,CAAC;CACD,UAAU,QAAQ,UAAU,eAAe,UAAU;EACnD,MAAM,QAAQ,WAAW,QAAQ,UAAU,MAAM,SAAS,CAAC;EAE3D,KAAK,KAAK,IAAI,MAAM,MAAM,MAAM,QAAQ,MAAM,MAAM,IAAI,WAAW,MAAM,MAAM,EAAE,CAAC,CAAC;CACrF,CAAC;CAED,OAAO;AACT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region ../../packages/grimoire/src/rules/no-js-imports.ts
|
|
2
|
+
const RELATIVE_JS = /^\.\.?\/.*\.(?:js|jsx|mjs|cjs)$/;
|
|
3
|
+
const IMPORT_CONTEXT = /(?:\bfrom|\bimport\s*\(?|\brequire\s*\()\s*$/;
|
|
4
|
+
/** The hits of the rule. */
|
|
5
|
+
function noJsImports(scanned) {
|
|
6
|
+
const hits = [];
|
|
7
|
+
for (const part of scanned.strings) {
|
|
8
|
+
if (!RELATIVE_JS.test(part.text)) continue;
|
|
9
|
+
const before = scanned.bare.slice(Math.max(0, part.quoteStart - 40), part.quoteStart);
|
|
10
|
+
if (!IMPORT_CONTEXT.test(before)) continue;
|
|
11
|
+
hits.push({
|
|
12
|
+
line: part.line,
|
|
13
|
+
column: part.column,
|
|
14
|
+
message: `the import ${JSON.stringify(part.text)} ends in a JavaScript extension; drop it`
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return hits;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { noJsImports };
|
|
22
|
+
//# sourceMappingURL=no-js-imports.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-js-imports.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/rules/no-js-imports.ts"],"sourcesContent":["/**\n * GR3010 `no-js-imports`: relative import paths carry no `.js` extension.\n * Flags the specifier of `import … from`, `export … from`, `import()`,\n * `import \"x\"` and `require()` when it starts with `./` or `../` and ends in\n * `.js`, `.jsx`, `.mjs` or `.cjs`. Package imports are never flagged.\n */\nimport type { ScannedSource } from \"./scan\";\nimport type { RuleHit } from \"./types\";\n\nconst RELATIVE_JS = /^\\.\\.?\\/.*\\.(?:js|jsx|mjs|cjs)$/;\nconst IMPORT_CONTEXT = /(?:\\bfrom|\\bimport\\s*\\(?|\\brequire\\s*\\()\\s*$/;\n\n/** The hits of the rule. */\nexport function noJsImports(scanned: ScannedSource): RuleHit[] {\n const hits: RuleHit[] = [];\n\n for (const part of scanned.strings) {\n if (!RELATIVE_JS.test(part.text)) continue;\n\n const before = scanned.bare.slice(Math.max(0, part.quoteStart - 40), part.quoteStart);\n\n if (!IMPORT_CONTEXT.test(before)) continue;\n\n hits.push({\n line: part.line,\n column: part.column,\n message: `the import ${JSON.stringify(part.text)} ends in a JavaScript extension; drop it`,\n });\n }\n\n return hits;\n}\n"],"mappings":";AASA,MAAM,cAAc;AACpB,MAAM,iBAAiB;;AAGvB,SAAgB,YAAY,SAAmC;CAC7D,MAAM,OAAkB,CAAC;CAEzB,KAAK,MAAM,QAAQ,QAAQ,SAAS;EAClC,IAAI,CAAC,YAAY,KAAK,KAAK,IAAI,GAAG;EAElC,MAAM,SAAS,QAAQ,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,aAAa,EAAE,GAAG,KAAK,UAAU;EAEpF,IAAI,CAAC,eAAe,KAAK,MAAM,GAAG;EAElC,KAAK,KAAK;GACR,MAAM,KAAK;GACX,QAAQ,KAAK;GACb,SAAS,cAAc,KAAK,UAAU,KAAK,IAAI,EAAE;EACnD,CAAC;CACH;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
//#region ../../packages/grimoire/src/rules/scan.ts
|
|
2
|
+
const blank = (text) => text.replace(/[^\r\n]/g, " ");
|
|
3
|
+
/** Scan `text`. */
|
|
4
|
+
function scanSource(text, mode = "code") {
|
|
5
|
+
const stripped = [];
|
|
6
|
+
const bare = [];
|
|
7
|
+
const strings = [];
|
|
8
|
+
const comments = [];
|
|
9
|
+
const length = text.length;
|
|
10
|
+
let line = 1;
|
|
11
|
+
let lineStart = 0;
|
|
12
|
+
let index = 0;
|
|
13
|
+
const templates = [];
|
|
14
|
+
let braces = 0;
|
|
15
|
+
const emit = (strippedPart, barePart) => {
|
|
16
|
+
stripped.push(strippedPart);
|
|
17
|
+
bare.push(barePart);
|
|
18
|
+
};
|
|
19
|
+
const advanceLines = (chunk, from) => {
|
|
20
|
+
for (let at = 0; at < chunk.length; at++) if (chunk[at] === "\n") {
|
|
21
|
+
line++;
|
|
22
|
+
lineStart = from + at + 1;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const readQuoted = (quote) => {
|
|
26
|
+
const start = index;
|
|
27
|
+
const startLine = line;
|
|
28
|
+
const startColumn = index + 2 - lineStart;
|
|
29
|
+
let cursor = index + 1;
|
|
30
|
+
while (cursor < length) {
|
|
31
|
+
const char = text[cursor];
|
|
32
|
+
if (char === "\\") {
|
|
33
|
+
cursor += 2;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (char === quote || char === "\n") break;
|
|
37
|
+
cursor++;
|
|
38
|
+
}
|
|
39
|
+
const closed = text[cursor] === quote;
|
|
40
|
+
const content = text.slice(start + 1, Math.min(cursor, length));
|
|
41
|
+
const end = closed ? cursor + 1 : cursor;
|
|
42
|
+
let isKey = false;
|
|
43
|
+
if (mode === "json") isKey = /^\s*:/.exec(text.slice(end, end + 200)) !== null;
|
|
44
|
+
strings.push({
|
|
45
|
+
text: content,
|
|
46
|
+
line: startLine,
|
|
47
|
+
column: startColumn,
|
|
48
|
+
quoteStart: start,
|
|
49
|
+
isKey
|
|
50
|
+
});
|
|
51
|
+
emit(text.slice(start, end), `${quote}${blank(content)}${closed ? quote : ""}`);
|
|
52
|
+
advanceLines(text.slice(start, end), start);
|
|
53
|
+
index = end;
|
|
54
|
+
};
|
|
55
|
+
const readTemplatePart = () => {
|
|
56
|
+
const start = index;
|
|
57
|
+
const startLine = line;
|
|
58
|
+
const startColumn = index + 2 - lineStart;
|
|
59
|
+
let cursor = index + 1;
|
|
60
|
+
let ends = "eof";
|
|
61
|
+
while (cursor < length) {
|
|
62
|
+
const char = text[cursor];
|
|
63
|
+
if (char === "\\") {
|
|
64
|
+
cursor += 2;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (char === "`") {
|
|
68
|
+
ends = "quote";
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
if (char === "$" && text[cursor + 1] === "{") {
|
|
72
|
+
ends = "expression";
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
cursor++;
|
|
76
|
+
}
|
|
77
|
+
cursor = Math.min(cursor, length);
|
|
78
|
+
const content = text.slice(start + 1, cursor);
|
|
79
|
+
const opener = text[start] ?? "`";
|
|
80
|
+
const closer = ends === "quote" ? "`" : ends === "expression" ? "${" : "";
|
|
81
|
+
strings.push({
|
|
82
|
+
text: content,
|
|
83
|
+
line: startLine,
|
|
84
|
+
column: startColumn,
|
|
85
|
+
quoteStart: start,
|
|
86
|
+
isKey: false
|
|
87
|
+
});
|
|
88
|
+
emit(`${opener}${content}${closer}`, `${opener}${blank(content)}${closer}`);
|
|
89
|
+
advanceLines(text.slice(start, cursor + closer.length), start);
|
|
90
|
+
if (ends === "expression") templates.push(braces);
|
|
91
|
+
index = cursor + closer.length;
|
|
92
|
+
};
|
|
93
|
+
while (index < length) {
|
|
94
|
+
const char = text[index] ?? "";
|
|
95
|
+
const next = text[index + 1];
|
|
96
|
+
if (mode !== "json" && char === "/" && next === "*") {
|
|
97
|
+
const close = text.indexOf("*/", index + 2);
|
|
98
|
+
const end = close === -1 ? length : close + 2;
|
|
99
|
+
const chunk = text.slice(index, end);
|
|
100
|
+
const startLine = line;
|
|
101
|
+
advanceLines(chunk, index);
|
|
102
|
+
comments.push({
|
|
103
|
+
text: chunk,
|
|
104
|
+
startLine,
|
|
105
|
+
endLine: line
|
|
106
|
+
});
|
|
107
|
+
emit(blank(chunk), blank(chunk));
|
|
108
|
+
index = end;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if ((mode === "code" || mode === "scss") && char === "/" && next === "/") {
|
|
112
|
+
let end = text.indexOf("\n", index);
|
|
113
|
+
if (end === -1) end = length;
|
|
114
|
+
const chunk = text.slice(index, end);
|
|
115
|
+
comments.push({
|
|
116
|
+
text: chunk,
|
|
117
|
+
startLine: line,
|
|
118
|
+
endLine: line
|
|
119
|
+
});
|
|
120
|
+
emit(blank(chunk), blank(chunk));
|
|
121
|
+
index = end;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (char === "\"" || char === "'") {
|
|
125
|
+
readQuoted(char);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (mode === "code" && char === "`") {
|
|
129
|
+
readTemplatePart();
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (mode === "code") {
|
|
133
|
+
if (char === "{") braces++;
|
|
134
|
+
if (char === "}") {
|
|
135
|
+
if (templates.length > 0 && templates[templates.length - 1] === braces) {
|
|
136
|
+
templates.pop();
|
|
137
|
+
emit("}", "}");
|
|
138
|
+
index++;
|
|
139
|
+
const resume = index - 1;
|
|
140
|
+
const startLine = line;
|
|
141
|
+
const startColumn = index + 1 - lineStart;
|
|
142
|
+
let cursor = index;
|
|
143
|
+
let ends = "eof";
|
|
144
|
+
while (cursor < length) {
|
|
145
|
+
const inner = text[cursor];
|
|
146
|
+
if (inner === "\\") {
|
|
147
|
+
cursor += 2;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (inner === "`") {
|
|
151
|
+
ends = "quote";
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
if (inner === "$" && text[cursor + 1] === "{") {
|
|
155
|
+
ends = "expression";
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
cursor++;
|
|
159
|
+
}
|
|
160
|
+
cursor = Math.min(cursor, length);
|
|
161
|
+
const content = text.slice(index, cursor);
|
|
162
|
+
const closer = ends === "quote" ? "`" : ends === "expression" ? "${" : "";
|
|
163
|
+
strings.push({
|
|
164
|
+
text: content,
|
|
165
|
+
line: startLine,
|
|
166
|
+
column: startColumn,
|
|
167
|
+
quoteStart: resume,
|
|
168
|
+
isKey: false
|
|
169
|
+
});
|
|
170
|
+
emit(`${content}${closer}`, `${blank(content)}${closer}`);
|
|
171
|
+
advanceLines(text.slice(index, cursor + closer.length), index);
|
|
172
|
+
if (ends === "expression") templates.push(braces);
|
|
173
|
+
index = cursor + closer.length;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
braces--;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (char === "\n") {
|
|
180
|
+
line++;
|
|
181
|
+
lineStart = index + 1;
|
|
182
|
+
}
|
|
183
|
+
emit(char, char);
|
|
184
|
+
index++;
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
stripped: stripped.join(""),
|
|
188
|
+
bare: bare.join(""),
|
|
189
|
+
strings,
|
|
190
|
+
comments
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
//#endregion
|
|
195
|
+
export { scanSource };
|
|
196
|
+
//# sourceMappingURL=scan.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/rules/scan.ts"],"sourcesContent":["/**\n * A small source scanner shared by the code rules and the assertion counter.\n * It is not a parser: it walks the text once and tells comments and string\n * literals from code, well enough for line rules.\n *\n * Limits: JSX text and regular expression literals are read as code, so an\n * apostrophe in JSX text starts a string that ends at the end of its line\n * (single and double quoted strings never span lines).\n */\n\n/** What kind of file is scanned: `code` (TS/JS), `css` (comments `/* *\\/` only), `scss` (also `//`) or `json` (no comments). */\nexport type ScanMode = \"code\" | \"css\" | \"scss\" | \"json\";\n\n/** One string literal (or one literal part of a template literal). */\nexport type ScannedString = {\n /** The text between the quotes, as written (escapes are not decoded). */\n text: string;\n /** 1-based line of the first character of `text`. */\n line: number;\n /** 1-based column of the first character of `text`. */\n column: number;\n /** Offset of the opening quote in the source. */\n quoteStart: number;\n /** `true` when, in `json` mode, the string is an object key. */\n isKey: boolean;\n};\n\n/** One comment. */\nexport type ScannedComment = { text: string; startLine: number; endLine: number };\n\n/** The result of {@link scanSource}. Both text versions have the length and the line breaks of the source. */\nexport type ScannedSource = {\n /** The source with comments blanked to spaces; strings kept. */\n stripped: string;\n /** The source with comments and string contents blanked (the quotes stay). */\n bare: string;\n strings: ScannedString[];\n comments: ScannedComment[];\n};\n\nconst blank = (text: string): string => text.replace(/[^\\r\\n]/g, \" \");\n\n/** Scan `text`. */\nexport function scanSource(text: string, mode: ScanMode = \"code\"): ScannedSource {\n const stripped: string[] = [];\n const bare: string[] = [];\n const strings: ScannedString[] = [];\n const comments: ScannedComment[] = [];\n const length = text.length;\n // Line starts, to turn an offset into line and column.\n let line = 1;\n let lineStart = 0;\n let index = 0;\n // Template literals: `${` pushes the brace depth to return to.\n const templates: number[] = [];\n let braces = 0;\n\n const emit = (strippedPart: string, barePart: string): void => {\n stripped.push(strippedPart);\n bare.push(barePart);\n };\n\n const advanceLines = (chunk: string, from: number): void => {\n for (let at = 0; at < chunk.length; at++) {\n if (chunk[at] === \"\\n\") {\n line++;\n lineStart = from + at + 1;\n }\n }\n };\n\n const readQuoted = (quote: string): void => {\n const start = index;\n const startLine = line;\n const startColumn = index + 2 - lineStart;\n let cursor = index + 1;\n\n while (cursor < length) {\n const char = text[cursor];\n\n if (char === \"\\\\\") {\n cursor += 2;\n continue;\n }\n\n if (char === quote || char === \"\\n\") break;\n\n cursor++;\n }\n\n const closed = text[cursor] === quote;\n const content = text.slice(start + 1, Math.min(cursor, length));\n const end = closed ? cursor + 1 : cursor;\n let isKey = false;\n\n if (mode === \"json\") {\n const after = /^\\s*:/.exec(text.slice(end, end + 200));\n\n isKey = after !== null;\n }\n\n strings.push({ text: content, line: startLine, column: startColumn, quoteStart: start, isKey });\n emit(text.slice(start, end), `${quote}${blank(content)}${closed ? quote : \"\"}`);\n advanceLines(text.slice(start, end), start);\n index = end;\n };\n\n // Reads a template literal part up to `${` or the closing backtick.\n const readTemplatePart = (): void => {\n const start = index;\n const startLine = line;\n const startColumn = index + 2 - lineStart;\n let cursor = index + 1;\n let ends: \"quote\" | \"expression\" | \"eof\" = \"eof\";\n\n while (cursor < length) {\n const char = text[cursor];\n\n if (char === \"\\\\\") {\n cursor += 2;\n continue;\n }\n\n if (char === \"`\") {\n ends = \"quote\";\n break;\n }\n\n if (char === \"$\" && text[cursor + 1] === \"{\") {\n ends = \"expression\";\n break;\n }\n\n cursor++;\n }\n\n cursor = Math.min(cursor, length);\n\n const content = text.slice(start + 1, cursor);\n const opener = text[start] ?? \"`\";\n const closer = ends === \"quote\" ? \"`\" : ends === \"expression\" ? \"${\" : \"\";\n\n strings.push({\n text: content,\n line: startLine,\n column: startColumn,\n quoteStart: start,\n isKey: false,\n });\n emit(`${opener}${content}${closer}`, `${opener}${blank(content)}${closer}`);\n advanceLines(text.slice(start, cursor + closer.length), start);\n\n if (ends === \"expression\") templates.push(braces);\n\n index = cursor + closer.length;\n };\n\n while (index < length) {\n const char = text[index] ?? \"\";\n const next = text[index + 1];\n\n if (mode !== \"json\" && char === \"/\" && next === \"*\") {\n const close = text.indexOf(\"*/\", index + 2);\n const end = close === -1 ? length : close + 2;\n const chunk = text.slice(index, end);\n const startLine = line;\n\n advanceLines(chunk, index);\n comments.push({ text: chunk, startLine, endLine: line });\n emit(blank(chunk), blank(chunk));\n index = end;\n continue;\n }\n\n if ((mode === \"code\" || mode === \"scss\") && char === \"/\" && next === \"/\") {\n // `://` inside a URL string never reaches here: strings are read whole.\n let end = text.indexOf(\"\\n\", index);\n\n if (end === -1) end = length;\n\n const chunk = text.slice(index, end);\n\n comments.push({ text: chunk, startLine: line, endLine: line });\n emit(blank(chunk), blank(chunk));\n index = end;\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n readQuoted(char);\n continue;\n }\n\n if (mode === \"code\" && char === \"`\") {\n readTemplatePart();\n continue;\n }\n\n if (mode === \"code\") {\n if (char === \"{\") braces++;\n\n if (char === \"}\") {\n if (templates.length > 0 && templates[templates.length - 1] === braces) {\n templates.pop();\n // The closing brace of `${…}`: the template continues.\n emit(\"}\", \"}\");\n index++;\n // Re-enter the template text after the brace.\n const resume = index - 1;\n const startLine = line;\n const startColumn = index + 1 - lineStart;\n let cursor = index;\n let ends: \"quote\" | \"expression\" | \"eof\" = \"eof\";\n\n while (cursor < length) {\n const inner = text[cursor];\n\n if (inner === \"\\\\\") {\n cursor += 2;\n continue;\n }\n\n if (inner === \"`\") {\n ends = \"quote\";\n break;\n }\n\n if (inner === \"$\" && text[cursor + 1] === \"{\") {\n ends = \"expression\";\n break;\n }\n\n cursor++;\n }\n\n cursor = Math.min(cursor, length);\n\n const content = text.slice(index, cursor);\n const closer = ends === \"quote\" ? \"`\" : ends === \"expression\" ? \"${\" : \"\";\n\n strings.push({\n text: content,\n line: startLine,\n column: startColumn,\n quoteStart: resume,\n isKey: false,\n });\n emit(`${content}${closer}`, `${blank(content)}${closer}`);\n advanceLines(text.slice(index, cursor + closer.length), index);\n\n if (ends === \"expression\") templates.push(braces);\n\n index = cursor + closer.length;\n continue;\n }\n\n braces--;\n }\n }\n\n if (char === \"\\n\") {\n line++;\n lineStart = index + 1;\n }\n\n emit(char, char);\n index++;\n }\n\n return { stripped: stripped.join(\"\"), bare: bare.join(\"\"), strings, comments };\n}\n\n/** The 1-based line of an offset. */\nexport function lineOfOffset(text: string, offset: number): number {\n let line = 1;\n\n for (let at = 0; at < offset && at < text.length; at++) {\n if (text[at] === \"\\n\") line++;\n }\n\n return line;\n}\n"],"mappings":";AAwCA,MAAM,SAAS,SAAyB,KAAK,QAAQ,YAAY,GAAG;;AAGpE,SAAgB,WAAW,MAAc,OAAiB,QAAuB;CAC/E,MAAM,WAAqB,CAAC;CAC5B,MAAM,OAAiB,CAAC;CACxB,MAAM,UAA2B,CAAC;CAClC,MAAM,WAA6B,CAAC;CACpC,MAAM,SAAS,KAAK;CAEpB,IAAI,OAAO;CACX,IAAI,YAAY;CAChB,IAAI,QAAQ;CAEZ,MAAM,YAAsB,CAAC;CAC7B,IAAI,SAAS;CAEb,MAAM,QAAQ,cAAsB,aAA2B;EAC7D,SAAS,KAAK,YAAY;EAC1B,KAAK,KAAK,QAAQ;CACpB;CAEA,MAAM,gBAAgB,OAAe,SAAuB;EAC1D,KAAK,IAAI,KAAK,GAAG,KAAK,MAAM,QAAQ,MAClC,IAAI,MAAM,QAAQ,MAAM;GACtB;GACA,YAAY,OAAO,KAAK;EAC1B;CAEJ;CAEA,MAAM,cAAc,UAAwB;EAC1C,MAAM,QAAQ;EACd,MAAM,YAAY;EAClB,MAAM,cAAc,QAAQ,IAAI;EAChC,IAAI,SAAS,QAAQ;EAErB,OAAO,SAAS,QAAQ;GACtB,MAAM,OAAO,KAAK;GAElB,IAAI,SAAS,MAAM;IACjB,UAAU;IACV;GACF;GAEA,IAAI,SAAS,SAAS,SAAS,MAAM;GAErC;EACF;EA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c,QAAQ,IAAI;KAChC,IAAI,SAAS;KACb,IAAI,OAAuC;KAE3C,OAAO,SAAS,QAAQ;MACtB,MAAM,QAAQ,KAAK;MAEnB,IAAI,UAAU,MAAM;OAClB,UAAU;OACV;MACF;MAEA,IAAI,UAAU,KAAK;OACjB,OAAO;OACP;MACF;MAEA,IAAI,UAAU,OAAO,KAAK,SAAS,OAAO,KAAK;OAC7C,OAAO;OACP;MACF;MAEA;KACF;KAEA,SAAS,KAAK,IAAI,QAAQ,MAAM;KAEhC,MAAM,UAAU,KAAK,MAAM,OAAO,MAAM;KACxC,MAAM,SAAS,SAAS,UAAU,MAAM,SAAS,eAAe,OAAO;KAEvE,QAAQ,KAAK;MACX,MAAM;MACN,MAAM;MACN,QAAQ;MACR,YAAY;MACZ,OAAO;KACT,CAAC;KACD,KAAK,GAAG,UAAU,UAAU,GAAG,MAAM,OAAO,IAAI,QAAQ;KACxD,aAAa,KAAK,MAAM,OAAO,SAAS,OAAO,MAAM,GAAG,KAAK;KAE7D,IAAI,SAAS,cAAc,UAAU,KAAK,MAAM;KAEhD,QAAQ,SAAS,OAAO;KACxB;IACF;IAEA;GACF;EACF;EAEA,IAAI,SAAS,MAAM;GACjB;GACA,YAAY,QAAQ;EACtB;EAEA,KAAK,MAAM,IAAI;EACf;CACF;CAEA,OAAO;EAAE,UAAU,SAAS,KAAK,EAAE;EAAG,MAAM,KAAK,KAAK,EAAE;EAAG;EAAS;CAAS;AAC/E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region ../../packages/grimoire/src/rules/specific-errors.ts
|
|
2
|
+
/** Generic phrases flagged anywhere (lower-case, no punctuation). */
|
|
3
|
+
const GENERIC_PHRASES = /* @__PURE__ */ new Set([
|
|
4
|
+
"something went wrong",
|
|
5
|
+
"something wrong happened",
|
|
6
|
+
"an error occurred",
|
|
7
|
+
"an error has occurred",
|
|
8
|
+
"an unexpected error occurred",
|
|
9
|
+
"an unexpected error has occurred",
|
|
10
|
+
"unknown error",
|
|
11
|
+
"unexpected error",
|
|
12
|
+
"an unknown error occurred",
|
|
13
|
+
"حدث خطأ ما",
|
|
14
|
+
"حدث خطأ",
|
|
15
|
+
"حدث خطأ غير متوقع",
|
|
16
|
+
"خطأ غير معروف"
|
|
17
|
+
]);
|
|
18
|
+
/** Short words flagged only as a locale value (`"error": "Error"`): in code they are log levels and event names. */
|
|
19
|
+
const GENERIC_WORDS = /* @__PURE__ */ new Set([
|
|
20
|
+
"oops",
|
|
21
|
+
"error",
|
|
22
|
+
"errors"
|
|
23
|
+
]);
|
|
24
|
+
const TRAILING_ADVICE = /[\s,.;:!-]*(?:please\s+)?(?:try\s+again(?:\s+later)?|حاول\s+مرة\s+أخرى(?:\s+لاحقا)?|يرجى\s+المحاولة\s+مرة\s+أخرى|حاول\s+مجددا)\s*[.!]*$/u;
|
|
25
|
+
/** The phrase of a string: trimmed, punctuation and "please try again" removed, lower-case. */
|
|
26
|
+
function phraseOf(text) {
|
|
27
|
+
return text.trim().toLowerCase().replace(TRAILING_ADVICE, "").replace(/^[\s"'`.,;:!?\-()[\]]+|[\s"'`.,;:!?\-()[\]]+$/gu, "").replace(/\s+/g, " ");
|
|
28
|
+
}
|
|
29
|
+
/** Whether a whole string is a generic error text. `locale` also flags the short words. */
|
|
30
|
+
function isGenericError(text, locale) {
|
|
31
|
+
const phrase = phraseOf(text);
|
|
32
|
+
if (phrase === "") return false;
|
|
33
|
+
return GENERIC_PHRASES.has(phrase) || locale && GENERIC_WORDS.has(phrase);
|
|
34
|
+
}
|
|
35
|
+
/** The hits of the rule. `locale` is `true` for locale files (JSON or TS), where keys are skipped and the short words count. */
|
|
36
|
+
function specificErrors(scanned, locale) {
|
|
37
|
+
const hits = [];
|
|
38
|
+
for (const part of scanned.strings) {
|
|
39
|
+
if (part.isKey) continue;
|
|
40
|
+
if (isGenericError(part.text, locale)) hits.push({
|
|
41
|
+
line: part.line,
|
|
42
|
+
column: part.column,
|
|
43
|
+
message: `${JSON.stringify(part.text)} says nothing about what failed or what to do next`
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return hits;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { isGenericError, phraseOf, specificErrors };
|
|
51
|
+
//# sourceMappingURL=specific-errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specific-errors.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/rules/specific-errors.ts"],"sourcesContent":["/**\n * GR3008 `specific-errors`: a user-facing error says what failed and what to\n * do next. A string whose whole text is a generic phrase is flagged.\n */\nimport type { ScannedSource } from \"./scan\";\nimport type { RuleHit } from \"./types\";\n\n/** Generic phrases flagged anywhere (lower-case, no punctuation). */\nconst GENERIC_PHRASES: ReadonlySet<string> = new Set([\n \"something went wrong\",\n \"something wrong happened\",\n \"an error occurred\",\n \"an error has occurred\",\n \"an unexpected error occurred\",\n \"an unexpected error has occurred\",\n \"unknown error\",\n \"unexpected error\",\n \"an unknown error occurred\",\n \"حدث خطأ ما\",\n \"حدث خطأ\",\n \"حدث خطأ غير متوقع\",\n \"خطأ غير معروف\",\n]);\n\n/** Short words flagged only as a locale value (`\"error\": \"Error\"`): in code they are log levels and event names. */\nconst GENERIC_WORDS: ReadonlySet<string> = new Set([\"oops\", \"error\", \"errors\"]);\n\nconst TRAILING_ADVICE =\n /[\\s,.;:!-]*(?:please\\s+)?(?:try\\s+again(?:\\s+later)?|حاول\\s+مرة\\s+أخرى(?:\\s+لاحقا)?|يرجى\\s+المحاولة\\s+مرة\\s+أخرى|حاول\\s+مجددا)\\s*[.!]*$/u;\n\n/** The phrase of a string: trimmed, punctuation and \"please try again\" removed, lower-case. */\nexport function phraseOf(text: string): string {\n return text\n .trim()\n .toLowerCase()\n .replace(TRAILING_ADVICE, \"\")\n .replace(/^[\\s\"'`.,;:!?\\-()[\\]]+|[\\s\"'`.,;:!?\\-()[\\]]+$/gu, \"\")\n .replace(/\\s+/g, \" \");\n}\n\n/** Whether a whole string is a generic error text. `locale` also flags the short words. */\nexport function isGenericError(text: string, locale: boolean): boolean {\n const phrase = phraseOf(text);\n\n if (phrase === \"\") return false;\n\n return GENERIC_PHRASES.has(phrase) || (locale && GENERIC_WORDS.has(phrase));\n}\n\n/** The hits of the rule. `locale` is `true` for locale files (JSON or TS), where keys are skipped and the short words count. */\nexport function specificErrors(scanned: ScannedSource, locale: boolean): RuleHit[] {\n const hits: RuleHit[] = [];\n\n for (const part of scanned.strings) {\n if (part.isKey) continue;\n\n if (isGenericError(part.text, locale)) {\n hits.push({\n line: part.line,\n column: part.column,\n message: `${JSON.stringify(part.text)} says nothing about what failed or what to do next`,\n });\n }\n }\n\n return hits;\n}\n"],"mappings":";;AAQA,MAAM,kCAAuC,IAAI,IAAI;CACnD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,gCAAqC,IAAI,IAAI;CAAC;CAAQ;CAAS;AAAQ,CAAC;AAE9E,MAAM,kBACJ;;AAGF,SAAgB,SAAS,MAAsB;CAC7C,OAAO,KACJ,KAAK,CAAC,CACN,YAAY,CAAC,CACb,QAAQ,iBAAiB,EAAE,CAAC,CAC5B,QAAQ,mDAAmD,EAAE,CAAC,CAC9D,QAAQ,QAAQ,GAAG;AACxB;;AAGA,SAAgB,eAAe,MAAc,QAA0B;CACrE,MAAM,SAAS,SAAS,IAAI;CAE5B,IAAI,WAAW,IAAI,OAAO;CAE1B,OAAO,gBAAgB,IAAI,MAAM,KAAM,UAAU,cAAc,IAAI,MAAM;AAC3E;;AAGA,SAAgB,eAAe,SAAwB,QAA4B;CACjF,MAAM,OAAkB,CAAC;CAEzB,KAAK,MAAM,QAAQ,QAAQ,SAAS;EAClC,IAAI,KAAK,OAAO;EAEhB,IAAI,eAAe,KAAK,MAAM,MAAM,GAClC,KAAK,KAAK;GACR,MAAM,KAAK;GACX,QAAQ,KAAK;GACb,SAAS,GAAG,KAAK,UAAU,KAAK,IAAI,EAAE;EACxC,CAAC;CAEL;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region ../../packages/grimoire/src/rules/type-discriminator.ts
|
|
2
|
+
const KIND_KEY = /(?<![\w$])kind\s*\??\s*:\s*["'`]/g;
|
|
3
|
+
const MODIFIERS = /(?:readonly|public|private|protected|static)\s+$/;
|
|
4
|
+
/** The hits of the rule. */
|
|
5
|
+
function typeDiscriminator(scanned) {
|
|
6
|
+
const hits = [];
|
|
7
|
+
const code = scanned.bare;
|
|
8
|
+
for (const match of code.matchAll(KIND_KEY)) {
|
|
9
|
+
const offset = match.index ?? 0;
|
|
10
|
+
let before = code.slice(0, offset).replace(MODIFIERS, "");
|
|
11
|
+
before = before.replace(/\s+$/, "");
|
|
12
|
+
const previous = before.slice(-1);
|
|
13
|
+
if (previous !== "" && !"{,;|&(<[".includes(previous)) continue;
|
|
14
|
+
const before2 = code.slice(0, offset);
|
|
15
|
+
const line = before2.split("\n").length;
|
|
16
|
+
hits.push({
|
|
17
|
+
line,
|
|
18
|
+
column: offset - (before2.lastIndexOf("\n") + 1) + 1,
|
|
19
|
+
message: "the discriminator field is named \"kind\"; name it \"type\""
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return hits;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { typeDiscriminator };
|
|
27
|
+
//# sourceMappingURL=type-discriminator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-discriminator.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/rules/type-discriminator.ts"],"sourcesContent":["/**\n * GR3009 `type-discriminator`: the field that tells variants apart is named\n * `type`, never `kind`. Flags `kind` as a property key whose value starts\n * with a string literal (`kind: \"a\"`, `kind?: \"a\" | \"b\"`).\n */\nimport type { ScannedSource } from \"./scan\";\nimport type { RuleHit } from \"./types\";\n\nconst KIND_KEY = /(?<![\\w$])kind\\s*\\??\\s*:\\s*[\"'`]/g;\nconst MODIFIERS = /(?:readonly|public|private|protected|static)\\s+$/;\n\n/** The hits of the rule. */\nexport function typeDiscriminator(scanned: ScannedSource): RuleHit[] {\n const hits: RuleHit[] = [];\n const code = scanned.bare;\n\n for (const match of code.matchAll(KIND_KEY)) {\n const offset = match.index ?? 0;\n let before = code.slice(0, offset).replace(MODIFIERS, \"\");\n\n before = before.replace(/\\s+$/, \"\");\n\n const previous = before.slice(-1);\n\n // A property key follows `{`, `,`, `;`, `|`, `&`, `(` or starts the text; `a ? kind : \"x\"` and `a.kind: …` do not.\n if (previous !== \"\" && !\"{,;|&(<[\".includes(previous)) continue;\n\n const before2 = code.slice(0, offset);\n const line = before2.split(\"\\n\").length;\n\n hits.push({\n line,\n column: offset - (before2.lastIndexOf(\"\\n\") + 1) + 1,\n message: 'the discriminator field is named \"kind\"; name it \"type\"',\n });\n }\n\n return hits;\n}\n"],"mappings":";AAQA,MAAM,WAAW;AACjB,MAAM,YAAY;;AAGlB,SAAgB,kBAAkB,SAAmC;CACnE,MAAM,OAAkB,CAAC;CACzB,MAAM,OAAO,QAAQ;CAErB,KAAK,MAAM,SAAS,KAAK,SAAS,QAAQ,GAAG;EAC3C,MAAM,SAAS,MAAM,SAAS;EAC9B,IAAI,SAAS,KAAK,MAAM,GAAG,MAAM,CAAC,CAAC,QAAQ,WAAW,EAAE;EAExD,SAAS,OAAO,QAAQ,QAAQ,EAAE;EAElC,MAAM,WAAW,OAAO,MAAM,EAAE;EAGhC,IAAI,aAAa,MAAM,CAAC,WAAW,SAAS,QAAQ,GAAG;EAEvD,MAAM,UAAU,KAAK,MAAM,GAAG,MAAM;EACpC,MAAM,OAAO,QAAQ,MAAM,IAAI,CAAC,CAAC;EAEjC,KAAK,KAAK;GACR;GACA,QAAQ,UAAU,QAAQ,YAAY,IAAI,IAAI,KAAK;GACnD,SAAS;EACX,CAAC;CACH;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//#region ../../packages/grimoire/src/scry/also-changes.ts
|
|
2
|
+
/** How many top hits that map to files bring files in. */
|
|
3
|
+
const TOP_HITS = 3;
|
|
4
|
+
/** The most files listed. */
|
|
5
|
+
const ALSO_CHANGES_LIMIT = 10;
|
|
6
|
+
const REASON_ORDER = [
|
|
7
|
+
"step",
|
|
8
|
+
"imports",
|
|
9
|
+
"imported-by",
|
|
10
|
+
"test"
|
|
11
|
+
];
|
|
12
|
+
const byText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
13
|
+
/** The files a hit stands for: a file, the file of an export, page or screen, a flow's step entries, a route's handler. */
|
|
14
|
+
function filesOfHit(snapshot, hit) {
|
|
15
|
+
const facts = snapshot.book.facts;
|
|
16
|
+
switch (hit.type) {
|
|
17
|
+
case "file": return [hit.id];
|
|
18
|
+
case "export": return [hit.id.split("#")[0] ?? hit.id];
|
|
19
|
+
case "page":
|
|
20
|
+
case "screen":
|
|
21
|
+
case "mail":
|
|
22
|
+
case "job": return hit.detail === null ? [] : [hit.detail];
|
|
23
|
+
case "flow": {
|
|
24
|
+
const bookmap = snapshot.collected?.flows?.[hit.id];
|
|
25
|
+
return [...new Set((bookmap?.steps ?? []).flatMap((step) => step.entries))].sort(byText);
|
|
26
|
+
}
|
|
27
|
+
case "route": {
|
|
28
|
+
const found = (facts.routes ?? []).find((route) => `${route.method} ${route.path}` === hit.id);
|
|
29
|
+
return found?.handlerFile == null ? [] : [found.handlerFile];
|
|
30
|
+
}
|
|
31
|
+
default: return [];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Files that prove the flow of a flow hit. */
|
|
35
|
+
function provingTests(snapshot, hit) {
|
|
36
|
+
if (hit.type !== "flow") return [];
|
|
37
|
+
const bookmap = snapshot.collected?.flows?.[hit.id];
|
|
38
|
+
return [...new Set((bookmap?.criteria ?? []).flatMap((item) => item.tests.map((test) => test.file)))];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The files that change with the top hits, most shared first (then step, imports,
|
|
42
|
+
* imported-by, test, then path), at most ten, none of them a hit's own file.
|
|
43
|
+
* `next` is the impact command for the file of the best top hit that is not a
|
|
44
|
+
* flow (else the first step file of the top flow).
|
|
45
|
+
*/
|
|
46
|
+
function alsoChangesOf(snapshot, hits) {
|
|
47
|
+
const files = new Map(snapshot.book.facts.files.map((file) => [file.file, file]));
|
|
48
|
+
const owner = (file) => snapshot.ownership?.files?.[file]?.owner ?? null;
|
|
49
|
+
const sameGroup = (left, right) => {
|
|
50
|
+
const leftOwner = owner(left);
|
|
51
|
+
if (leftOwner !== null) return leftOwner === owner(right);
|
|
52
|
+
const leftFile = files.get(left);
|
|
53
|
+
return owner(right) === null && leftFile !== void 0 && leftFile.module === files.get(right)?.module;
|
|
54
|
+
};
|
|
55
|
+
const isSpec = (file) => files.get(file)?.type === "spec";
|
|
56
|
+
const top = hits.map((hit) => ({
|
|
57
|
+
hit,
|
|
58
|
+
seeds: filesOfHit(snapshot, hit).filter((file) => files.has(file))
|
|
59
|
+
})).filter((item) => item.seeds.length > 0).slice(0, TOP_HITS);
|
|
60
|
+
const hitFiles = new Set(hits.filter((hit) => hit.type !== "flow").flatMap((hit) => filesOfHit(snapshot, hit)));
|
|
61
|
+
const found = /* @__PURE__ */ new Map();
|
|
62
|
+
const add = (file, reason, via) => {
|
|
63
|
+
if (hitFiles.has(file)) return;
|
|
64
|
+
const existing = found.get(file);
|
|
65
|
+
if (existing === void 0) {
|
|
66
|
+
found.set(file, {
|
|
67
|
+
reason,
|
|
68
|
+
via: /* @__PURE__ */ new Set([via])
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
existing.via.add(via);
|
|
73
|
+
if (REASON_ORDER.indexOf(reason) < REASON_ORDER.indexOf(existing.reason)) existing.reason = reason;
|
|
74
|
+
};
|
|
75
|
+
for (const { hit, seeds } of top) {
|
|
76
|
+
if (hit.type === "flow") for (const seed of seeds) add(seed, "step", hit.id);
|
|
77
|
+
for (const seed of seeds) {
|
|
78
|
+
const book = files.get(seed);
|
|
79
|
+
if (book === void 0) continue;
|
|
80
|
+
for (const entry of book.imports ?? []) {
|
|
81
|
+
if (entry.file === null || isSpec(entry.file) || !files.has(entry.file)) continue;
|
|
82
|
+
if (sameGroup(seed, entry.file)) add(entry.file, "imported-by", hit.id);
|
|
83
|
+
}
|
|
84
|
+
for (const importer of book.importedBy ?? []) {
|
|
85
|
+
if (!files.has(importer)) continue;
|
|
86
|
+
if (isSpec(importer)) add(importer, "test", hit.id);
|
|
87
|
+
else if (sameGroup(seed, importer)) add(importer, "imports", hit.id);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const test of provingTests(snapshot, hit)) add(test, "test", hit.id);
|
|
91
|
+
}
|
|
92
|
+
const alsoChanges = [...found].map(([file, { reason, via }]) => ({
|
|
93
|
+
file,
|
|
94
|
+
reason,
|
|
95
|
+
via: [...via]
|
|
96
|
+
})).sort((left, right) => right.via.length - left.via.length || REASON_ORDER.indexOf(left.reason) - REASON_ORDER.indexOf(right.reason) || byText(left.file, right.file)).slice(0, 10);
|
|
97
|
+
const first = (top.find((item) => item.hit.type !== "flow") ?? top[0])?.seeds[0];
|
|
98
|
+
return {
|
|
99
|
+
alsoChanges,
|
|
100
|
+
next: first === void 0 ? void 0 : `warlock scry --impact ${first}`
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { alsoChangesOf };
|
|
106
|
+
//# sourceMappingURL=also-changes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"also-changes.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/also-changes.ts"],"sourcesContent":["/**\n * The files that usually change with the top hits of a search: what the hits'\n * files import and what imports them inside the same owning feature (the same\n * module when the file has no owner), and the tests that import them or prove\n * the hits' flows. Pure: reads the snapshot only.\n */\nimport type { ScryAlsoChange, ScryHit } from \"../contracts/scry\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\n\n/** How many top hits that map to files bring files in. */\nconst TOP_HITS = 3;\n\n/** The most files listed. */\nexport const ALSO_CHANGES_LIMIT = 10;\n\nconst REASON_ORDER: ScryAlsoChange[\"reason\"][] = [\"step\", \"imports\", \"imported-by\", \"test\"];\n\nconst byText = (left: string, right: string): number => (left < right ? -1 : left > right ? 1 : 0);\n\n/** The files a hit stands for: a file, the file of an export, page or screen, a flow's step entries, a route's handler. */\nfunction filesOfHit(snapshot: GrimoireSnapshot, hit: ScryHit): string[] {\n const facts = snapshot.book.facts;\n\n switch (hit.type) {\n case \"file\":\n return [hit.id];\n case \"export\":\n return [hit.id.split(\"#\")[0] ?? hit.id];\n case \"page\":\n case \"screen\":\n case \"mail\":\n case \"job\":\n return hit.detail === null ? [] : [hit.detail];\n case \"flow\": {\n const bookmap = snapshot.collected?.flows?.[hit.id];\n\n return [...new Set((bookmap?.steps ?? []).flatMap((step) => step.entries))].sort(byText);\n }\n case \"route\": {\n const found = (facts.routes ?? []).find(\n (route) => `${route.method} ${route.path}` === hit.id,\n );\n\n return found?.handlerFile == null ? [] : [found.handlerFile];\n }\n default:\n return [];\n }\n}\n\n/** Files that prove the flow of a flow hit. */\nfunction provingTests(snapshot: GrimoireSnapshot, hit: ScryHit): string[] {\n if (hit.type !== \"flow\") return [];\n\n const bookmap = snapshot.collected?.flows?.[hit.id];\n\n return [\n ...new Set((bookmap?.criteria ?? []).flatMap((item) => item.tests.map((test) => test.file))),\n ];\n}\n\n/**\n * The files that change with the top hits, most shared first (then step, imports,\n * imported-by, test, then path), at most ten, none of them a hit's own file.\n * `next` is the impact command for the file of the best top hit that is not a\n * flow (else the first step file of the top flow).\n */\nexport function alsoChangesOf(\n snapshot: GrimoireSnapshot,\n hits: readonly ScryHit[],\n): { alsoChanges: ScryAlsoChange[]; next: string | undefined } {\n const files = new Map(snapshot.book.facts.files.map((file) => [file.file, file]));\n const owner = (file: string): string | null => snapshot.ownership?.files?.[file]?.owner ?? null;\n const sameGroup = (left: string, right: string): boolean => {\n const leftOwner = owner(left);\n\n if (leftOwner !== null) return leftOwner === owner(right);\n\n const leftFile = files.get(left);\n\n return (\n owner(right) === null &&\n leftFile !== undefined &&\n leftFile.module === files.get(right)?.module\n );\n };\n const isSpec = (file: string): boolean => files.get(file)?.type === \"spec\";\n\n const top = hits\n .map((hit) => ({ hit, seeds: filesOfHit(snapshot, hit).filter((file) => files.has(file)) }))\n .filter((item) => item.seeds.length > 0)\n .slice(0, TOP_HITS);\n // A hit's own file is already in the answer; the step files of a flow hit are not.\n const hitFiles = new Set(\n hits.filter((hit) => hit.type !== \"flow\").flatMap((hit) => filesOfHit(snapshot, hit)),\n );\n const found = new Map<string, { reason: ScryAlsoChange[\"reason\"]; via: Set<string> }>();\n const add = (file: string, reason: ScryAlsoChange[\"reason\"], via: string): void => {\n if (hitFiles.has(file)) return;\n\n const existing = found.get(file);\n\n if (existing === undefined) {\n found.set(file, { reason, via: new Set([via]) });\n\n return;\n }\n\n existing.via.add(via);\n\n if (REASON_ORDER.indexOf(reason) < REASON_ORDER.indexOf(existing.reason))\n existing.reason = reason;\n };\n\n for (const { hit, seeds } of top) {\n if (hit.type === \"flow\") {\n for (const seed of seeds) add(seed, \"step\", hit.id);\n }\n\n for (const seed of seeds) {\n const book = files.get(seed);\n\n if (book === undefined) continue;\n\n // Facts built by hand (an adapter's own, a spec's) may leave the import lists out.\n for (const entry of book.imports ?? []) {\n if (entry.file === null || isSpec(entry.file) || !files.has(entry.file)) continue;\n if (sameGroup(seed, entry.file)) add(entry.file, \"imported-by\", hit.id);\n }\n\n for (const importer of book.importedBy ?? []) {\n if (!files.has(importer)) continue;\n if (isSpec(importer)) add(importer, \"test\", hit.id);\n else if (sameGroup(seed, importer)) add(importer, \"imports\", hit.id);\n }\n }\n\n for (const test of provingTests(snapshot, hit)) add(test, \"test\", hit.id);\n }\n\n const alsoChanges = [...found]\n .map(([file, { reason, via }]) => ({ file, reason, via: [...via] }))\n .sort(\n (left, right) =>\n right.via.length - left.via.length ||\n REASON_ORDER.indexOf(left.reason) - REASON_ORDER.indexOf(right.reason) ||\n byText(left.file, right.file),\n )\n .slice(0, ALSO_CHANGES_LIMIT);\n // The file of the best hit that is a file itself (a flow hit's step files have no order of their own).\n const first = (top.find((item) => item.hit.type !== \"flow\") ?? top[0])?.seeds[0];\n\n return { alsoChanges, next: first === undefined ? undefined : `warlock scry --impact ${first}` };\n}\n"],"mappings":";;AAUA,MAAM,WAAW;;AAGjB,MAAa,qBAAqB;AAElC,MAAM,eAA2C;CAAC;CAAQ;CAAW;CAAe;AAAM;AAE1F,MAAM,UAAU,MAAc,UAA2B,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;;AAGhG,SAAS,WAAW,UAA4B,KAAwB;CACtE,MAAM,QAAQ,SAAS,KAAK;CAE5B,QAAQ,IAAI,MAAZ;EACE,KAAK,QACH,OAAO,CAAC,IAAI,EAAE;EAChB,KAAK,UACH,OAAO,CAAC,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,EAAE;EACxC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,OACH,OAAO,IAAI,WAAW,OAAO,CAAC,IAAI,CAAC,IAAI,MAAM;EAC/C,KAAK,QAAQ;GACX,MAAM,UAAU,SAAS,WAAW,QAAQ,IAAI;GAEhD,OAAO,CAAC,GAAG,IAAI,KAAK,SAAS,SAAS,CAAC,EAAC,CAAE,SAAS,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM;EACzF;EACA,KAAK,SAAS;GACZ,MAAM,SAAS,MAAM,UAAU,CAAC,EAAC,CAAE,MAChC,UAAU,GAAG,MAAM,OAAO,GAAG,MAAM,WAAW,IAAI,EACrD;GAEA,OAAO,OAAO,eAAe,OAAO,CAAC,IAAI,CAAC,MAAM,WAAW;EAC7D;EACA,SACE,OAAO,CAAC;CACZ;AACF;;AAGA,SAAS,aAAa,UAA4B,KAAwB;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,IAAI,aAAa,QAAQ,MAAM,MAAM,KACrE,OAAO,KAAK,MAAM,MAAM,IAAI,CAChC,CAAC,CACA,MAAM,KAAqB;CAE9B,MAAM,SAAS,IAAI,MAAM,SAAS,KAAK,IAAI,SAAS,MAAM,KAAK,IAAI,GAAE,EAAG,MAAM;CAE9E,OAAO;EAAE;EAAa,MAAM,UAAU,SAAY,SAAY,yBAAyB;CAAQ;AACjG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/format.ts"],"mappings":";;;YAmCY;;EAEV;;;;;;
|
|
1
|
+
{"version":3,"file":"format.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/format.ts"],"mappings":";;;YAmCY;;EAEV;;;;;;wBAobc,iBAAiB,QAAQ,YAAY,UAAS"}
|