@starci/eslint-canon-fe 9.8.5 → 9.9.2
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 +24 -3
- package/README.md +2 -4
- package/dist/button-intent.d.ts +0 -1
- package/dist/button-intent.js +1 -16
- package/dist/file-layout.js +2 -1
- package/dist/index.js +2 -0
- package/dist/lib/config.js +3 -2
- package/dist/lib/scope.d.ts +1 -1
- package/dist/lib/scope.js +1 -1
- package/dist/lib/why.d.ts +20 -5
- package/dist/lib/why.js +26 -11
- package/dist/loading.js +1 -1
- package/dist/props-and-slots.d.ts +6 -0
- package/dist/props-and-slots.js +41 -0
- package/dist/shape-slot.js +6 -6
- package/dist/skeleton-states.d.ts +16 -0
- package/dist/skeleton-states.js +230 -0
- package/dist/surface-rules.d.ts +2 -5
- package/dist/surface-rules.js +28 -121
- package/dist/ui-rulings.js +1 -1
- package/docs/button-intent.md +0 -1
- package/docs/size-and-state-budget.md +1 -1
- package/docs/surface-rules.md +17 -32
- package/package.json +1 -1
- package/runtime/bundle.json +4 -0
- package/runtime/knowledge/hfs/canon-pins.yaml +7 -7
- package/runtime/knowledge/hfs/slots.yaml +5 -5
- package/runtime/knowledge/patterns/fe/folder.yaml +1 -1
- package/runtime/scripts/hfs/architecture/clones.mjs +12 -2
- package/runtime/scripts/hfs/architecture/component-tiers.mjs +161 -0
- package/runtime/scripts/hfs/architecture/config.mjs +1 -1
- package/runtime/scripts/hfs/architecture/frontend-world.mjs +1 -1
- package/runtime/scripts/hfs/architecture/frontend.mjs +2 -2
- package/runtime/scripts/hfs/architecture/index.mjs +6 -0
- package/runtime/scripts/hfs/architecture/render-graph.mjs +449 -0
- package/runtime/scripts/hfs/architecture/render-prop-across-server.mjs +58 -0
- package/runtime/scripts/hfs/architecture/surface-nesting.mjs +127 -0
- package/runtime/scripts/hfs/architecture/unit-spec-providers.mjs +12 -5
- package/runtime/scripts/hfs/slot-manifest-shape.mjs +16 -1
|
@@ -9,7 +9,8 @@ import { checkFunctionSubject, functionSubjectExports, keyOf as literalKey, valu
|
|
|
9
9
|
/**
|
|
10
10
|
* R48 `unit-spec-providers` (BE_SPEC_QUALITY), the unit test standard's rule 3: the unit spec of a service builds its
|
|
11
11
|
* subject with `Test.createTestingModule({ providers: [...] })`, and that providers array EQUALS the constructor
|
|
12
|
-
* dependencies of the service under test: the service class first, then one provider for each constructor parameter.
|
|
12
|
+
* dependencies of the service under test: the service class first, then one provider for each required constructor parameter.
|
|
13
|
+
* A parameter decorated by `Optional()` imported from `@nestjs/common` may be omitted to exercise its absent-provider branch.
|
|
13
14
|
*
|
|
14
15
|
* The service under test is the sibling `<name>.service.ts` of every `<name>.service.spec.ts` under src/ or apps/ (a spec is
|
|
15
16
|
* outside the production program, so it is read from disk). A parameter decorated with a custom `Inject<Thing>()` provides
|
|
@@ -80,6 +81,7 @@ function serviceClassFor(ts, rel, serviceRel, serviceFile, imports, list, report
|
|
|
80
81
|
}
|
|
81
82
|
function checkDependencies(kit, rel, service, serviceFile, list, provided, report) {
|
|
82
83
|
const { serviceName, serviceClass } = service;
|
|
84
|
+
const checker = kit.checkerOf(serviceFile.sourceFile);
|
|
83
85
|
const dependencies = constructorDependencies(kit, serviceFile, serviceClass);
|
|
84
86
|
const expected = [];
|
|
85
87
|
for (const dependency of dependencies) {
|
|
@@ -87,18 +89,23 @@ function checkDependencies(kit, rel, service, serviceFile, list, provided, repor
|
|
|
87
89
|
report(list, `${rel}: a constructor dependency of ${serviceName.name} cannot be resolved to a token (${dependency.reason}), so its provider cannot be checked; inject it through an exported Inject<Thing>() decorator or a class type.`);
|
|
88
90
|
continue;
|
|
89
91
|
}
|
|
90
|
-
|
|
92
|
+
const optional = kit.decorators(dependency.parameter).some(decorator => {
|
|
93
|
+
const expression = decorator.expression;
|
|
94
|
+
return kit.ts.isCallExpression(expression) && expression.arguments.length === 0
|
|
95
|
+
&& kit.isImportOf(checker, expression.expression, 'Optional', '@nestjs/common');
|
|
96
|
+
});
|
|
97
|
+
expected.push({ name: dependency.name, optional });
|
|
91
98
|
}
|
|
92
99
|
const remaining = [...expected];
|
|
93
100
|
for (const item of provided.slice(1)) {
|
|
94
|
-
const index = remaining.
|
|
101
|
+
const index = remaining.findIndex(dependency => dependency.name === item.name);
|
|
95
102
|
if (index === -1)
|
|
96
103
|
report(item.node, `${rel}: ${item.name} is provided but is not a constructor dependency of ${serviceName.name}; a unit spec provides exactly what the constructor needs.`);
|
|
97
104
|
else
|
|
98
105
|
remaining.splice(index, 1);
|
|
99
106
|
}
|
|
100
|
-
for (const
|
|
101
|
-
report(list, `${rel}: ${name} is a constructor dependency of ${serviceName.name} but is not provided; add \`{ provide: ${name}, useValue: double }\` (or the class itself) to the providers.`);
|
|
107
|
+
for (const dependency of remaining.filter(item => !item.optional))
|
|
108
|
+
report(list, `${rel}: ${dependency.name} is a constructor dependency of ${serviceName.name} but is not provided; add \`{ provide: ${dependency.name}, useValue: double }\` (or the class itself) to the providers.`);
|
|
102
109
|
}
|
|
103
110
|
function checkTestingModule({ ts, kit, rel, serviceRel, serviceFile, imports, call, report }) {
|
|
104
111
|
const list = providerList(ts, call, rel, report);
|
|
@@ -49,13 +49,27 @@ function checkProfileMaps(m, bad) {
|
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
51
51
|
for (const extra of Object.keys(m[key]))
|
|
52
|
-
if (!isSide(extra))
|
|
52
|
+
if (!isSide(extra) && !(key === 'tiers' && extra === COMPONENT_LIBRARY))
|
|
53
53
|
bad.push(`${key}.${extra} is not a profile`);
|
|
54
54
|
for (const profile of PROFILES)
|
|
55
55
|
if (!(profile in m[key]))
|
|
56
56
|
bad.push(`${key}.${profile} is missing`);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
/** The tier matrix of a component library (packages/grammar), beside the be and fe profiles: tiers.grammar. */
|
|
60
|
+
const COMPONENT_LIBRARY = 'grammar';
|
|
61
|
+
function checkComponentLibraryTiers(m, bad) {
|
|
62
|
+
const tiers = m.tiers?.[COMPONENT_LIBRARY];
|
|
63
|
+
if (tiers === undefined)
|
|
64
|
+
return;
|
|
65
|
+
bad.push(...tierMapProblems(COMPONENT_LIBRARY, tiers));
|
|
66
|
+
if (!isPlainObject(tiers))
|
|
67
|
+
return;
|
|
68
|
+
for (const [tier, def] of Object.entries(tiers))
|
|
69
|
+
for (const target of def?.mayImport ?? [])
|
|
70
|
+
if (!(target in tiers))
|
|
71
|
+
bad.push(`tiers.${COMPONENT_LIBRARY}.${tier}.mayImport names ${target}, which is not a ${COMPONENT_LIBRARY} tier`);
|
|
72
|
+
}
|
|
59
73
|
function checkAppKindAndTierShapes(m, bad) {
|
|
60
74
|
for (const profile of PROFILES) {
|
|
61
75
|
const kinds = m.appKinds?.[profile];
|
|
@@ -66,6 +80,7 @@ function checkAppKindAndTierShapes(m, bad) {
|
|
|
66
80
|
continue;
|
|
67
81
|
bad.push(...tierMapProblems(profile, tiers));
|
|
68
82
|
}
|
|
83
|
+
checkComponentLibraryTiers(m, bad);
|
|
69
84
|
}
|
|
70
85
|
function checkSlotShapes(m, bad) {
|
|
71
86
|
if (!Array.isArray(m.slots) || !m.slots.length) {
|