@fabrika/check 0.9.0-dev.21 → 0.9.0-dev.23
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 +6 -6
- package/src/check.ts +15 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/check",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@babel/parser": "8.0.7",
|
|
50
|
-
"@fabrika/app": "0.9.0-dev.
|
|
51
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
52
|
-
"@fabrika/db": "0.9.0-dev.
|
|
53
|
-
"@fabrika/operations-contract": "0.9.0-dev.
|
|
54
|
-
"@fabrika/platform-node": "0.9.0-dev.
|
|
50
|
+
"@fabrika/app": "0.9.0-dev.23",
|
|
51
|
+
"@fabrika/auth-core": "0.9.0-dev.23",
|
|
52
|
+
"@fabrika/db": "0.9.0-dev.23",
|
|
53
|
+
"@fabrika/operations-contract": "0.9.0-dev.23",
|
|
54
|
+
"@fabrika/platform-node": "0.9.0-dev.23",
|
|
55
55
|
"zod": "^3.25.76"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/src/check.ts
CHANGED
|
@@ -114,27 +114,34 @@ interface ContractDependent {
|
|
|
114
114
|
readonly inserts: ConflictInsert[]
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Whether `type-assertion`, `any-type` and `suppression-comment` (how a module's own source is written) apply: not to
|
|
119
|
+
* a generated module, nor to a test file, which never ships and which `test-only-import` keeps out of shipped code.
|
|
120
|
+
*/
|
|
121
|
+
const isHeldToWriting = (file: string, generated: boolean): boolean => !generated && !isTestFile(file)
|
|
122
|
+
|
|
117
123
|
/**
|
|
118
124
|
* A module under `tools/` runs on a developer's machine, never in the application: it is held to how its source is
|
|
119
|
-
* written (`type-assertion`, `any-type
|
|
120
|
-
* module` of a trusted package and the rules of its tests. Every other module rule guards code that runs in the
|
|
125
|
+
* written (`type-assertion`, `any-type` and `suppression-comment` outside its tests; `capability-widening`), `key-literal`,
|
|
126
|
+
* a `declare module` of a trusted package and the rules of its tests. Every other module rule guards code that runs in the
|
|
121
127
|
* application.
|
|
122
128
|
*/
|
|
123
129
|
const checkToolModule = (module: ParsedModule, generated: boolean, findings: Finding[]): void => {
|
|
124
130
|
const report = reporter(module.file, findings)
|
|
125
131
|
const isTest = isTestFile(module.file)
|
|
132
|
+
const writing = isHeldToWriting(module.file, generated)
|
|
126
133
|
walk(module.program, (node, ancestors) => {
|
|
127
134
|
checkKeyLiteralNode(node, report)
|
|
128
|
-
if (
|
|
135
|
+
if (writing) checkTypeNode(node, report)
|
|
129
136
|
checkCapabilityNode(node, report)
|
|
130
137
|
checkAmbientModule(node, report)
|
|
131
138
|
if (isTest) checkTestNode(node, ancestors, report)
|
|
132
139
|
checkMockModule(node, report)
|
|
133
140
|
})
|
|
134
|
-
if (
|
|
141
|
+
if (writing) checkComments(module.comments, report)
|
|
135
142
|
}
|
|
136
143
|
|
|
137
|
-
/** A generated module (`isGeneratedModule`) is not held to `type-assertion`, `any-type`, `suppression-comment` and the hints. */
|
|
144
|
+
/** A generated module (`isGeneratedModule`) is not held to `type-assertion`, `any-type`, `suppression-comment` and the hints; a test file not to the first three. */
|
|
138
145
|
const checkSourceModule = (
|
|
139
146
|
module: ParsedModule,
|
|
140
147
|
generated: boolean,
|
|
@@ -148,6 +155,7 @@ const checkSourceModule = (
|
|
|
148
155
|
const report = reporter(module.file, findings)
|
|
149
156
|
const isGeneratedEntry = module.file === GENERATED_ENTRY_FILE
|
|
150
157
|
const isTest = isTestFile(module.file)
|
|
158
|
+
const writing = isHeldToWriting(module.file, generated)
|
|
151
159
|
const deferred = (at: AstNode, rule: 'cross-app-fetch' | 'url-endpoint' | 'on-conflict-index', message: string, allowed: string): Finding[] => {
|
|
152
160
|
const found: Finding[] = []
|
|
153
161
|
reporter(module.file, found)(at, rule, message, allowed)
|
|
@@ -177,14 +185,14 @@ const checkSourceModule = (
|
|
|
177
185
|
walk(module.program, (node, ancestors) => {
|
|
178
186
|
checkRuntimeNode(node, ancestors, context)
|
|
179
187
|
checkFrameworkWrite(node, ancestors, trusted, report)
|
|
180
|
-
if (
|
|
188
|
+
if (writing) checkTypeNode(node, report)
|
|
181
189
|
checkCapabilityNode(node, report)
|
|
182
190
|
checkAmbientModule(node, report)
|
|
183
191
|
if (isTest) checkTestNode(node, ancestors, report)
|
|
184
192
|
checkMockModule(node, report)
|
|
185
193
|
checkStructureNode(place, node, report)
|
|
186
194
|
})
|
|
187
|
-
if (
|
|
195
|
+
if (writing) checkComments(module.comments, report)
|
|
188
196
|
checkModuleReferences(module.file, references, mappings, exists, report, isGeneratedEntry, isTest)
|
|
189
197
|
}
|
|
190
198
|
|