@r_masseater/msch 0.6.2 → 0.9.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 +35 -2
- package/dist/cli-contract-DlE7gy0b.mjs +115 -0
- package/dist/cli-contract-DlE7gy0b.mjs.map +1 -0
- package/dist/cli.mjs +684 -236
- package/dist/cli.mjs.map +1 -1
- package/dist/comment-directives-DApQXgQf.mjs +20 -0
- package/dist/comment-directives-DApQXgQf.mjs.map +1 -0
- package/dist/dependencies-x3j9tLcR.mjs +186 -0
- package/dist/dependencies-x3j9tLcR.mjs.map +1 -0
- package/dist/lint.d.mts +6 -1
- package/dist/lint.mjs +47 -17
- package/dist/lint.mjs.map +1 -1
- package/dist/oxlint.mjs +2 -2
- package/dist/workspace-settings.d.mts +32 -0
- package/dist/workspace-settings.mjs +216 -0
- package/dist/workspace-settings.mjs.map +1 -0
- package/dist/workspace-tasks-CRL-gm__.mjs +298 -0
- package/dist/workspace-tasks-CRL-gm__.mjs.map +1 -0
- package/package.json +13 -3
- package/src/vite.d.ts +36 -1
- package/dist/cli-contract-DpQurUwC.mjs +0 -286
- package/dist/cli-contract-DpQurUwC.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -30,20 +30,53 @@ export default defineConfig({ lint });
|
|
|
30
30
|
|
|
31
31
|
リポジトリに固有のルールや overrides は、`lint` を広げてから足す。
|
|
32
32
|
decision ルールは呼ぶたびに費用がかかるので、プリセットは有効にしない。
|
|
33
|
+
`import/no-nodejs-modules` は使わず、Effect に代わりのある Node.js の組み込みだけを `effecttsgo/node-builtin-import` で止める。
|
|
34
|
+
`eslint/new-cap` は `capIsNew` を切る。`new` なしでクラスを呼ぶ誤りは型検査が落とすので、大文字で始まる関数の呼び出しを例外として並べずに済む。
|
|
33
35
|
`decisionRules` を掛けたいファイルの overrides に渡す。
|
|
34
36
|
|
|
37
|
+
Vite+ はワークスペースの `vite.config.ts` の `lint` を使わない。
|
|
38
|
+
1 つのワークスペースだけに効く設定は、そのワークスペースの `vite.config.ts` の `msch` にリテラルで書く。
|
|
39
|
+
ルートの `vite.config.ts` は `@r_masseater/msch/workspace-settings` の `workspaceSettings` でそれを読む。
|
|
40
|
+
ワークスペースは `pnpm-workspace.yaml` の `packages` から求める。
|
|
41
|
+
ワークスペースの `vite.config.ts` は実行しないので、アプリの重いプラグインを読み込まずに済む。
|
|
42
|
+
`msch.lint` には overrides と ignorePatterns を書く。読んだパスの前には、ワークスペースのディレクトリが付く。
|
|
43
|
+
`msch.devDependencies` には、ルートが禁じた依存を devDependencies にだけ許す理由を鍵にして、許す依存を書く。
|
|
44
|
+
`use` は、ルートが `workspaceSettings` に渡す `ruleSets` と `dependencySets` の名前を指す。
|
|
45
|
+
import した値が要る規則と依存は、ルートの集合に名前を付けて置く。
|
|
46
|
+
`test` タスクを持たないワークスペースは `testProjects` に入り、ルートの `vp test` が動かす。
|
|
47
|
+
`workspaceSettings` はタスクも返す。`tasks.verify` は、`vite.config.ts` が `verify` タスクを書く各ワークスペースの `verify` タスクを列挙し、ルートの `verify` はそれらに依存する。
|
|
48
|
+
`components.json` の `aliases.ui` は `package.json` の `imports` で解決し、shadcn の部品の置き場を `lint.shadcnUi` として返す。
|
|
49
|
+
`package.json` の `exports` と `bin` が指すファイルは `lint.publicEntries` として返す。`dist` を指す入口は、`pack.entry` から元のファイルをたどる。プラグインや textlint のルールのように、読み込む側が default export を求める入口に使う。
|
|
50
|
+
|
|
35
51
|
`effecttsgo` のルールは、@effect/tsgo が手を入れた oxlint でだけ動く。
|
|
36
52
|
`prepare` で `effect-tsgo patch --typescript --oxlint` を実行するか、`effect-tsgo vp check` で動かす。
|
|
37
53
|
oxlint のバージョンは、@effect/tsgo が対応するものに合わせる。
|
|
38
54
|
|
|
39
55
|
## msch の検査
|
|
40
56
|
|
|
41
|
-
リポジトリのルートで `msch` を実行すると、値の集合と形の重複、overrides
|
|
57
|
+
リポジトリのルートで `msch` を実行すると、値の集合と形の重複、overrides の要不要、テストのためだけのコード、見えない文字、コメント、Python の使用、ルート以外の案内文書、npm に出すパッケージの依存の重さを調べる。
|
|
42
58
|
外部から読んだ値を Effect Schema で確かめるときは、`satisfies Schema.Decoder<ライブラリの型>` か変数の型注釈でライブラリの型に結びつける。結びつけた Schema は、ライブラリの形の写しとして指摘しない。
|
|
43
59
|
見えない文字は、ゼロ幅の文字・書字方向を変える制御文字・タグ文字のように、エディタやレビューで見えずに意味を変えうる文字で、`git ls-files` に載るテキストのファイルから探す。ファイル先頭の BOM と、NUL を含むバイナリは対象にしない。
|
|
60
|
+
コメントは、コード・マークアップ・設定・クエリのどれにも書かない。
|
|
61
|
+
msch は `git ls-files` に載るファイルを、その言語のパーサーで読んでコメントを探す。
|
|
62
|
+
TypeScript・JavaScript・Rust・C#・shell・PowerShell・Go・Java・Ruby・PHP・C・C++・シェーダー・CSS は tree-sitter で読む。
|
|
63
|
+
HTML と XML は htmlparser2 で読み、HTML の中のスクリプトとスタイルも調べる。画像の SVG は調べない。
|
|
64
|
+
YAML・TOML・SQL・Dockerfile は、それぞれのパーサーで読む。
|
|
65
|
+
許すのは、ツールが読むコメントだけである。
|
|
66
|
+
`oxlint-disable`・`/** @internal */`・`/** @msch <概念> */` などの lint のディレクティブと、1 行目のシェバンを許す。
|
|
67
|
+
`shellcheck`・`zizmor: ignore[...]`・`renovate:` も許す。
|
|
68
|
+
コミットに固定した action の後ろに書くバージョンと、drizzle の `--> statement-breakpoint` も許す。
|
|
69
|
+
lint のプリセットの `no-comments/disallowComments` も、同じ一覧を許す。
|
|
70
|
+
`.gitattributes` に `linguist-generated` や `linguist-vendored` とマークされたファイルや、ルートの `lint.ignorePatterns` で除外されたファイルは読み込まない。
|
|
71
|
+
リポジトリがコメントから独自のフォーマットを読み込む際は、ルートの `vite.config.ts` の `msch.comments.allow` に、それらのコメント用の正規表現を記述する。各記述は、コメントマーカー以降のテキストと照合される。
|
|
44
72
|
Python は使わない方針なので、`.py`・`pyproject.toml`・`uv.lock` などのファイルを指摘する。スクリプト・CI・設定の中で `python3`・`pip`・`uv`・`poetry` を呼ぶ箇所と、`actions/setup-python` などの action、`mise.toml` に書いた Python の道具も指摘する。
|
|
45
73
|
案内文書は、`AGENTS.md`・`CLAUDE.md` をルートにだけ置かせる。
|
|
46
|
-
|
|
74
|
+
ルートの `vite.config.ts` の文字列がワークスペースの中を指していると指摘する。そのワークスペースだけの設定は、そのワークスペースの `vite.config.ts` に移す。
|
|
75
|
+
Cargo のワークスペースがあれば、`verify` タスクを持つワークスペースの中にない crate を指摘する。
|
|
76
|
+
msch は、`vite.config.ts` の `verify` タスクを別のファイル内のコードから取得しているワークスペースを指摘する。ルートの `verify` は `vite.config.ts` を実行せずに読み込むため、その `verify` を一度も実行しないからである。
|
|
77
|
+
ルートの `vite.config.ts` に `msch: { workspaceAgentsMd: true }` と書くと、ワークスペース(`package.json` のあるディレクトリ)の直下にも `AGENTS.md` を置ける。`CLAUDE.md` はルートだけに置く。
|
|
78
|
+
README はルートまたはワークスペースのディレクトリ(`git ls-files` に載る `package.json` が格納されているディレクトリ)でのみ許可される。
|
|
79
|
+
msch は、ワークスペースのパス、ディレクトリ名、パッケージ名のいずれかを記載したルートの README を指摘する。ルートの README はリポジトリ全体について説明し、各ワークスペースの使用方法はそのワークスペースの README に記載する。
|
|
47
80
|
npm に出すワークスペースでは、インストールした側に増える依存の容量を `installSize` の予算と比べる。容量は、`dependencies`・`optionalDependencies`・必須の peer を node_modules からたどった合計で、そのパッケージ自身の `peerDependencies` に書いたものは数えない。予算を超えると、重い順に依存を並べ、公開の入口(`exports` と `bin`)の一部からしか import されないものにはその入口を添える。
|
|
48
81
|
`dependencies` に `catalog:stack` の依存があると、使う側がすでに持っているものとして、`peerDependencies` へ移すよう指摘する。
|
|
49
82
|
`tsconfig.json` の `types` に `@r_masseater/msch/vite` を足すと、`defineConfig` の `msch` に型が付く。
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { n as NODE_MODULES } from "./dependencies-x3j9tLcR.mjs";
|
|
2
|
+
import { Array, Option, Order, Schema, String as String$1, pipe } from "effect";
|
|
3
|
+
import { InternalSymbolName, SyntaxKind, getJSDocTags, getLeadingCommentRanges, getNameOfDeclaration, getTextOfJSDocComment } from "typescript/ast";
|
|
4
|
+
import { isArrayLiteralExpression, isBinaryExpression, isCallExpression, isClassDeclaration, isElementAccessExpression, isEnumDeclaration, isExportDeclaration, isIdentifier, isImportDeclaration, isInterfaceDeclaration, isModuleBlock, isModuleDeclaration, isNewExpression, isNumericLiteral, isObjectLiteralExpression, isPropertyAccessExpression, isPropertyAssignment, isSatisfiesExpression, isSignatureDeclaration, isSourceFile, isSpreadElement, isStringLiteral, isTypeAliasDeclaration, isTypeLiteralNode, isTypeReferenceNode, isUnionTypeNode, isVariableDeclaration, isVariableDeclarationList, isVariableStatement } from "typescript/ast/is";
|
|
5
|
+
import { API, IndexKind } from "typescript/sync";
|
|
6
|
+
// src/syntax.ts
|
|
7
|
+
const NODE_MODULES_SEGMENT = `/${NODE_MODULES}/`;
|
|
8
|
+
const uniqueByReference = (items) => Array.dedupeWith(items, (left, right) => left === right);
|
|
9
|
+
const childrenOf = (node) => {
|
|
10
|
+
const children = [];
|
|
11
|
+
node.forEachChild((child) => {
|
|
12
|
+
children.push(child);
|
|
13
|
+
});
|
|
14
|
+
return children;
|
|
15
|
+
};
|
|
16
|
+
const descendantsOf = (node) => pipe(childrenOf(node), Array.flatMap((child) => Array.prepend(descendantsOf(child), child)));
|
|
17
|
+
const isExternalFile = (program) => (sourceFile) => String$1.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) || program.isSourceFileFromExternalLibrary(sourceFile);
|
|
18
|
+
const isExternalDeclaration = (program) => (declaration) => isExternalFile(program)(declaration.getSourceFile());
|
|
19
|
+
const ALIAS_KINDS = /* @__PURE__ */ new Set([
|
|
20
|
+
SyntaxKind.ImportSpecifier,
|
|
21
|
+
SyntaxKind.ImportClause,
|
|
22
|
+
SyntaxKind.NamespaceImport,
|
|
23
|
+
SyntaxKind.ExportSpecifier,
|
|
24
|
+
SyntaxKind.ImportEqualsDeclaration,
|
|
25
|
+
SyntaxKind.ExportAssignment
|
|
26
|
+
]);
|
|
27
|
+
const declarationsOf = (symbol) => pipe(symbol.declarations, Array.flatMap((handle) => Option.toArray(Option.fromUndefinedOr(handle.resolve()))));
|
|
28
|
+
const isAliasDeclaration = (declaration) => ALIAS_KINDS.has(declaration.kind);
|
|
29
|
+
const resolvedSymbol = (checker) => (symbol) => {
|
|
30
|
+
if (!pipe(declarationsOf(symbol), Array.some((declaration) => isAliasDeclaration(declaration)))) return symbol;
|
|
31
|
+
return checker.getAliasedSymbol(symbol);
|
|
32
|
+
};
|
|
33
|
+
const symbolAt = (checker) => (node) => Option.fromUndefinedOr(checker.getSymbolAtLocation(node)).pipe(Option.map(resolvedSymbol(checker)));
|
|
34
|
+
const referencedSymbols = (checker) => (node) => {
|
|
35
|
+
const identifiers = pipe(Array.prepend(descendantsOf(node), node), Array.filter((candidate) => isIdentifier(candidate)));
|
|
36
|
+
const symbols = pipe(checker.getSymbolAtLocation(identifiers), Array.flatMap((symbol) => Option.toArray(Option.fromUndefinedOr(symbol))), Array.map(resolvedSymbol(checker)));
|
|
37
|
+
return uniqueByReference(symbols);
|
|
38
|
+
};
|
|
39
|
+
const lineOf = (node) => {
|
|
40
|
+
const sourceFile = node.getSourceFile();
|
|
41
|
+
return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;
|
|
42
|
+
};
|
|
43
|
+
const columnOf = (node) => {
|
|
44
|
+
const sourceFile = node.getSourceFile();
|
|
45
|
+
return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).character + 1;
|
|
46
|
+
};
|
|
47
|
+
const contains = (outer) => (inner) => outer.getSourceFile().fileName === inner.getSourceFile().fileName && outer.getStart() <= inner.getStart() && inner.getEnd() <= outer.getEnd();
|
|
48
|
+
const isTypeDeclaration = (declaration) => isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration) || isEnumDeclaration(declaration);
|
|
49
|
+
const isGenericDeclaration = (declaration) => (isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration)) && Array.isReadonlyArrayNonEmpty(declaration.typeParameters ?? []);
|
|
50
|
+
const propertyNamesOf = (checker) => (type) => pipe(checker.getPropertiesOfType(type), Array.map((property) => property.name));
|
|
51
|
+
const moduleSpecifierOf = (statement) => {
|
|
52
|
+
if (!isImportDeclaration(statement) && !isExportDeclaration(statement)) return Option.none();
|
|
53
|
+
return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(Option.filter((specifier) => isStringLiteral(specifier)), Option.map((specifier) => specifier.text));
|
|
54
|
+
};
|
|
55
|
+
const importedModulesOf = (sourceFile) => pipe(sourceFile.statements, Array.map((statement) => moduleSpecifierOf(statement)), Array.getSomes);
|
|
56
|
+
// src/problem.ts
|
|
57
|
+
const RuleNameSchema = Schema.Literals([
|
|
58
|
+
"owner-annotation",
|
|
59
|
+
"duplicate-value-set",
|
|
60
|
+
"owner-value-set",
|
|
61
|
+
"owner-extension",
|
|
62
|
+
"owned-literal",
|
|
63
|
+
"library-value-set",
|
|
64
|
+
"library-shape",
|
|
65
|
+
"unused-override",
|
|
66
|
+
"removable-override",
|
|
67
|
+
"hidden-unicode",
|
|
68
|
+
"python-file",
|
|
69
|
+
"python-command",
|
|
70
|
+
"nested-docs",
|
|
71
|
+
"root-readme",
|
|
72
|
+
"stack-dependency",
|
|
73
|
+
"install-size",
|
|
74
|
+
"unverified-crate",
|
|
75
|
+
"hidden-verify",
|
|
76
|
+
"root-workspace-path",
|
|
77
|
+
"comment"
|
|
78
|
+
]);
|
|
79
|
+
const ProblemSchema = Schema.Struct({
|
|
80
|
+
file: Schema.String,
|
|
81
|
+
line: Schema.Int,
|
|
82
|
+
column: Schema.Int,
|
|
83
|
+
rule: RuleNameSchema,
|
|
84
|
+
message: Schema.String
|
|
85
|
+
});
|
|
86
|
+
const ProblemList = Schema.Array(ProblemSchema);
|
|
87
|
+
const problemAt = ({ rule, message }) => (node) => ({
|
|
88
|
+
file: node.getSourceFile().fileName,
|
|
89
|
+
line: lineOf(node),
|
|
90
|
+
column: columnOf(node),
|
|
91
|
+
rule,
|
|
92
|
+
message
|
|
93
|
+
});
|
|
94
|
+
const problemOrder = Order.combineAll([
|
|
95
|
+
Order.mapInput(Order.String, (problem) => problem.file),
|
|
96
|
+
Order.mapInput(Order.Number, (problem) => problem.line),
|
|
97
|
+
Order.mapInput(Order.Number, (problem) => problem.column),
|
|
98
|
+
Order.mapInput(Order.String, (problem) => problem.rule),
|
|
99
|
+
Order.mapInput(Order.String, (problem) => problem.message)
|
|
100
|
+
]);
|
|
101
|
+
const problemKey = (problem) => pipe([
|
|
102
|
+
problem.file,
|
|
103
|
+
String(problem.line),
|
|
104
|
+
String(problem.column),
|
|
105
|
+
problem.rule,
|
|
106
|
+
problem.message
|
|
107
|
+
], Array.join("\0"));
|
|
108
|
+
const sortProblems = (problems) => Array.sort(Array.dedupeWith(problems, (left, right) => problemKey(left) === problemKey(right)), problemOrder);
|
|
109
|
+
const describeFinding = (problem) => `[${problem.rule}] ${problem.message}`;
|
|
110
|
+
const formatProblem = (relative) => (problem) => `${relative(problem.file)}:${String(problem.line)}:${String(problem.column)} ${describeFinding(problem)}`;
|
|
111
|
+
// src/cli-contract.ts
|
|
112
|
+
const JSON_FLAG = "--json";
|
|
113
|
+
export { isTypeAliasDeclaration as $, getTextOfJSDocComment as A, isInterfaceDeclaration as B, API as C, getJSDocTags as D, SyntaxKind as E, isElementAccessExpression as F, isObjectLiteralExpression as G, isModuleDeclaration as H, isEnumDeclaration as I, isSatisfiesExpression as J, isPropertyAccessExpression as K, isExportDeclaration as L, isBinaryExpression as M, isCallExpression as N, getLeadingCommentRanges as O, isClassDeclaration as P, isStringLiteral as Q, isIdentifier as R, uniqueByReference as S, InternalSymbolName as T, isNewExpression as U, isModuleBlock as V, isNumericLiteral as W, isSourceFile as X, isSignatureDeclaration as Y, isSpreadElement as Z, lineOf as _, problemAt as a, isVariableStatement as at, resolvedSymbol as b, childrenOf as c, declarationsOf as d, isTypeLiteralNode as et, descendantsOf as f, isTypeDeclaration as g, isGenericDeclaration as h, formatProblem as i, isVariableDeclarationList as it, isArrayLiteralExpression as j, getNameOfDeclaration as k, columnOf as l, isExternalDeclaration as m, ProblemList as n, isUnionTypeNode as nt, sortProblems as o, importedModulesOf as p, isPropertyAssignment as q, describeFinding as r, isVariableDeclaration as rt, NODE_MODULES_SEGMENT as s, JSON_FLAG as t, isTypeReferenceNode as tt, contains as u, propertyNamesOf as v, IndexKind as w, symbolAt as x, referencedSymbols as y, isImportDeclaration as z };
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=cli-contract-DlE7gy0b.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-contract-DlE7gy0b.mjs","names":["Arr","Str","Arr"],"sources":["../src/syntax.ts","../src/problem.ts","../src/cli-contract.ts"],"sourcesContent":["import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n isEnumDeclaration,\n isExportDeclaration,\n isIdentifier,\n isImportDeclaration,\n isInterfaceDeclaration,\n isStringLiteral,\n isTypeAliasDeclaration,\n SyntaxKind,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n Declaration,\n EnumDeclaration,\n InterfaceDeclaration,\n Node,\n Program,\n SourceFile,\n TypeSymbol,\n Type,\n TypeAliasDeclaration,\n} from \"./compiler.ts\";\nimport { NODE_MODULES } from \"./dependencies.ts\";\n\nconst NODE_MODULES_SEGMENT = `/${NODE_MODULES}/`;\n\nconst POSITION_BASE = 1;\n\nconst uniqueByReference = <Item>(items: readonly Item[]): readonly Item[] =>\n Arr.dedupeWith(items, (left, right) => left === right);\n\nconst childrenOf = (node: Node): readonly Node[] => {\n const children: Node[] = [];\n node.forEachChild((child) => {\n children.push(child);\n });\n return children;\n};\n\nconst descendantsOf = (node: Node): readonly Node[] =>\n pipe(\n childrenOf(node),\n Arr.flatMap((child) => Arr.prepend(descendantsOf(child), child)),\n );\n\nconst isExternalFile =\n (program: Program) =>\n (sourceFile: SourceFile): boolean =>\n Str.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) ||\n program.isSourceFileFromExternalLibrary(sourceFile);\n\nconst isExternalDeclaration =\n (program: Program) =>\n (declaration: Node): boolean =>\n isExternalFile(program)(declaration.getSourceFile());\n\nconst ALIAS_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.ImportSpecifier,\n SyntaxKind.ImportClause,\n SyntaxKind.NamespaceImport,\n SyntaxKind.ExportSpecifier,\n SyntaxKind.ImportEqualsDeclaration,\n SyntaxKind.ExportAssignment,\n]);\n\nconst declarationsOf = (symbol: TypeSymbol): readonly Declaration[] =>\n pipe(\n symbol.declarations,\n Arr.flatMap((handle) => Option.toArray(Option.fromUndefinedOr(handle.resolve()))),\n );\n\nconst isAliasDeclaration = (declaration: Node): boolean => ALIAS_KINDS.has(declaration.kind);\n\nconst resolvedSymbol =\n (checker: Checker) =>\n (symbol: TypeSymbol): TypeSymbol => {\n if (\n !pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isAliasDeclaration(declaration)),\n )\n ) {\n return symbol;\n }\n return checker.getAliasedSymbol(symbol);\n };\n\nconst symbolAt =\n (checker: Checker) =>\n (node: Node): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(checker.getSymbolAtLocation(node)).pipe(\n Option.map(resolvedSymbol(checker)),\n );\n\nconst referencedSymbols =\n (checker: Checker) =>\n (node: Node): readonly TypeSymbol[] => {\n const identifiers = pipe(\n Arr.prepend(descendantsOf(node), node),\n Arr.filter((candidate) => isIdentifier(candidate)),\n );\n const symbols = pipe(\n checker.getSymbolAtLocation(identifiers),\n Arr.flatMap((symbol) => Option.toArray(Option.fromUndefinedOr(symbol))),\n Arr.map(resolvedSymbol(checker)),\n );\n return uniqueByReference(symbols);\n };\n\nconst lineOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + POSITION_BASE;\n};\n\nconst columnOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return (\n sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).character + POSITION_BASE\n );\n};\n\nconst contains =\n (outer: Node) =>\n (inner: Node): boolean =>\n outer.getSourceFile().fileName === inner.getSourceFile().fileName &&\n outer.getStart() <= inner.getStart() &&\n inner.getEnd() <= outer.getEnd();\n\nconst isTypeDeclaration = (\n declaration: Node,\n): declaration is TypeAliasDeclaration | InterfaceDeclaration | EnumDeclaration =>\n isTypeAliasDeclaration(declaration) ||\n isInterfaceDeclaration(declaration) ||\n isEnumDeclaration(declaration);\n\nconst isGenericDeclaration = (declaration: Node): boolean =>\n (isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration)) &&\n Arr.isReadonlyArrayNonEmpty(declaration.typeParameters ?? []);\n\nconst propertyNamesOf =\n (checker: Checker) =>\n (type: Type): readonly string[] =>\n pipe(\n checker.getPropertiesOfType(type),\n Arr.map((property) => property.name),\n );\n\nconst moduleSpecifierOf = (statement: Node): Option.Option<string> => {\n if (!isImportDeclaration(statement) && !isExportDeclaration(statement)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(\n Option.filter((specifier) => isStringLiteral(specifier)),\n Option.map((specifier) => specifier.text),\n );\n};\n\nconst importedModulesOf = (sourceFile: SourceFile): readonly string[] =>\n pipe(\n sourceFile.statements,\n Arr.map((statement) => moduleSpecifierOf(statement)),\n Arr.getSomes,\n );\n\nexport {\n NODE_MODULES_SEGMENT,\n POSITION_BASE,\n childrenOf,\n columnOf,\n contains,\n declarationsOf,\n descendantsOf,\n importedModulesOf,\n isExternalDeclaration,\n isGenericDeclaration,\n isTypeDeclaration,\n lineOf,\n propertyNamesOf,\n referencedSymbols,\n resolvedSymbol,\n symbolAt,\n uniqueByReference,\n};\n","import { Array as Arr, Order, Schema, pipe } from \"effect\";\n\nimport type { Node } from \"./compiler.ts\";\nimport { columnOf, lineOf } from \"./syntax.ts\";\n\nconst RuleNameSchema = Schema.Literals([\n \"owner-annotation\",\n \"duplicate-value-set\",\n \"owner-value-set\",\n \"owner-extension\",\n \"owned-literal\",\n \"library-value-set\",\n \"library-shape\",\n \"unused-override\",\n \"removable-override\",\n \"hidden-unicode\",\n \"python-file\",\n \"python-command\",\n \"nested-docs\",\n \"root-readme\",\n \"stack-dependency\",\n \"install-size\",\n \"unverified-crate\",\n \"hidden-verify\",\n \"root-workspace-path\",\n \"comment\",\n]);\n\ntype RuleName = typeof RuleNameSchema.Type;\n\nconst ProblemSchema = Schema.Struct({\n file: Schema.String,\n line: Schema.Int,\n column: Schema.Int,\n rule: RuleNameSchema,\n message: Schema.String,\n});\n\ntype Problem = typeof ProblemSchema.Type;\n\nconst ProblemList = Schema.Array(ProblemSchema);\n\nconst CANDIDATE_LIMIT = 3;\n\ninterface Finding {\n readonly rule: RuleName;\n readonly message: string;\n}\n\nconst problemAt =\n ({ rule, message }: Finding) =>\n (node: Node): Problem => ({\n file: node.getSourceFile().fileName,\n line: lineOf(node),\n column: columnOf(node),\n rule,\n message,\n });\n\nconst problemOrder: Order.Order<Problem> = Order.combineAll([\n Order.mapInput(Order.String, (problem: Problem) => problem.file),\n Order.mapInput(Order.Number, (problem: Problem) => problem.line),\n Order.mapInput(Order.Number, (problem: Problem) => problem.column),\n Order.mapInput(Order.String, (problem: Problem) => problem.rule),\n Order.mapInput(Order.String, (problem: Problem) => problem.message),\n]);\n\nconst problemKey = (problem: Problem): string =>\n pipe(\n [problem.file, String(problem.line), String(problem.column), problem.rule, problem.message],\n Arr.join(\"\\0\"),\n );\n\nconst sortProblems = (problems: readonly Problem[]): readonly Problem[] =>\n Arr.sort(\n Arr.dedupeWith(problems, (left, right) => problemKey(left) === problemKey(right)),\n problemOrder,\n );\n\nconst describeFinding = (problem: Problem): string => `[${problem.rule}] ${problem.message}`;\n\nconst formatProblem =\n (relative: (file: string) => string) =>\n (problem: Problem): string =>\n `${relative(problem.file)}:${String(problem.line)}:${String(problem.column)} ${describeFinding(problem)}`;\n\nexport { CANDIDATE_LIMIT, ProblemList, describeFinding, formatProblem, problemAt, sortProblems };\nexport type { Finding, Problem, RuleName };\n","const JSON_FLAG = \"--json\";\n\nexport { JSON_FLAG };\n"],"mappings":";;;;;;AA0BA,MAAM,uBAAuB,IAAI,aAAa;AAI9C,MAAM,qBAA2B,UAC/BA,MAAI,WAAW,QAAQ,MAAM,UAAU,SAAS,KAAK;AAEvD,MAAM,cAAc,SAAgC;CAClD,MAAM,WAAmB,CAAC;CAC1B,KAAK,cAAc,UAAU;EAC3B,SAAS,KAAK,KAAK;CACrB,CAAC;CACD,OAAO;AACT;AAEA,MAAM,iBAAiB,SACrB,KACE,WAAW,IAAI,GACfA,MAAI,SAAS,UAAUA,MAAI,QAAQ,cAAc,KAAK,GAAG,KAAK,CAAC,CACjE;AAEF,MAAM,kBACH,aACA,eACCC,SAAI,SAAS,oBAAoB,CAAC,CAAC,WAAW,QAAQ,KACtD,QAAQ,gCAAgC,UAAU;AAEtD,MAAM,yBACH,aACA,gBACC,eAAe,OAAO,CAAC,CAAC,YAAY,cAAc,CAAC;AAEvD,MAAM,8BAAuC,IAAI,IAAI;CACnD,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;AACb,CAAC;AAED,MAAM,kBAAkB,WACtB,KACE,OAAO,cACPD,MAAI,SAAS,WAAW,OAAO,QAAQ,OAAO,gBAAgB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAClF;AAEF,MAAM,sBAAsB,gBAA+B,YAAY,IAAI,YAAY,IAAI;AAE3F,MAAM,kBACH,aACA,WAAmC;CAClC,IACE,CAAC,KACC,eAAe,MAAM,GACrBA,MAAI,MAAM,gBAAgB,mBAAmB,WAAW,CAAC,CAC3D,GAEA,OAAO;CAET,OAAO,QAAQ,iBAAiB,MAAM;AACxC;AAEF,MAAM,YACH,aACA,SACC,OAAO,gBAA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