@webpieces/code-rules 0.4.979 → 0.4.980
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/package.json +8 -7
- package/src/code-policy-registry.js +5 -0
- package/src/code-policy-registry.js.map +1 -1
- package/src/configs/ipc-configs.d.ts +158 -0
- package/src/configs/ipc-configs.js +206 -0
- package/src/configs/ipc-configs.js.map +1 -0
- package/src/index.d.ts +7 -0
- package/src/index.js +20 -1
- package/src/index.js.map +1 -1
- package/src/ipc/ipc-boundary-analyzer.d.ts +92 -0
- package/src/ipc/ipc-boundary-analyzer.js +371 -0
- package/src/ipc/ipc-boundary-analyzer.js.map +1 -0
- package/src/ipc/ipc-contract-inventory.d.ts +83 -0
- package/src/ipc/ipc-contract-inventory.js +215 -0
- package/src/ipc/ipc-contract-inventory.js.map +1 -0
- package/src/ipc/ipc-contract-shape-analyzer.d.ts +54 -0
- package/src/ipc/ipc-contract-shape-analyzer.js +186 -0
- package/src/ipc/ipc-contract-shape-analyzer.js.map +1 -0
- package/src/ipc/ipc-controller-resolver.d.ts +43 -0
- package/src/ipc/ipc-controller-resolver.js +187 -0
- package/src/ipc/ipc-controller-resolver.js.map +1 -0
- package/src/ipc/ipc-pairing-analyzer.d.ts +43 -0
- package/src/ipc/ipc-pairing-analyzer.js +247 -0
- package/src/ipc/ipc-pairing-analyzer.js.map +1 -0
- package/src/ipc/ipc-protocol-fingerprint.d.ts +50 -0
- package/src/ipc/ipc-protocol-fingerprint.js +215 -0
- package/src/ipc/ipc-protocol-fingerprint.js.map +1 -0
- package/src/ipc/ipc-protocol-recorder.d.ts +25 -0
- package/src/ipc/ipc-protocol-recorder.js +98 -0
- package/src/ipc/ipc-protocol-recorder.js.map +1 -0
- package/src/ipc/ipc-rule-support.d.ts +27 -0
- package/src/ipc/ipc-rule-support.js +76 -0
- package/src/ipc/ipc-rule-support.js.map +1 -0
- package/src/ipc/ipc-source.d.ts +96 -0
- package/src/ipc/ipc-source.js +239 -0
- package/src/ipc/ipc-source.js.map +1 -0
- package/src/ipc-record-protocol.d.ts +2 -0
- package/src/ipc-record-protocol.js +34 -0
- package/src/ipc-record-protocol.js.map +1 -0
- package/src/rule-help.js +4 -0
- package/src/rule-help.js.map +1 -1
- package/src/rule-settings.js +119 -1
- package/src/rule-settings.js.map +1 -1
- package/src/validate-ipc-boundary.d.ts +20 -0
- package/src/validate-ipc-boundary.js +96 -0
- package/src/validate-ipc-boundary.js.map +1 -0
- package/src/validate-ipc-contract-shape.d.ts +20 -0
- package/src/validate-ipc-contract-shape.js +105 -0
- package/src/validate-ipc-contract-shape.js.map +1 -0
- package/src/validate-ipc-pairing.d.ts +16 -0
- package/src/validate-ipc-pairing.js +71 -0
- package/src/validate-ipc-pairing.js.map +1 -0
- package/src/validate-ipc-protocol-fingerprint.d.ts +23 -0
- package/src/validate-ipc-protocol-fingerprint.js +79 -0
- package/src/validate-ipc-protocol-fingerprint.js.map +1 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared syntax layer of the four IPC rules (#1389): one parsed file, its import bindings, and the
|
|
3
|
+
* resolution of a module specifier to a workspace file — all WITHOUT a `ts.Program`.
|
|
4
|
+
*
|
|
5
|
+
* Why no program: the script these rules replace built one over every source file of the monorepo and
|
|
6
|
+
* ran the checker over all of it; a program keeps every AST and symbol table resident, so its memory grew
|
|
7
|
+
* with the repo and exhausted Node's default heap on CI. Each rule here reads exactly the files it judges.
|
|
8
|
+
* A specifier is resolved with `ts.resolveModuleName`, which probes the file system for ONE specifier and
|
|
9
|
+
* builds nothing; the tsconfig is parsed with a host that never enumerates the repo's files.
|
|
10
|
+
*/
|
|
11
|
+
import * as ts from 'typescript';
|
|
12
|
+
/** One refused site: where it is and why. Data-only. */
|
|
13
|
+
export declare class IpcFinding {
|
|
14
|
+
/** Workspace-relative. */
|
|
15
|
+
readonly relFile: string;
|
|
16
|
+
/** 1-based. */
|
|
17
|
+
readonly line: number;
|
|
18
|
+
readonly snippet: string;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
constructor(
|
|
21
|
+
/** Workspace-relative. */
|
|
22
|
+
relFile: string,
|
|
23
|
+
/** 1-based. */
|
|
24
|
+
line: number, snippet: string, message: string);
|
|
25
|
+
}
|
|
26
|
+
/** One name an import declaration binds. Data-only. */
|
|
27
|
+
export declare class IpcImportBinding {
|
|
28
|
+
/** The local name in this file. */
|
|
29
|
+
readonly local: string;
|
|
30
|
+
/** The exported name it refers to; `default` or `*` (namespace) for those forms. */
|
|
31
|
+
readonly imported: string;
|
|
32
|
+
readonly moduleSpecifier: string;
|
|
33
|
+
/** `import type` or an inline `type` specifier — erased at compile time. */
|
|
34
|
+
readonly typeOnly: boolean;
|
|
35
|
+
readonly node: ts.Node;
|
|
36
|
+
constructor(
|
|
37
|
+
/** The local name in this file. */
|
|
38
|
+
local: string,
|
|
39
|
+
/** The exported name it refers to; `default` or `*` (namespace) for those forms. */
|
|
40
|
+
imported: string, moduleSpecifier: string,
|
|
41
|
+
/** `import type` or an inline `type` specifier — erased at compile time. */
|
|
42
|
+
typeOnly: boolean, node: ts.Node);
|
|
43
|
+
}
|
|
44
|
+
/** One parsed source file, workspace-relative, with its import bindings. */
|
|
45
|
+
export declare class IpcSourceFile {
|
|
46
|
+
readonly relFile: string;
|
|
47
|
+
readonly source: ts.SourceFile;
|
|
48
|
+
private bindings;
|
|
49
|
+
constructor(relFile: string, source: ts.SourceFile);
|
|
50
|
+
lineOf(node: ts.Node): number;
|
|
51
|
+
snippetOf(node: ts.Node): string;
|
|
52
|
+
finding(node: ts.Node, message: string): IpcFinding;
|
|
53
|
+
/** Every binding of every top-level import declaration. */
|
|
54
|
+
imports(): readonly IpcImportBinding[];
|
|
55
|
+
/** The import binding a local name refers to, if it is imported. */
|
|
56
|
+
importOf(local: string): IpcImportBinding | undefined;
|
|
57
|
+
/** The top-level class declared with this name, if any. */
|
|
58
|
+
classNamed(name: string): ts.ClassDeclaration | undefined;
|
|
59
|
+
/** The initializer of the top-level `const|let|var <name> = …`, if any. */
|
|
60
|
+
variableInitializer(name: string): ts.Expression | undefined;
|
|
61
|
+
private readImports;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parses workspace files on demand and caches them for one rule run, so a file reached from two
|
|
65
|
+
* registrations is parsed once — and only files a rule actually reaches are ever parsed.
|
|
66
|
+
*/
|
|
67
|
+
export declare class IpcFileReader {
|
|
68
|
+
readonly workspaceRoot: string;
|
|
69
|
+
private readonly cache;
|
|
70
|
+
constructor(workspaceRoot: string);
|
|
71
|
+
exists(relFile: string): boolean;
|
|
72
|
+
/** The parsed file, cached for the rest of the run, or undefined when it does not exist. */
|
|
73
|
+
read(relFile: string): IpcSourceFile | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* The parsed file WITHOUT caching it — for a per-file rule walking many files, so each tree is garbage
|
|
76
|
+
* as soon as it is judged and memory stays flat however many files the mode selects.
|
|
77
|
+
*/
|
|
78
|
+
parse(relFile: string): IpcSourceFile | undefined;
|
|
79
|
+
}
|
|
80
|
+
/** Reads a tsconfig's compiler options (following `extends`) without enumerating any source file. */
|
|
81
|
+
export declare class IpcCompilerOptionsReader {
|
|
82
|
+
read(workspaceRoot: string, tsconfigPath: string): ts.CompilerOptions;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Resolves a module specifier written in a workspace file to the workspace file it names (relative
|
|
86
|
+
* imports and tsconfig `paths` aliases alike), or undefined for a package or an unresolvable specifier.
|
|
87
|
+
*/
|
|
88
|
+
export declare class IpcModuleResolver {
|
|
89
|
+
private readonly workspaceRoot;
|
|
90
|
+
private readonly options;
|
|
91
|
+
private readonly cache;
|
|
92
|
+
private readonly moduleCache;
|
|
93
|
+
constructor(workspaceRoot: string, options: ts.CompilerOptions);
|
|
94
|
+
resolve(fromRelFile: string, specifier: string): string | undefined;
|
|
95
|
+
private workspaceRelative;
|
|
96
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The shared syntax layer of the four IPC rules (#1389): one parsed file, its import bindings, and the
|
|
4
|
+
* resolution of a module specifier to a workspace file — all WITHOUT a `ts.Program`.
|
|
5
|
+
*
|
|
6
|
+
* Why no program: the script these rules replace built one over every source file of the monorepo and
|
|
7
|
+
* ran the checker over all of it; a program keeps every AST and symbol table resident, so its memory grew
|
|
8
|
+
* with the repo and exhausted Node's default heap on CI. Each rule here reads exactly the files it judges.
|
|
9
|
+
* A specifier is resolved with `ts.resolveModuleName`, which probes the file system for ONE specifier and
|
|
10
|
+
* builds nothing; the tsconfig is parsed with a host that never enumerates the repo's files.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.IpcModuleResolver = exports.IpcCompilerOptionsReader = exports.IpcFileReader = exports.IpcSourceFile = exports.IpcImportBinding = exports.IpcFinding = void 0;
|
|
14
|
+
const tslib_1 = require("tslib");
|
|
15
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
16
|
+
const path = tslib_1.__importStar(require("path"));
|
|
17
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
18
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
19
|
+
/** One refused site: where it is and why. Data-only. */
|
|
20
|
+
class IpcFinding {
|
|
21
|
+
relFile;
|
|
22
|
+
line;
|
|
23
|
+
snippet;
|
|
24
|
+
message;
|
|
25
|
+
constructor(
|
|
26
|
+
/** Workspace-relative. */
|
|
27
|
+
relFile,
|
|
28
|
+
/** 1-based. */
|
|
29
|
+
line, snippet, message) {
|
|
30
|
+
this.relFile = relFile;
|
|
31
|
+
this.line = line;
|
|
32
|
+
this.snippet = snippet;
|
|
33
|
+
this.message = message;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.IpcFinding = IpcFinding;
|
|
37
|
+
/** One name an import declaration binds. Data-only. */
|
|
38
|
+
class IpcImportBinding {
|
|
39
|
+
local;
|
|
40
|
+
imported;
|
|
41
|
+
moduleSpecifier;
|
|
42
|
+
typeOnly;
|
|
43
|
+
node;
|
|
44
|
+
constructor(
|
|
45
|
+
/** The local name in this file. */
|
|
46
|
+
local,
|
|
47
|
+
/** The exported name it refers to; `default` or `*` (namespace) for those forms. */
|
|
48
|
+
imported, moduleSpecifier,
|
|
49
|
+
/** `import type` or an inline `type` specifier — erased at compile time. */
|
|
50
|
+
typeOnly, node) {
|
|
51
|
+
this.local = local;
|
|
52
|
+
this.imported = imported;
|
|
53
|
+
this.moduleSpecifier = moduleSpecifier;
|
|
54
|
+
this.typeOnly = typeOnly;
|
|
55
|
+
this.node = node;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.IpcImportBinding = IpcImportBinding;
|
|
59
|
+
/** One parsed source file, workspace-relative, with its import bindings. */
|
|
60
|
+
class IpcSourceFile {
|
|
61
|
+
relFile;
|
|
62
|
+
source;
|
|
63
|
+
bindings;
|
|
64
|
+
constructor(relFile, source) {
|
|
65
|
+
this.relFile = relFile;
|
|
66
|
+
this.source = source;
|
|
67
|
+
}
|
|
68
|
+
lineOf(node) {
|
|
69
|
+
return this.source.getLineAndCharacterOfPosition(node.getStart(this.source)).line + 1;
|
|
70
|
+
}
|
|
71
|
+
snippetOf(node) {
|
|
72
|
+
const text = node.getText(this.source).replace(/\s+/g, ' ').trim();
|
|
73
|
+
return text.length > 160 ? `${text.slice(0, 157)}...` : text;
|
|
74
|
+
}
|
|
75
|
+
finding(node, message) {
|
|
76
|
+
return new IpcFinding(this.relFile, this.lineOf(node), this.snippetOf(node), message);
|
|
77
|
+
}
|
|
78
|
+
/** Every binding of every top-level import declaration. */
|
|
79
|
+
imports() {
|
|
80
|
+
if (this.bindings === undefined)
|
|
81
|
+
this.bindings = this.readImports();
|
|
82
|
+
return this.bindings;
|
|
83
|
+
}
|
|
84
|
+
/** The import binding a local name refers to, if it is imported. */
|
|
85
|
+
importOf(local) {
|
|
86
|
+
return this.imports().find((binding) => binding.local === local);
|
|
87
|
+
}
|
|
88
|
+
/** The top-level class declared with this name, if any. */
|
|
89
|
+
classNamed(name) {
|
|
90
|
+
return this.source.statements.find((statement) => ts.isClassDeclaration(statement) && statement.name?.text === name);
|
|
91
|
+
}
|
|
92
|
+
/** The initializer of the top-level `const|let|var <name> = …`, if any. */
|
|
93
|
+
variableInitializer(name) {
|
|
94
|
+
for (const statement of this.source.statements) {
|
|
95
|
+
if (!ts.isVariableStatement(statement))
|
|
96
|
+
continue;
|
|
97
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
98
|
+
if (ts.isIdentifier(declaration.name) && declaration.name.text === name)
|
|
99
|
+
return declaration.initializer;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
readImports() {
|
|
105
|
+
const out = [];
|
|
106
|
+
for (const statement of this.source.statements) {
|
|
107
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier))
|
|
108
|
+
continue;
|
|
109
|
+
const clause = statement.importClause;
|
|
110
|
+
if (clause === undefined)
|
|
111
|
+
continue;
|
|
112
|
+
const specifier = statement.moduleSpecifier.text;
|
|
113
|
+
const clauseTypeOnly = clause.isTypeOnly;
|
|
114
|
+
if (clause.name)
|
|
115
|
+
out.push(new IpcImportBinding(clause.name.text, 'default', specifier, clauseTypeOnly, clause.name));
|
|
116
|
+
const named = clause.namedBindings;
|
|
117
|
+
if (named !== undefined && ts.isNamespaceImport(named)) {
|
|
118
|
+
out.push(new IpcImportBinding(named.name.text, '*', specifier, clauseTypeOnly, named));
|
|
119
|
+
}
|
|
120
|
+
else if (named !== undefined) {
|
|
121
|
+
for (const element of named.elements) {
|
|
122
|
+
const imported = element.propertyName?.text ?? element.name.text;
|
|
123
|
+
out.push(new IpcImportBinding(element.name.text, imported, specifier, clauseTypeOnly || element.isTypeOnly, element));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.IpcSourceFile = IpcSourceFile;
|
|
131
|
+
/**
|
|
132
|
+
* Parses workspace files on demand and caches them for one rule run, so a file reached from two
|
|
133
|
+
* registrations is parsed once — and only files a rule actually reaches are ever parsed.
|
|
134
|
+
*/
|
|
135
|
+
class IpcFileReader {
|
|
136
|
+
workspaceRoot;
|
|
137
|
+
cache = new Map();
|
|
138
|
+
constructor(workspaceRoot) {
|
|
139
|
+
this.workspaceRoot = workspaceRoot;
|
|
140
|
+
}
|
|
141
|
+
exists(relFile) {
|
|
142
|
+
return fs.existsSync(path.join(this.workspaceRoot, relFile));
|
|
143
|
+
}
|
|
144
|
+
/** The parsed file, cached for the rest of the run, or undefined when it does not exist. */
|
|
145
|
+
read(relFile) {
|
|
146
|
+
const cached = this.cache.get(relFile);
|
|
147
|
+
if (cached !== undefined)
|
|
148
|
+
return cached ?? undefined;
|
|
149
|
+
const parsed = this.parse(relFile);
|
|
150
|
+
this.cache.set(relFile, parsed ?? null);
|
|
151
|
+
return parsed;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The parsed file WITHOUT caching it — for a per-file rule walking many files, so each tree is garbage
|
|
155
|
+
* as soon as it is judged and memory stays flat however many files the mode selects.
|
|
156
|
+
*/
|
|
157
|
+
parse(relFile) {
|
|
158
|
+
const absFile = path.join(this.workspaceRoot, relFile);
|
|
159
|
+
if (!fs.existsSync(absFile))
|
|
160
|
+
return undefined;
|
|
161
|
+
const text = fs.readFileSync(absFile, 'utf8');
|
|
162
|
+
const kind = relFile.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
163
|
+
return new IpcSourceFile(relFile, ts.createSourceFile(absFile, text, ts.ScriptTarget.Latest, true, kind));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.IpcFileReader = IpcFileReader;
|
|
167
|
+
/** A tsconfig host that answers file questions but NEVER lists a directory — no repo walk. */
|
|
168
|
+
class NoEnumerationHost {
|
|
169
|
+
useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
|
|
170
|
+
readDirectory() {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
fileExists(file) {
|
|
174
|
+
return ts.sys.fileExists(file);
|
|
175
|
+
}
|
|
176
|
+
readFile(file) {
|
|
177
|
+
return ts.sys.readFile(file);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/** Reads a tsconfig's compiler options (following `extends`) without enumerating any source file. */
|
|
181
|
+
class IpcCompilerOptionsReader {
|
|
182
|
+
read(workspaceRoot, tsconfigPath) {
|
|
183
|
+
const absConfig = path.join(workspaceRoot, tsconfigPath);
|
|
184
|
+
if (!fs.existsSync(absConfig)) {
|
|
185
|
+
throw new tooling_common_1.InformAiError(`IPC rules: tsconfigPath "${tsconfigPath}" does not exist under ${workspaceRoot}. ` +
|
|
186
|
+
'Point the rule\'s "tsconfigPath" at the tsconfig whose "paths" resolve your imports.');
|
|
187
|
+
}
|
|
188
|
+
const raw = ts.readConfigFile(absConfig, ts.sys.readFile);
|
|
189
|
+
if (raw.error !== undefined) {
|
|
190
|
+
throw new tooling_common_1.InformAiError(`IPC rules: cannot read ${tsconfigPath}: ${ts.flattenDiagnosticMessageText(raw.error.messageText, '\n')}`);
|
|
191
|
+
}
|
|
192
|
+
const parsed = ts.parseJsonConfigFileContent(raw.config, new NoEnumerationHost(), path.dirname(absConfig));
|
|
193
|
+
return {
|
|
194
|
+
...parsed.options,
|
|
195
|
+
noEmit: true,
|
|
196
|
+
skipLibCheck: true,
|
|
197
|
+
allowJs: false,
|
|
198
|
+
module: ts.ModuleKind.ESNext,
|
|
199
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
200
|
+
jsx: ts.JsxEmit.ReactJSX,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.IpcCompilerOptionsReader = IpcCompilerOptionsReader;
|
|
205
|
+
/**
|
|
206
|
+
* Resolves a module specifier written in a workspace file to the workspace file it names (relative
|
|
207
|
+
* imports and tsconfig `paths` aliases alike), or undefined for a package or an unresolvable specifier.
|
|
208
|
+
*/
|
|
209
|
+
class IpcModuleResolver {
|
|
210
|
+
workspaceRoot;
|
|
211
|
+
options;
|
|
212
|
+
cache = new Map();
|
|
213
|
+
moduleCache;
|
|
214
|
+
constructor(workspaceRoot, options) {
|
|
215
|
+
this.workspaceRoot = workspaceRoot;
|
|
216
|
+
this.options = options;
|
|
217
|
+
this.moduleCache = ts.createModuleResolutionCache(workspaceRoot, (name) => name, options);
|
|
218
|
+
}
|
|
219
|
+
resolve(fromRelFile, specifier) {
|
|
220
|
+
const key = `${path.posix.dirname(fromRelFile)}\u0000${specifier}`;
|
|
221
|
+
const cached = this.cache.get(key);
|
|
222
|
+
if (cached !== undefined)
|
|
223
|
+
return cached ?? undefined;
|
|
224
|
+
const containing = path.join(this.workspaceRoot, fromRelFile);
|
|
225
|
+
const result = ts.resolveModuleName(specifier, containing, this.options, ts.sys, this.moduleCache);
|
|
226
|
+
const resolved = result.resolvedModule?.resolvedFileName;
|
|
227
|
+
const rel = resolved === undefined ? undefined : this.workspaceRelative(resolved);
|
|
228
|
+
this.cache.set(key, rel ?? null);
|
|
229
|
+
return rel;
|
|
230
|
+
}
|
|
231
|
+
workspaceRelative(absFile) {
|
|
232
|
+
const rel = path.relative(this.workspaceRoot, absFile).split(path.sep).join('/');
|
|
233
|
+
if (rel.startsWith('..') || path.isAbsolute(rel) || rel.split('/').includes('node_modules'))
|
|
234
|
+
return undefined;
|
|
235
|
+
return rel;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
exports.IpcModuleResolver = IpcModuleResolver;
|
|
239
|
+
//# sourceMappingURL=ipc-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipc-source.js","sourceRoot":"","sources":["../../../../../../packages/tooling/code-rules/src/ipc/ipc-source.ts"],"names":[],"mappings":";AAAA;;;;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QACnC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,IAAI,SAAS,CAAC;QACrD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACnG,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,EAAE,gBAAgB,CAAC;QACzD,MAAM,GAAG,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAClF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC;QACjC,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,iBAAiB,CAAC,OAAe;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjF,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC;YAAE,OAAO,SAAS,CAAC;QAC9G,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AA5BD,8CA4BC","sourcesContent":["/**\n * The shared syntax layer of the four IPC rules (#1389): one parsed file, its import bindings, and the\n * resolution of a module specifier to a workspace file — all WITHOUT a `ts.Program`.\n *\n * Why no program: the script these rules replace built one over every source file of the monorepo and\n * ran the checker over all of it; a program keeps every AST and symbol table resident, so its memory grew\n * with the repo and exhausted Node's default heap on CI. Each rule here reads exactly the files it judges.\n * A specifier is resolved with `ts.resolveModuleName`, which probes the file system for ONE specifier and\n * builds nothing; the tsconfig is parsed with a host that never enumerates the repo's files.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { InformAiError } from '@webpieces/tooling-common';\n\n/** One refused site: where it is and why. Data-only. */\nexport class IpcFinding {\n constructor(\n /** Workspace-relative. */\n readonly relFile: string,\n /** 1-based. */\n readonly line: number,\n readonly snippet: string,\n readonly message: string,\n ) {}\n}\n\n/** One name an import declaration binds. Data-only. */\nexport class IpcImportBinding {\n constructor(\n /** The local name in this file. */\n readonly local: string,\n /** The exported name it refers to; `default` or `*` (namespace) for those forms. */\n readonly imported: string,\n readonly moduleSpecifier: string,\n /** `import type` or an inline `type` specifier — erased at compile time. */\n readonly typeOnly: boolean,\n readonly node: ts.Node,\n ) {}\n}\n\n/** One parsed source file, workspace-relative, with its import bindings. */\nexport class IpcSourceFile {\n private bindings: IpcImportBinding[] | undefined;\n\n constructor(\n readonly relFile: string,\n readonly source: ts.SourceFile,\n ) {}\n\n lineOf(node: ts.Node): number {\n return this.source.getLineAndCharacterOfPosition(node.getStart(this.source)).line + 1;\n }\n\n snippetOf(node: ts.Node): string {\n const text = node.getText(this.source).replace(/\\s+/g, ' ').trim();\n return text.length > 160 ? `${text.slice(0, 157)}...` : text;\n }\n\n finding(node: ts.Node, message: string): IpcFinding {\n return new IpcFinding(this.relFile, this.lineOf(node), this.snippetOf(node), message);\n }\n\n /** Every binding of every top-level import declaration. */\n imports(): readonly IpcImportBinding[] {\n if (this.bindings === undefined) this.bindings = this.readImports();\n return this.bindings;\n }\n\n /** The import binding a local name refers to, if it is imported. */\n importOf(local: string): IpcImportBinding | undefined {\n return this.imports().find((binding: IpcImportBinding) => binding.local === local);\n }\n\n /** The top-level class declared with this name, if any. */\n classNamed(name: string): ts.ClassDeclaration | undefined {\n return this.source.statements.find(\n (statement: ts.Statement): statement is ts.ClassDeclaration =>\n ts.isClassDeclaration(statement) && statement.name?.text === name,\n );\n }\n\n /** The initializer of the top-level `const|let|var <name> = …`, if any. */\n variableInitializer(name: string): ts.Expression | undefined {\n for (const statement of this.source.statements) {\n if (!ts.isVariableStatement(statement)) continue;\n for (const declaration of statement.declarationList.declarations) {\n if (ts.isIdentifier(declaration.name) && declaration.name.text === name) return declaration.initializer;\n }\n }\n return undefined;\n }\n\n private readImports(): IpcImportBinding[] {\n const out: IpcImportBinding[] = [];\n for (const statement of this.source.statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;\n const clause = statement.importClause;\n if (clause === undefined) continue;\n const specifier = statement.moduleSpecifier.text;\n const clauseTypeOnly = clause.isTypeOnly;\n if (clause.name) out.push(new IpcImportBinding(clause.name.text, 'default', specifier, clauseTypeOnly, clause.name));\n const named = clause.namedBindings;\n if (named !== undefined && ts.isNamespaceImport(named)) {\n out.push(new IpcImportBinding(named.name.text, '*', specifier, clauseTypeOnly, named));\n } else if (named !== undefined) {\n for (const element of named.elements) {\n const imported = element.propertyName?.text ?? element.name.text;\n out.push(new IpcImportBinding(element.name.text, imported, specifier, clauseTypeOnly || element.isTypeOnly, element));\n }\n }\n }\n return out;\n }\n}\n\n/**\n * Parses workspace files on demand and caches them for one rule run, so a file reached from two\n * registrations is parsed once — and only files a rule actually reaches are ever parsed.\n */\nexport class IpcFileReader {\n private readonly cache = new Map<string, IpcSourceFile | null>();\n\n constructor(readonly workspaceRoot: string) {}\n\n exists(relFile: string): boolean {\n return fs.existsSync(path.join(this.workspaceRoot, relFile));\n }\n\n /** The parsed file, cached for the rest of the run, or undefined when it does not exist. */\n read(relFile: string): IpcSourceFile | undefined {\n const cached = this.cache.get(relFile);\n if (cached !== undefined) return cached ?? undefined;\n const parsed = this.parse(relFile);\n this.cache.set(relFile, parsed ?? null);\n return parsed;\n }\n\n /**\n * The parsed file WITHOUT caching it — for a per-file rule walking many files, so each tree is garbage\n * as soon as it is judged and memory stays flat however many files the mode selects.\n */\n parse(relFile: string): IpcSourceFile | undefined {\n const absFile = path.join(this.workspaceRoot, relFile);\n if (!fs.existsSync(absFile)) return undefined;\n const text = fs.readFileSync(absFile, 'utf8');\n const kind = relFile.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;\n return new IpcSourceFile(relFile, ts.createSourceFile(absFile, text, ts.ScriptTarget.Latest, true, kind));\n }\n}\n\n/** A tsconfig host that answers file questions but NEVER lists a directory — no repo walk. */\nclass NoEnumerationHost implements ts.ParseConfigHost {\n readonly useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;\n\n readDirectory(): readonly string[] {\n return [];\n }\n\n fileExists(file: string): boolean {\n return ts.sys.fileExists(file);\n }\n\n readFile(file: string): string | undefined {\n return ts.sys.readFile(file);\n }\n}\n\n/** Reads a tsconfig's compiler options (following `extends`) without enumerating any source file. */\nexport class IpcCompilerOptionsReader {\n read(workspaceRoot: string, tsconfigPath: string): ts.CompilerOptions {\n const absConfig = path.join(workspaceRoot, tsconfigPath);\n if (!fs.existsSync(absConfig)) {\n throw new InformAiError(\n `IPC rules: tsconfigPath \"${tsconfigPath}\" does not exist under ${workspaceRoot}. ` +\n 'Point the rule\\'s \"tsconfigPath\" at the tsconfig whose \"paths\" resolve your imports.',\n );\n }\n const raw = ts.readConfigFile(absConfig, ts.sys.readFile);\n if (raw.error !== undefined) {\n throw new InformAiError(\n `IPC rules: cannot read ${tsconfigPath}: ${ts.flattenDiagnosticMessageText(raw.error.messageText, '\\n')}`,\n );\n }\n const parsed = ts.parseJsonConfigFileContent(raw.config, new NoEnumerationHost(), path.dirname(absConfig));\n return {\n ...parsed.options,\n noEmit: true,\n skipLibCheck: true,\n allowJs: false,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n jsx: ts.JsxEmit.ReactJSX,\n };\n }\n}\n\n/**\n * Resolves a module specifier written in a workspace file to the workspace file it names (relative\n * imports and tsconfig `paths` aliases alike), or undefined for a package or an unresolvable specifier.\n */\nexport class IpcModuleResolver {\n private readonly cache = new Map<string, string | null>();\n private readonly moduleCache: ts.ModuleResolutionCache;\n\n constructor(\n private readonly workspaceRoot: string,\n private readonly options: ts.CompilerOptions,\n ) {\n this.moduleCache = ts.createModuleResolutionCache(workspaceRoot, (name: string) => name, options);\n }\n\n resolve(fromRelFile: string, specifier: string): string | undefined {\n const key = `${path.posix.dirname(fromRelFile)}\\u0000${specifier}`;\n const cached = this.cache.get(key);\n if (cached !== undefined) return cached ?? undefined;\n const containing = path.join(this.workspaceRoot, fromRelFile);\n const result = ts.resolveModuleName(specifier, containing, this.options, ts.sys, this.moduleCache);\n const resolved = result.resolvedModule?.resolvedFileName;\n const rel = resolved === undefined ? undefined : this.workspaceRelative(resolved);\n this.cache.set(key, rel ?? null);\n return rel;\n }\n\n private workspaceRelative(absFile: string): string | undefined {\n const rel = path.relative(this.workspaceRoot, absFile).split(path.sep).join('/');\n if (rel.startsWith('..') || path.isAbsolute(rel) || rel.split('/').includes('node_modules')) return undefined;\n return rel;\n }\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
6
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
7
|
+
const scan_scope_1 = require("./scan-scope");
|
|
8
|
+
const ipc_protocol_recorder_1 = require("./ipc/ipc-protocol-recorder");
|
|
9
|
+
const ipc_rule_support_1 = require("./ipc/ipc-rule-support");
|
|
10
|
+
/**
|
|
11
|
+
* `wp-ipc-record-protocol` (#1389) — re-record the `ipc-protocol-fingerprint` manifest after an intentional
|
|
12
|
+
* wire change. It computes the snapshot exactly as the rule does (same config entry, same path
|
|
13
|
+
* exclusions) and writes `manifestPath`. Recording never waives the rule's branch-base check: a changed
|
|
14
|
+
* fingerprint still fails until the version constant is incremented past the base's protocol.
|
|
15
|
+
*/
|
|
16
|
+
(0, rules_config_1.runMain)(async () => {
|
|
17
|
+
new rules_config_1.CliArgs().assertNoArgs(new rules_config_1.CliUsage('wp-ipc-record-protocol', `Re-record the ${ipc_protocol_recorder_1.IPC_FINGERPRINT_RULE} manifest from the current IPC contract. Increment the version ` +
|
|
18
|
+
'constant first for a wire change; the branch-base comparison still requires it.'));
|
|
19
|
+
const workspaceRoot = new rules_config_1.RepoRootFinder().resolveRepoRoot(process.cwd());
|
|
20
|
+
const loaded = (0, rules_config_1.loadAndValidate)(workspaceRoot);
|
|
21
|
+
const config = loaded.rulesConfig[ipc_protocol_recorder_1.IPC_FINGERPRINT_RULE];
|
|
22
|
+
if (config === undefined) {
|
|
23
|
+
throw new tooling_common_1.InformAiError(`No "${ipc_protocol_recorder_1.IPC_FINGERPRINT_RULE}" entry is configured; add it to its code-rules owner file first.`);
|
|
24
|
+
}
|
|
25
|
+
const diffScope = new rules_config_1.DiffScope();
|
|
26
|
+
const support = new ipc_rule_support_1.IpcRuleSupport(diffScope, new scan_scope_1.ProjectCatalog(diffScope));
|
|
27
|
+
const recorder = new ipc_protocol_recorder_1.IpcProtocolRecorder(support);
|
|
28
|
+
const exclusions = new rules_config_1.RuleFileExclusions(ipc_protocol_recorder_1.IPC_FINGERPRINT_RULE, loaded.excludePaths.paths, config.excludePaths ?? []);
|
|
29
|
+
const snapshot = await new rules_config_1.RuleFileScope().runWithin(exclusions, () => recorder.current(workspaceRoot, config));
|
|
30
|
+
const written = recorder.record(workspaceRoot, config, snapshot);
|
|
31
|
+
process.stdout.write(`Recorded IPC contract fingerprint (protocol ${snapshot.protocol}) to ${written}; the branch-base comparison ` +
|
|
32
|
+
'still requires a protocol increment for a contract change.\n');
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=ipc-record-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipc-record-protocol.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/ipc-record-protocol.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,0DASiC;AACjC,8DAA0D;AAE1D,6CAA8C;AAC9C,uEAAwF;AACxF,6DAAwD;AAExD;;;;;GAKG;AACH,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,IAAI,sBAAO,EAAE,CAAC,YAAY,CACtB,IAAI,uBAAQ,CACR,wBAAwB,EACxB,iBAAiB,4CAAoB,iEAAiE;QAClG,iFAAiF,CACxF,CACJ,CAAC;IACF,MAAM,aAAa,GAAG,IAAI,6BAAc,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAG,IAAA,8BAAe,EAAC,aAAa,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,4CAAuD,CAE1E,CAAC;IAChB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,8BAAa,CAAC,OAAO,4CAAoB,mEAAmE,CAAC,CAAC;IAC5H,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,wBAAS,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,IAAI,iCAAc,CAAC,SAAS,EAAE,IAAI,2BAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7E,MAAM,QAAQ,GAAG,IAAI,2CAAmB,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,IAAI,iCAAkB,CAAC,4CAAoB,EAAE,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IACtH,MAAM,QAAQ,GAAG,MAAM,IAAI,4BAAa,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;IAChH,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjE,OAAO,CAAC,MAAM,CAAC,KAAK,CAChB,+CAA+C,QAAQ,CAAC,QAAQ,QAAQ,OAAO,+BAA+B;QAC1G,8DAA8D,CACrE,CAAC;AACN,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport {\n CliArgs,\n CliUsage,\n DiffScope,\n RepoRootFinder,\n RuleFileExclusions,\n RuleFileScope,\n loadAndValidate,\n runMain,\n} from '@webpieces/rules-config';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { IpcProtocolFingerprintConfig } from './configs/ipc-configs';\nimport { ProjectCatalog } from './scan-scope';\nimport { IPC_FINGERPRINT_RULE, IpcProtocolRecorder } from './ipc/ipc-protocol-recorder';\nimport { IpcRuleSupport } from './ipc/ipc-rule-support';\n\n/**\n * `wp-ipc-record-protocol` (#1389) — re-record the `ipc-protocol-fingerprint` manifest after an intentional\n * wire change. It computes the snapshot exactly as the rule does (same config entry, same path\n * exclusions) and writes `manifestPath`. Recording never waives the rule's branch-base check: a changed\n * fingerprint still fails until the version constant is incremented past the base's protocol.\n */\nrunMain(async (): Promise<void> => {\n new CliArgs().assertNoArgs(\n new CliUsage(\n 'wp-ipc-record-protocol',\n `Re-record the ${IPC_FINGERPRINT_RULE} manifest from the current IPC contract. Increment the version ` +\n 'constant first for a wire change; the branch-base comparison still requires it.',\n ),\n );\n const workspaceRoot = new RepoRootFinder().resolveRepoRoot(process.cwd());\n const loaded = loadAndValidate(workspaceRoot);\n const config = loaded.rulesConfig[IPC_FINGERPRINT_RULE as keyof typeof loaded.rulesConfig] as\n | IpcProtocolFingerprintConfig\n | undefined;\n if (config === undefined) {\n throw new InformAiError(`No \"${IPC_FINGERPRINT_RULE}\" entry is configured; add it to its code-rules owner file first.`);\n }\n const diffScope = new DiffScope();\n const support = new IpcRuleSupport(diffScope, new ProjectCatalog(diffScope));\n const recorder = new IpcProtocolRecorder(support);\n const exclusions = new RuleFileExclusions(IPC_FINGERPRINT_RULE, loaded.excludePaths.paths, config.excludePaths ?? []);\n const snapshot = await new RuleFileScope().runWithin(exclusions, () => recorder.current(workspaceRoot, config));\n const written = recorder.record(workspaceRoot, config, snapshot);\n process.stdout.write(\n `Recorded IPC contract fingerprint (protocol ${snapshot.protocol}) to ${written}; the branch-base comparison ` +\n 'still requires a protocol increment for a contract change.\\n',\n );\n});\n"]}
|
package/src/rule-help.js
CHANGED
|
@@ -33,5 +33,9 @@ exports.ruleHelp = {
|
|
|
33
33
|
'required-type-suffix': new rules_sdk_1.RuleHelp('Require configured suffixes on API contract types.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
34
34
|
'framework-tsconfig': new rules_sdk_1.RuleHelp('Align framework-specific TypeScript settings with project declarations.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
35
35
|
'framework-packages': new rules_sdk_1.RuleHelp('Align framework packages with the configured project requirements.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
36
|
+
'ipc-boundary': new rules_sdk_1.RuleHelp('Keep raw IPC, the ipc-bridge factories and WebView delivery inside the configured transport/composition/bootstrap modules.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
37
|
+
'ipc-contract-shape': new rules_sdk_1.RuleHelp('Require every shared IPC API to carry @WpInternal, @WpIpcEndpoint and @MaskLog with one named DTO and a Promise reply.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
38
|
+
'ipc-pairing': new rules_sdk_1.RuleHelp('Require a generated client at every IPC sender and exactly one receiver registration of a subclass of the same API.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
39
|
+
'ipc-protocol-fingerprint': new rules_sdk_1.RuleHelp('Require the recorded IPC protocol fingerprint to match the contract and a version increment for every wire change.', 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.'),
|
|
36
40
|
};
|
|
37
41
|
//# sourceMappingURL=rule-help.js.map
|
package/src/rule-help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-help.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-help.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAEhD,gEAAgE;AACnD,QAAA,QAAQ,GAAuC;IACxD,kBAAkB,EAAE,IAAI,oBAAQ,CAC5B,mDAAmD,EACnD,sIAAsI,CACzI;IACD,gBAAgB,EAAE,IAAI,oBAAQ,CAC1B,wDAAwD,EACxD,sIAAsI,CACzI;IACD,qBAAqB,EAAE,IAAI,oBAAQ,CAC/B,oDAAoD,EACpD,sIAAsI,CACzI;IACD,yBAAyB,EAAE,IAAI,oBAAQ,CACnC,oEAAoE,EACpE,sIAAsI,CACzI;IACD,gBAAgB,EAAE,IAAI,oBAAQ,CAC1B,wEAAwE,EACxE,sIAAsI,CACzI;IACD,iBAAiB,EAAE,IAAI,oBAAQ,CAC3B,0EAA0E,EAC1E,sIAAsI,CACzI;IACD,sBAAsB,EAAE,IAAI,oBAAQ,CAChC,sEAAsE,EACtE,sIAAsI,CACzI;IACD,kBAAkB,EAAE,IAAI,oBAAQ,CAC5B,qEAAqE,EACrE,sIAAsI,CACzI;IACD,gBAAgB,EAAE,IAAI,oBAAQ,CAC1B,wEAAwE,EACxE,sIAAsI,CACzI;IACD,qBAAqB,EAAE,IAAI,oBAAQ,CAC/B,mEAAmE,EACnE,sIAAsI,CACzI;IACD,yBAAyB,EAAE,IAAI,oBAAQ,CACnC,uEAAuE,EACvE,sIAAsI,CACzI;IACD,mCAAmC,EAAE,IAAI,oBAAQ,CAC7C,+DAA+D,EAC/D,sIAAsI,CACzI;IACD,sBAAsB,EAAE,IAAI,oBAAQ,CAChC,wGAAwG,EACxG,sIAAsI,CACzI;IACD,qBAAqB,EAAE,IAAI,oBAAQ,CAC/B,qEAAqE,EACrE,sIAAsI,CACzI;IACD,6CAA6C,EAAE,IAAI,oBAAQ,CACvD,wEAAwE,EACxE,sIAAsI,CACzI;IACD,eAAe,EAAE,IAAI,oBAAQ,CACzB,4EAA4E,EAC5E,sIAAsI,CACzI;IACD,6BAA6B,EAAE,IAAI,oBAAQ,CACvC,kEAAkE,EAClE,sIAAsI,CACzI;IACD,8BAA8B,EAAE,IAAI,oBAAQ,CACxC,oEAAoE,EACpE,sIAAsI,CACzI;IACD,2BAA2B,EAAE,IAAI,oBAAQ,CACrC,yDAAyD,EACzD,sIAAsI,CACzI;IACD,iDAAiD,EAAE,IAAI,oBAAQ,CAC3D,6EAA6E,EAC7E,sIAAsI,CACzI;IACD,eAAe,EAAE,IAAI,oBAAQ,CACzB,sEAAsE,EACtE,sIAAsI,CACzI;IACD,UAAU,EAAE,IAAI,oBAAQ,CACpB,kFAAkF,EAClF,sIAAsI,CACzI;IACD,sBAAsB,EAAE,IAAI,oBAAQ,CAChC,8IAA8I,EAC9I,sIAAsI,CACzI;IACD,6BAA6B,EAAE,IAAI,oBAAQ,CACvC,mDAAmD,EACnD,sIAAsI,CACzI;IACD,8BAA8B,EAAE,IAAI,oBAAQ,CACxC,qDAAqD,EACrD,sIAAsI,CACzI;IACD,6BAA6B,EAAE,IAAI,oBAAQ,CACvC,iEAAiE,EACjE,sIAAsI,CACzI;IACD,sBAAsB,EAAE,IAAI,oBAAQ,CAChC,oDAAoD,EACpD,sIAAsI,CACzI;IACD,oBAAoB,EAAE,IAAI,oBAAQ,CAC9B,yEAAyE,EACzE,sIAAsI,CACzI;IACD,oBAAoB,EAAE,IAAI,oBAAQ,CAC9B,oEAAoE,EACpE,sIAAsI,CACzI;CACJ,CAAC","sourcesContent":["import { RuleHelp } from '@webpieces/rules-sdk';\n\n/** Owner-authored guidance consumed by the registry catalog. */\nexport const ruleHelp: Readonly<Record<string, RuleHelp>> = {\n 'max-method-lines': new RuleHelp(\n 'Limit method length in the configured scan scope.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'max-file-lines': new RuleHelp(\n 'Limit source file length in the configured scan scope.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'require-return-type': new RuleHelp(\n 'Require explicit function and method return types.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-inline-type-literals': new RuleHelp(\n 'Use named data classes instead of inline object type declarations.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-any-unknown': new RuleHelp(\n 'Require concrete types outside explicitly permitted opaque boundaries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-implicit-any': new RuleHelp(\n 'Require explicit parameter types when inference does not establish them.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'prisma-validate-dtos': new RuleHelp(\n 'Validate Prisma-facing DTO declarations against the generated model.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'prisma-converter': new RuleHelp(\n 'Validate the converters between Prisma models and application DTOs.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-destructure': new RuleHelp(\n 'Use whole values or explicit property access instead of destructuring.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'catch-error-pattern': new RuleHelp(\n 'Narrow caught errors through the shared error conversion pattern.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-unmanaged-exceptions': new RuleHelp(\n 'Handle or explicitly document exceptions at the responsible boundary.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'angular-no-direct-api-in-resolver': new RuleHelp(\n 'Keep direct API client construction out of Angular resolvers.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'catch-must-propagate': new RuleHelp(\n 'Require a caught error to propagate whole: rethrown, thrown as a cause, forwarded, returned or stored.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-symbol-di-tokens': new RuleHelp(\n 'Use class tokens for dependency injection instead of symbol tokens.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-client-creation-outside-server-or-client': new RuleHelp(\n 'Construct API clients only in their designated server or client layer.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-custom-css': new RuleHelp(\n 'Use the configured styling system instead of custom CSS in governed files.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-state-paths-in-templates': new RuleHelp(\n 'Use the declared state binding pattern in application templates.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-process-exit-outside-main': new RuleHelp(\n 'Restrict process termination to executable application boundaries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-function-outside-class': new RuleHelp(\n 'Put business operations in instance methods on classes.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'inject-annotation-not-needed-for-concrete-class': new RuleHelp(\n 'Inject concrete classes by their class token without redundant annotations.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'framework-tag': new RuleHelp(\n 'Match project framework tags to their actual code and package usage.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'role-tag': new RuleHelp(\n 'Match project role tags to their actual API and implementation responsibilities.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'ensure-we-are-secure': new RuleHelp(\n 'Audit canonical WpAuth credential alternatives and WpAuthorization operation policies on every HTTP endpoint; audit explicit IPC boundaries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-inline-import-in-api-lib': new RuleHelp(\n 'Keep API library type imports explicit and named.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'one-enum-spelling-in-api-lib': new RuleHelp(\n 'Use one enum declaration spelling in API libraries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-utility-types-in-api-lib': new RuleHelp(\n 'Use explicit named API data contracts instead of utility types.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'required-type-suffix': new RuleHelp(\n 'Require configured suffixes on API contract types.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'framework-tsconfig': new RuleHelp(\n 'Align framework-specific TypeScript settings with project declarations.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'framework-packages': new RuleHelp(\n 'Align framework packages with the configured project requirements.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n};\n"]}
|
|
1
|
+
{"version":3,"file":"rule-help.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/rule-help.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAEhD,gEAAgE;AACnD,QAAA,QAAQ,GAAuC;IACxD,kBAAkB,EAAE,IAAI,oBAAQ,CAC5B,mDAAmD,EACnD,sIAAsI,CACzI;IACD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AsI,CACzI;IACD,iDAAiD,EAAE,IAAI,oBAAQ,CAC3D,6EAA6E,EAC7E,sIAAsI,CACzI;IACD,eAAe,EAAE,IAAI,oBAAQ,CACzB,sEAAsE,EACtE,sIAAsI,CACzI;IACD,UAAU,EAAE,IAAI,oBAAQ,CACpB,kFAAkF,EAClF,sIAAsI,CACzI;IACD,sBAAsB,EAAE,IAAI,oBAAQ,CAChC,8IAA8I,EAC9I,sIAAsI,CACzI;IACD,6BAA6B,EAAE,IAAI,oBAAQ,CACvC,mDAAmD,EACnD,sIAAsI,CACzI;IACD,8BAA8B,EAAE,IAAI,oBAAQ,CACxC,qDAAqD,EACrD,sIAAsI,CACzI;IACD,6BAA6B,EAAE,IAAI,oBAAQ,CACvC,iEAAiE,EACjE,sIAAsI,CACzI;IACD,sBAAsB,EAAE,IAAI,oBAAQ,CAChC,oDAAoD,EACpD,sIAAsI,CACzI;IACD,oBAAoB,EAAE,IAAI,oBAAQ,CAC9B,yEAAyE,EACzE,sIAAsI,CACzI;IACD,oBAAoB,EAAE,IAAI,oBAAQ,CAC9B,oEAAoE,EACpE,sIAAsI,CACzI;IACD,cAAc,EAAE,IAAI,oBAAQ,CACxB,4HAA4H,EAC5H,sIAAsI,CACzI;IACD,oBAAoB,EAAE,IAAI,oBAAQ,CAC9B,wHAAwH,EACxH,sIAAsI,CACzI;IACD,aAAa,EAAE,IAAI,oBAAQ,CACvB,qHAAqH,EACrH,sIAAsI,CACzI;IACD,0BAA0B,EAAE,IAAI,oBAAQ,CACpC,oHAAoH,EACpH,sIAAsI,CACzI;CACJ,CAAC","sourcesContent":["import { RuleHelp } from '@webpieces/rules-sdk';\n\n/** Owner-authored guidance consumed by the registry catalog. */\nexport const ruleHelp: Readonly<Record<string, RuleHelp>> = {\n 'max-method-lines': new RuleHelp(\n 'Limit method length in the configured scan scope.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'max-file-lines': new RuleHelp(\n 'Limit source file length in the configured scan scope.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'require-return-type': new RuleHelp(\n 'Require explicit function and method return types.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-inline-type-literals': new RuleHelp(\n 'Use named data classes instead of inline object type declarations.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-any-unknown': new RuleHelp(\n 'Require concrete types outside explicitly permitted opaque boundaries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-implicit-any': new RuleHelp(\n 'Require explicit parameter types when inference does not establish them.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'prisma-validate-dtos': new RuleHelp(\n 'Validate Prisma-facing DTO declarations against the generated model.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'prisma-converter': new RuleHelp(\n 'Validate the converters between Prisma models and application DTOs.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-destructure': new RuleHelp(\n 'Use whole values or explicit property access instead of destructuring.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'catch-error-pattern': new RuleHelp(\n 'Narrow caught errors through the shared error conversion pattern.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-unmanaged-exceptions': new RuleHelp(\n 'Handle or explicitly document exceptions at the responsible boundary.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'angular-no-direct-api-in-resolver': new RuleHelp(\n 'Keep direct API client construction out of Angular resolvers.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'catch-must-propagate': new RuleHelp(\n 'Require a caught error to propagate whole: rethrown, thrown as a cause, forwarded, returned or stored.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-symbol-di-tokens': new RuleHelp(\n 'Use class tokens for dependency injection instead of symbol tokens.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-client-creation-outside-server-or-client': new RuleHelp(\n 'Construct API clients only in their designated server or client layer.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-custom-css': new RuleHelp(\n 'Use the configured styling system instead of custom CSS in governed files.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-state-paths-in-templates': new RuleHelp(\n 'Use the declared state binding pattern in application templates.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-process-exit-outside-main': new RuleHelp(\n 'Restrict process termination to executable application boundaries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-function-outside-class': new RuleHelp(\n 'Put business operations in instance methods on classes.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'inject-annotation-not-needed-for-concrete-class': new RuleHelp(\n 'Inject concrete classes by their class token without redundant annotations.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'framework-tag': new RuleHelp(\n 'Match project framework tags to their actual code and package usage.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'role-tag': new RuleHelp(\n 'Match project role tags to their actual API and implementation responsibilities.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'ensure-we-are-secure': new RuleHelp(\n 'Audit canonical WpAuth credential alternatives and WpAuthorization operation policies on every HTTP endpoint; audit explicit IPC boundaries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-inline-import-in-api-lib': new RuleHelp(\n 'Keep API library type imports explicit and named.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'one-enum-spelling-in-api-lib': new RuleHelp(\n 'Use one enum declaration spelling in API libraries.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'no-utility-types-in-api-lib': new RuleHelp(\n 'Use explicit named API data contracts instead of utility types.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'required-type-suffix': new RuleHelp(\n 'Require configured suffixes on API contract types.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'framework-tsconfig': new RuleHelp(\n 'Align framework-specific TypeScript settings with project declarations.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'framework-packages': new RuleHelp(\n 'Align framework packages with the configured project requirements.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'ipc-boundary': new RuleHelp(\n 'Keep raw IPC, the ipc-bridge factories and WebView delivery inside the configured transport/composition/bootstrap modules.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'ipc-contract-shape': new RuleHelp(\n 'Require every shared IPC API to carry @WpInternal, @WpIpcEndpoint and @MaskLog with one named DTO and a Promise reply.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'ipc-pairing': new RuleHelp(\n 'Require a generated client at every IPC sender and exactly one receiver registration of a subclass of the same API.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n 'ipc-protocol-fingerprint': new RuleHelp(\n 'Require the recorded IPC protocol fingerprint to match the contract and a version increment for every wire change.',\n 'Apply this policy in source, or review its explicit settings in {configFile}. An intentional opt-out requires complete OFF settings.',\n ),\n};\n"]}
|
package/src/rule-settings.js
CHANGED
|
@@ -59,7 +59,11 @@ exports.optionalTuning = {
|
|
|
59
59
|
"no-utility-types-in-api-lib": {},
|
|
60
60
|
"required-type-suffix": {},
|
|
61
61
|
"framework-tsconfig": {},
|
|
62
|
-
"framework-packages": {}
|
|
62
|
+
"framework-packages": {},
|
|
63
|
+
"ipc-boundary": {},
|
|
64
|
+
"ipc-contract-shape": {},
|
|
65
|
+
"ipc-pairing": {},
|
|
66
|
+
"ipc-protocol-fingerprint": {}
|
|
63
67
|
};
|
|
64
68
|
/** Written for review by setup/sync; never used as a loader fallback. */
|
|
65
69
|
exports.recommendedSeeds = {
|
|
@@ -282,6 +286,120 @@ exports.recommendedSeeds = {
|
|
|
282
286
|
]
|
|
283
287
|
}
|
|
284
288
|
]
|
|
289
|
+
},
|
|
290
|
+
"ipc-boundary": {
|
|
291
|
+
"mode": "NEW_AND_MODIFIED_FILES",
|
|
292
|
+
"turnOffRuleUntilEpoch": 0,
|
|
293
|
+
"turnOffRuleWhileOnBranch": null,
|
|
294
|
+
"tsconfigPath": "tsconfig.base.json",
|
|
295
|
+
"transportFiles": [
|
|
296
|
+
"apps/website/src/app/native/shell-transport.ts",
|
|
297
|
+
"apps/shell/src/bridge/shell-transport.ts"
|
|
298
|
+
],
|
|
299
|
+
"compositionFiles": [
|
|
300
|
+
"apps/website/src/app/native/provide-native.ts",
|
|
301
|
+
"apps/website/src/app/native/website-endpoints.ts",
|
|
302
|
+
"apps/shell/src/bridge/native-endpoints.ts"
|
|
303
|
+
],
|
|
304
|
+
"bootstrapFiles": [
|
|
305
|
+
"apps/website/src/app/native/shell-bootstrap.ts",
|
|
306
|
+
"apps/shell/src/bridge/native-bootstrap.ts"
|
|
307
|
+
],
|
|
308
|
+
"testOnlyModuleSuffixes": [
|
|
309
|
+
".spec-support"
|
|
310
|
+
],
|
|
311
|
+
"retiredModules": [],
|
|
312
|
+
"retiredIdentifiers": [],
|
|
313
|
+
"forbiddenClassNamePatterns": [
|
|
314
|
+
"To(Native|Website)Impl$"
|
|
315
|
+
],
|
|
316
|
+
"legacyWireFile": null,
|
|
317
|
+
"bootstrapAllowedLegacyNames": [],
|
|
318
|
+
"legacyWireCommandPrefixes": []
|
|
319
|
+
},
|
|
320
|
+
"ipc-contract-shape": {
|
|
321
|
+
"mode": "NEW_AND_MODIFIED_FILES",
|
|
322
|
+
"turnOffRuleUntilEpoch": 0,
|
|
323
|
+
"turnOffRuleWhileOnBranch": null,
|
|
324
|
+
"tsconfigPath": "tsconfig.base.json",
|
|
325
|
+
"contractPaths": [
|
|
326
|
+
"libraries/apis/shell-api/src/**"
|
|
327
|
+
],
|
|
328
|
+
"apiClassSuffixes": [
|
|
329
|
+
"ToNativeApi",
|
|
330
|
+
"ToWebsiteApi"
|
|
331
|
+
],
|
|
332
|
+
"requiredProjectTags": [
|
|
333
|
+
"api:ipc-contract",
|
|
334
|
+
"framework:browser",
|
|
335
|
+
"framework:node"
|
|
336
|
+
],
|
|
337
|
+
"forbiddenImportModules": [
|
|
338
|
+
"@angular/*",
|
|
339
|
+
"react",
|
|
340
|
+
"react-native",
|
|
341
|
+
"expo*",
|
|
342
|
+
"@webpieces/ipc-bridge"
|
|
343
|
+
],
|
|
344
|
+
"forbiddenImportPaths": [
|
|
345
|
+
"apps/**"
|
|
346
|
+
]
|
|
347
|
+
},
|
|
348
|
+
"ipc-pairing": {
|
|
349
|
+
"mode": "MODIFIED_PROJECTS",
|
|
350
|
+
"turnOffRuleUntilEpoch": 0,
|
|
351
|
+
"turnOffRuleWhileOnBranch": null,
|
|
352
|
+
"tsconfigPath": "tsconfig.base.json",
|
|
353
|
+
"contractPaths": [
|
|
354
|
+
"libraries/apis/shell-api/src/**"
|
|
355
|
+
],
|
|
356
|
+
"directions": [
|
|
357
|
+
{
|
|
358
|
+
"apiSuffix": "ToNativeApi",
|
|
359
|
+
"wireDirection": "native",
|
|
360
|
+
"senderFiles": [
|
|
361
|
+
"apps/website/src/app/native/**"
|
|
362
|
+
],
|
|
363
|
+
"receiverFiles": [
|
|
364
|
+
"apps/shell/src/bridge/native-endpoints.ts"
|
|
365
|
+
]
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"apiSuffix": "ToWebsiteApi",
|
|
369
|
+
"wireDirection": "website",
|
|
370
|
+
"senderFiles": [
|
|
371
|
+
"apps/shell/src/bridge/**"
|
|
372
|
+
],
|
|
373
|
+
"receiverFiles": [
|
|
374
|
+
"apps/website/src/app/native/website-endpoints.ts"
|
|
375
|
+
]
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
"wireTableFile": null,
|
|
379
|
+
"wireTableExport": null,
|
|
380
|
+
"forbiddenDispatchVariables": []
|
|
381
|
+
},
|
|
382
|
+
"ipc-protocol-fingerprint": {
|
|
383
|
+
"mode": "MODIFIED_PROJECTS",
|
|
384
|
+
"turnOffRuleUntilEpoch": 0,
|
|
385
|
+
"turnOffRuleWhileOnBranch": null,
|
|
386
|
+
"tsconfigPath": "tsconfig.base.json",
|
|
387
|
+
"contractPaths": [
|
|
388
|
+
"libraries/apis/shell-api/src/**"
|
|
389
|
+
],
|
|
390
|
+
"apiClassSuffixes": [
|
|
391
|
+
"ToNativeApi",
|
|
392
|
+
"ToWebsiteApi"
|
|
393
|
+
],
|
|
394
|
+
"wireTableFile": null,
|
|
395
|
+
"wireTableExport": null,
|
|
396
|
+
"normalizedSourceFiles": [
|
|
397
|
+
"libraries/apis/shell-api/src/*Api.ts"
|
|
398
|
+
],
|
|
399
|
+
"manifestPath": "libraries/apis/shell-api/protocol-manifest.json",
|
|
400
|
+
"versionFile": "libraries/apis/shell-api/src/bridge-protocol.ts",
|
|
401
|
+
"versionConstant": "BRIDGE_PROTOCOL_VERSION",
|
|
402
|
+
"withoutBaseline": "FAIL"
|
|
285
403
|
}
|
|
286
404
|
};
|
|
287
405
|
//# sourceMappingURL=rule-settings.js.map
|