@yahoo/uds-create-config 5.108.2 → 5.108.3
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/dist/__fixtures__/yos-native.d.ts +5 -0
- package/dist/configs/react-native-system.d.ts +5 -0
- package/dist/configs/react-native-system.js +2 -0
- package/dist/configs/system.js +2 -0
- package/dist/entities/native/NativeSettings.d.ts +5 -0
- package/dist/entities/system/Settings.d.ts +10 -0
- package/dist/entities/system/Settings.js +13 -0
- package/dist/framework/Config.d.ts +1 -1
- package/dist/framework/Config.js +1 -1
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/lint/catalog.d.ts +40 -0
- package/dist/lint/catalog.js +50 -0
- package/dist/lint/edits.d.ts +27 -3
- package/dist/lint/edits.js +40 -1
- package/dist/lint/index.d.ts +4 -3
- package/dist/lint/index.js +3 -2
- package/dist/lint/lint.d.ts +1 -1
- package/dist/lint/lint.js +11 -5
- package/dist/lint/rules.d.ts +7 -7
- package/dist/lint/rules.js +6 -6
- package/dist/migrations/20261118171253_lint_names_removed.d.ts +4 -0
- package/dist/migrations/20261118171253_lint_names_removed.js +10 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -68,6 +68,11 @@ export declare function yosNative(): import("..").ConfigInstance<{
|
|
|
68
68
|
when: import("zod").ZodOptional<import("zod").ZodString>;
|
|
69
69
|
reason: import("zod").ZodString;
|
|
70
70
|
}, import("zod/v4/core").$strict>>>;
|
|
71
|
+
names: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
72
|
+
label: import("zod").ZodOptional<import("zod").ZodString>;
|
|
73
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
74
|
+
}, import("zod/v4/core").$strict>>>;
|
|
75
|
+
removed: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
71
76
|
}, import("zod/v4/core").$strict>>;
|
|
72
77
|
defaults: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
73
78
|
background: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -86,6 +86,11 @@ declare const ReactNativeSystemDefinition: ConfigClass<{
|
|
|
86
86
|
when: _$zod.ZodOptional<_$zod.ZodString>;
|
|
87
87
|
reason: _$zod.ZodString;
|
|
88
88
|
}, _$zod_v4_core0.$strict>>>;
|
|
89
|
+
names: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodObject<{
|
|
90
|
+
label: _$zod.ZodOptional<_$zod.ZodString>;
|
|
91
|
+
description: _$zod.ZodOptional<_$zod.ZodString>;
|
|
92
|
+
}, _$zod_v4_core0.$strict>>>;
|
|
93
|
+
removed: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
|
|
89
94
|
}, _$zod_v4_core0.$strict>>;
|
|
90
95
|
defaults: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
91
96
|
background: _$zod.ZodOptional<_$zod.ZodUnion<readonly [_$zod.ZodUnion<readonly [_$zod.ZodString, _$zod.ZodObject<{
|
|
@@ -17,6 +17,7 @@ import { reanimatedCubicBezierMigration } from "../migrations/20261015212722_rea
|
|
|
17
17
|
import { motionJsonSchemaMigration } from "../migrations/20261015221052_motion_json_schema.js";
|
|
18
18
|
import { motionTypeOnlyMigration } from "../migrations/20261016135620_motion_type_only.js";
|
|
19
19
|
import { styleSetOwnRuleOnlyMigration } from "../migrations/20261113131930_style_set_own_rule_only.js";
|
|
20
|
+
import { lintNamesRemovedMigration } from "../migrations/20261118171253_lint_names_removed.js";
|
|
20
21
|
import { CanvasRole } from "../entities/system/CanvasRole.js";
|
|
21
22
|
import { Guidance } from "../entities/system/Guidance.js";
|
|
22
23
|
import { Source } from "../entities/system/Source.js";
|
|
@@ -78,5 +79,6 @@ if (!registeredSchemaMigrations().has(20261015221052)) registerSchemaMigrations(
|
|
|
78
79
|
if (!registeredSchemaMigrations().has(20261016135620)) registerSchemaMigrations(motionTypeOnlyMigration);
|
|
79
80
|
if (!registeredSchemaMigrations().has(20261015202345)) registerSchemaMigrations(componentElementSwapMigration);
|
|
80
81
|
if (!registeredSchemaMigrations().has(20261113131930)) registerSchemaMigrations(styleSetOwnRuleOnlyMigration);
|
|
82
|
+
if (!registeredSchemaMigrations().has(20261118171253)) registerSchemaMigrations(lintNamesRemovedMigration);
|
|
81
83
|
//#endregion
|
|
82
84
|
export { ReactNativeSystem };
|
package/dist/configs/system.js
CHANGED
|
@@ -53,6 +53,7 @@ import { nativeLintLocationsMigration } from "../migrations/20261112145536_nativ
|
|
|
53
53
|
import { variantBooleansMigration } from "../migrations/20261112154943_variant_booleans.js";
|
|
54
54
|
import { vendorLinkTypeMigration } from "../migrations/20261112163439_vendor_link_type.js";
|
|
55
55
|
import { styleSetOwnRuleOnlyMigration } from "../migrations/20261113131930_style_set_own_rule_only.js";
|
|
56
|
+
import { lintNamesRemovedMigration } from "../migrations/20261118171253_lint_names_removed.js";
|
|
56
57
|
import { CanvasRole } from "../entities/system/CanvasRole.js";
|
|
57
58
|
import { GlobalStyle } from "../entities/system/GlobalStyle.js";
|
|
58
59
|
import { Guidance } from "../entities/system/Guidance.js";
|
|
@@ -244,5 +245,6 @@ if (!registeredSchemaMigrations().has(20261112154943)) registerSchemaMigrations(
|
|
|
244
245
|
if (!registeredSchemaMigrations().has(20261112163439)) registerSchemaMigrations(vendorLinkTypeMigration);
|
|
245
246
|
if (!registeredSchemaMigrations().has(20261113131930)) registerSchemaMigrations(styleSetOwnRuleOnlyMigration);
|
|
246
247
|
if (!registeredSchemaMigrations().has(20261117234103)) registerSchemaMigrations(uds6038McpInputsMigration);
|
|
248
|
+
if (!registeredSchemaMigrations().has(20261118171253)) registerSchemaMigrations(lintNamesRemovedMigration);
|
|
247
249
|
//#endregion
|
|
248
250
|
export { System };
|
|
@@ -75,6 +75,11 @@ declare const NativeSettings: EntityClass<z.ZodObject<Omit<{
|
|
|
75
75
|
when: z.ZodOptional<z.ZodString>;
|
|
76
76
|
reason: z.ZodString;
|
|
77
77
|
}, z.core.$strict>>>;
|
|
78
|
+
names: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
79
|
+
label: z.ZodOptional<z.ZodString>;
|
|
80
|
+
description: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strict>>>;
|
|
82
|
+
removed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
83
|
}, z.core.$strict>>;
|
|
79
84
|
defaults: z.ZodOptional<z.ZodObject<{
|
|
80
85
|
background: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
@@ -129,6 +129,11 @@ declare const LintSectionDefinition: SubEntityClass<z.ZodObject<{
|
|
|
129
129
|
when: z.ZodOptional<z.ZodString>;
|
|
130
130
|
reason: z.ZodString;
|
|
131
131
|
}, z.core.$strict>>>;
|
|
132
|
+
names: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
133
|
+
label: z.ZodOptional<z.ZodString>;
|
|
134
|
+
description: z.ZodOptional<z.ZodString>;
|
|
135
|
+
}, z.core.$strict>>>;
|
|
136
|
+
removed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
132
137
|
}, z.core.$strict>>;
|
|
133
138
|
interface LintSectionClass extends Named<typeof LintSectionDefinition> {}
|
|
134
139
|
declare const LintSection: LintSectionClass;
|
|
@@ -249,6 +254,11 @@ declare const SettingsDefinition: EntityClass<z.ZodObject<{
|
|
|
249
254
|
when: z.ZodOptional<z.ZodString>;
|
|
250
255
|
reason: z.ZodString;
|
|
251
256
|
}, z.core.$strict>>>;
|
|
257
|
+
names: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
258
|
+
label: z.ZodOptional<z.ZodString>;
|
|
259
|
+
description: z.ZodOptional<z.ZodString>;
|
|
260
|
+
}, z.core.$strict>>>;
|
|
261
|
+
removed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
252
262
|
}, z.core.$strict>>;
|
|
253
263
|
defaults: z.ZodOptional<z.ZodObject<{
|
|
254
264
|
background: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
@@ -224,6 +224,19 @@ const lintFields = z.strictObject({
|
|
|
224
224
|
})).meta({
|
|
225
225
|
title: "Ignored findings",
|
|
226
226
|
description: "Findings kept on purpose, each with its reason: a rule on a component, narrowed to a layer, a style key and the rule it is written in when those are given, or on a token. `uds lint` and Create both leave them out."
|
|
227
|
+
}).optional(),
|
|
228
|
+
/** This system's own words for a rule or a group, by its name, in place of the lint's. */
|
|
229
|
+
names: z.record(z.string(), z.strictObject({
|
|
230
|
+
label: z.string().min(1).optional(),
|
|
231
|
+
description: z.string().min(1).optional()
|
|
232
|
+
})).meta({
|
|
233
|
+
title: "Names",
|
|
234
|
+
description: "This system's own label and description for a rule or a group, keyed by the rule's or group's name: `{ 'near-token': { label: 'Off the scale' } }`. Create's Lint page shows them in place of the lint's own."
|
|
235
|
+
}).optional(),
|
|
236
|
+
/** Built-in rules the system has taken out: they don't run and aren't listed. */
|
|
237
|
+
removed: z.array(z.string()).meta({
|
|
238
|
+
title: "Removed rules",
|
|
239
|
+
description: "Built-in rules this system has taken out, by name. They don't run in Create or `uds lint` and aren't listed; taking a name out of the list puts the rule back."
|
|
227
240
|
}).optional()
|
|
228
241
|
});
|
|
229
242
|
const LintSection = defineSubEntity({
|
|
@@ -74,7 +74,7 @@ interface RecordedSource {
|
|
|
74
74
|
* The dense-counter `2` a short-lived scheme stamped before the chain existed reads as the mint
|
|
75
75
|
* that replaced it (see `detectedWireVersion`).
|
|
76
76
|
*/
|
|
77
|
-
declare const SERIALIZED_CONFIG_VERSION =
|
|
77
|
+
declare const SERIALIZED_CONFIG_VERSION = 20261118171253;
|
|
78
78
|
interface SerializedConfig {
|
|
79
79
|
/** See {@link SERIALIZED_CONFIG_VERSION}. Always written; a stored artifact may lack it. */
|
|
80
80
|
readonly version: number;
|
package/dist/framework/Config.js
CHANGED
|
@@ -6681,7 +6681,7 @@ var Config = class Config {
|
|
|
6681
6681
|
* links from the provided sources. A declared `linkedKind` with no provided source throws. */
|
|
6682
6682
|
hydrateFrom(stored, options) {
|
|
6683
6683
|
const claimed = schemaVersionOf(stored);
|
|
6684
|
-
if (claimed >
|
|
6684
|
+
if (claimed > 20261118171253) throw new SchemaVersionTooNew(claimed);
|
|
6685
6685
|
const wire = upgradeSerializedConfig(stored);
|
|
6686
6686
|
if (!Array.isArray(wire.ownedKinds) || typeof wire.items !== "object" || wire.items === null) throw new ConfigFormatError(`Config "${stored.name ?? "system-config"}" cannot be hydrated: this is not a serialized config-v2 config (no "ownedKinds"/"items"). A pre-cutover build artifact converts through the registered cutover migration — import the config type's module (e.g. \`configs/system\`) before hydrating.`);
|
|
6687
6687
|
const leftover = wire.options;
|
|
@@ -15,7 +15,7 @@ import { Patch, SerializedConfig } from "./Config.js";
|
|
|
15
15
|
* sets this constant to its own older timestamp; the merge ref then carries a registered migration
|
|
16
16
|
* newer than the constant, and the assertion fails until the author re-mints.
|
|
17
17
|
*/
|
|
18
|
-
declare const CURRENT_SCHEMA_VERSION =
|
|
18
|
+
declare const CURRENT_SCHEMA_VERSION = 20261118171253;
|
|
19
19
|
/** What the walkers need to see of an envelope — loose on purpose, so a typed `SerializedConfig`
|
|
20
20
|
* and a raw old-shape record both flow in without casts. */
|
|
21
21
|
interface VersionStamped {
|
|
@@ -13,7 +13,7 @@ import { ConfigFormatError } from "./rejection.js";
|
|
|
13
13
|
* sets this constant to its own older timestamp; the merge ref then carries a registered migration
|
|
14
14
|
* newer than the constant, and the assertion fails until the author re-mints.
|
|
15
15
|
*/
|
|
16
|
-
const CURRENT_SCHEMA_VERSION =
|
|
16
|
+
const CURRENT_SCHEMA_VERSION = 20261118171253;
|
|
17
17
|
/** The mint that moved `options` into the `settings` kind — restated here, rather than imported
|
|
18
18
|
* from the migration that owns it, because that migration imports this module. */
|
|
19
19
|
const SETTINGS_AS_KIND_VERSION = 20260908171448;
|
|
@@ -45,7 +45,7 @@ function registerSchemaMigrations(...migrations) {
|
|
|
45
45
|
for (const migration of migrations) {
|
|
46
46
|
if (migration.version !== 1 && !isMintTimestamp(migration.version)) throw new Error(`Schema migration version ${migration.version} is not a mint timestamp — mint one with \`date +%Y%m%d%H%M%S\`, like a supabase migration.`);
|
|
47
47
|
if (REGISTERED.has(migration.version)) throw new Error(`A schema migration at version ${migration.version} is already registered.`);
|
|
48
|
-
if (migration.version >
|
|
48
|
+
if (migration.version > 20261118171253) throw new Error(`Schema migration ${migration.version} is newer than CURRENT_SCHEMA_VERSION (${CURRENT_SCHEMA_VERSION}) — a stale branch merged, or the mint forgot to bump the constant. Re-mint: set CURRENT_SCHEMA_VERSION to the newest migration version.`);
|
|
49
49
|
REGISTERED.set(migration.version, migration);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -102,7 +102,7 @@ function pendingFor(version, target, options) {
|
|
|
102
102
|
* Already-current input passes through untouched — same reference, so hot paths pay nothing.
|
|
103
103
|
*/
|
|
104
104
|
function upgradeSerializedConfig(json, options) {
|
|
105
|
-
const target = options?.target ??
|
|
105
|
+
const target = options?.target ?? 20261118171253;
|
|
106
106
|
const version = detectedWireVersion(json);
|
|
107
107
|
if (version > target) throw new SchemaVersionTooNew(version, target);
|
|
108
108
|
const raw = json;
|
|
@@ -160,7 +160,7 @@ function upgradedSources(json, options) {
|
|
|
160
160
|
* meaning under the current schema and replay skips it — reported by the caller, not swallowed here.
|
|
161
161
|
*/
|
|
162
162
|
function upgradePatch(patch, writtenAt, options) {
|
|
163
|
-
const target = options?.target ??
|
|
163
|
+
const target = options?.target ?? 20261118171253;
|
|
164
164
|
if (writtenAt > target) throw new SchemaVersionTooNew(writtenAt, target);
|
|
165
165
|
let current = patch;
|
|
166
166
|
for (const migration of pendingFor(writtenAt, target, options)) {
|
|
@@ -179,7 +179,7 @@ function upgradePatch(patch, writtenAt, options) {
|
|
|
179
179
|
* stamp would cause.
|
|
180
180
|
*/
|
|
181
181
|
function upgradeDraftEntries(draft, options) {
|
|
182
|
-
const target = options?.target ??
|
|
182
|
+
const target = options?.target ?? 20261118171253;
|
|
183
183
|
const entries = [];
|
|
184
184
|
const held = [];
|
|
185
185
|
const retired = [];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Config } from "../framework/Config.js";
|
|
2
|
+
import { AuthoringLintGroup, AuthoringLintRule } from "./rules.js";
|
|
3
|
+
|
|
4
|
+
//#region src/lint/catalog.d.ts
|
|
5
|
+
/** A rule or a group as this system names it. */
|
|
6
|
+
interface LintRuleText {
|
|
7
|
+
readonly label?: string;
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A rule as this system has it. */
|
|
11
|
+
interface LintCatalogRule {
|
|
12
|
+
readonly id: AuthoringLintRule;
|
|
13
|
+
readonly group: AuthoringLintGroup;
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
}
|
|
17
|
+
interface LintCatalogGroup {
|
|
18
|
+
readonly id: AuthoringLintGroup;
|
|
19
|
+
readonly title: string;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
}
|
|
22
|
+
interface LintCatalog {
|
|
23
|
+
readonly groups: Readonly<Record<AuthoringLintGroup, LintCatalogGroup>>;
|
|
24
|
+
/** Every rule that runs: the built-in ones less the removed. */
|
|
25
|
+
readonly rules: readonly LintCatalogRule[];
|
|
26
|
+
/** The rules the system removed. */
|
|
27
|
+
readonly removed: readonly LintCatalogRule[];
|
|
28
|
+
/** A rule that runs, or a removed one, by name. */
|
|
29
|
+
rule(id: string): LintCatalogRule | undefined;
|
|
30
|
+
}
|
|
31
|
+
declare const isBuiltInRule: (id: string) => id is AuthoringLintRule;
|
|
32
|
+
declare const isLintGroup: (id: string) => id is AuthoringLintGroup;
|
|
33
|
+
/** The rules the system removed. */
|
|
34
|
+
declare const removedLintRules: (config: Config | null) => ReadonlySet<string>;
|
|
35
|
+
/** The system's own words for rules and groups. */
|
|
36
|
+
declare const lintNames: (config: Config | null) => Readonly<Record<string, LintRuleText>>;
|
|
37
|
+
/** The lint as `config`'s system has it. The same object for the same config. */
|
|
38
|
+
declare function lintCatalog(config: Config | null): LintCatalog;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { LintCatalog, LintCatalogGroup, LintCatalogRule, LintRuleText, isBuiltInRule, isLintGroup, lintCatalog, lintNames, removedLintRules };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Settings } from "../entities/system/Settings.js";
|
|
2
|
+
import "../index.js";
|
|
3
|
+
import { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES } from "./rules.js";
|
|
4
|
+
//#region src/lint/catalog.ts
|
|
5
|
+
/**
|
|
6
|
+
* The lint as one system has it: the built-in rules and groups under the system's own names, less the
|
|
7
|
+
* rules it removed.
|
|
8
|
+
*/
|
|
9
|
+
const lintSettings = (config) => (config ? Settings.get(config)?.lint : void 0) ?? {};
|
|
10
|
+
const isBuiltInRule = (id) => id in AUTHORING_LINT_RULES;
|
|
11
|
+
const isLintGroup = (id) => id in AUTHORING_LINT_GROUPS;
|
|
12
|
+
/** The rules the system removed. */
|
|
13
|
+
const removedLintRules = (config) => new Set(lintSettings(config).removed ?? []);
|
|
14
|
+
/** The system's own words for rules and groups. */
|
|
15
|
+
const lintNames = (config) => lintSettings(config).names ?? {};
|
|
16
|
+
const catalogs = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
const NO_CONFIG_CATALOG = buildCatalog(null);
|
|
18
|
+
/** The lint as `config`'s system has it. The same object for the same config. */
|
|
19
|
+
function lintCatalog(config) {
|
|
20
|
+
if (!config) return NO_CONFIG_CATALOG;
|
|
21
|
+
const hit = catalogs.get(config);
|
|
22
|
+
if (hit) return hit;
|
|
23
|
+
const catalog = buildCatalog(config);
|
|
24
|
+
catalogs.set(config, catalog);
|
|
25
|
+
return catalog;
|
|
26
|
+
}
|
|
27
|
+
function buildCatalog(config) {
|
|
28
|
+
const names = lintNames(config);
|
|
29
|
+
const removed = removedLintRules(config);
|
|
30
|
+
const groups = Object.fromEntries(Object.keys(AUTHORING_LINT_GROUPS).map((id) => [id, {
|
|
31
|
+
id,
|
|
32
|
+
title: names[id]?.label ?? AUTHORING_LINT_GROUPS[id].title,
|
|
33
|
+
description: names[id]?.description ?? AUTHORING_LINT_GROUPS[id].about
|
|
34
|
+
}]));
|
|
35
|
+
const all = Object.keys(AUTHORING_LINT_RULES).map((id) => ({
|
|
36
|
+
id,
|
|
37
|
+
group: AUTHORING_LINT_RULES[id].group,
|
|
38
|
+
label: names[id]?.label ?? AUTHORING_LINT_RULES[id].label,
|
|
39
|
+
description: names[id]?.description ?? AUTHORING_LINT_RULES[id].detects
|
|
40
|
+
}));
|
|
41
|
+
const byId = new Map(all.map((rule) => [rule.id, rule]));
|
|
42
|
+
return {
|
|
43
|
+
groups,
|
|
44
|
+
rules: all.filter((rule) => !removed.has(rule.id)),
|
|
45
|
+
removed: all.filter((rule) => removed.has(rule.id)),
|
|
46
|
+
rule: (id) => byId.get(id)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { isBuiltInRule, isLintGroup, lintCatalog, lintNames, removedLintRules };
|
package/dist/lint/edits.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ConfigEdit } from "../framework/config-op.js";
|
|
2
2
|
import { Config } from "../framework/Config.js";
|
|
3
|
-
import { AuthoringLintGroup, AuthoringLintRule, AuthoringLintSeverity } from "./rules.js";
|
|
4
3
|
import { ConfigLintFinding, LintIgnore, LintRetarget } from "./context.js";
|
|
4
|
+
import { AuthoringLintGroup, AuthoringLintRule, AuthoringLintSeverity } from "./rules.js";
|
|
5
|
+
import { LintRuleText } from "./catalog.js";
|
|
5
6
|
|
|
6
7
|
//#region src/lint/edits.d.ts
|
|
7
8
|
/** Where a finding is, as the config stores it, and the value it suggests. */
|
|
8
9
|
interface LintFixSite {
|
|
9
|
-
readonly rule:
|
|
10
|
+
readonly rule: string;
|
|
10
11
|
readonly component?: string;
|
|
11
12
|
readonly token?: string;
|
|
12
13
|
readonly composite?: string;
|
|
@@ -47,6 +48,29 @@ declare function severityEdits({
|
|
|
47
48
|
name: string;
|
|
48
49
|
severity: AuthoringLintSeverity;
|
|
49
50
|
}): ConfigEdit[];
|
|
51
|
+
/**
|
|
52
|
+
* The settings edit that gives a rule or a group the system's own label and description. A value the
|
|
53
|
+
* lint already gives it, or an empty one, drops the system's entry, so the lint's words show again.
|
|
54
|
+
*/
|
|
55
|
+
declare function lintNameEdits({
|
|
56
|
+
config,
|
|
57
|
+
name,
|
|
58
|
+
text
|
|
59
|
+
}: {
|
|
60
|
+
config: Config;
|
|
61
|
+
name: string;
|
|
62
|
+
text: LintRuleText;
|
|
63
|
+
}): ConfigEdit[];
|
|
64
|
+
/** The settings edit that takes a rule out of the system, or (`removed: false`) puts it back. */
|
|
65
|
+
declare function removeRuleEdits({
|
|
66
|
+
config,
|
|
67
|
+
rule,
|
|
68
|
+
removed
|
|
69
|
+
}: {
|
|
70
|
+
config: Config;
|
|
71
|
+
rule: AuthoringLintRule;
|
|
72
|
+
removed: boolean;
|
|
73
|
+
}): ConfigEdit[];
|
|
50
74
|
/** A finding's entry in `settings.lint.ignore`: as narrow as the finding says where it is. */
|
|
51
75
|
declare function ignoreEntry(site: LintFixSite, reason: string): LintIgnore;
|
|
52
76
|
/** The settings edit that keeps a finding, with why: `uds lint` and Create both leave it out. */
|
|
@@ -78,4 +102,4 @@ declare function fixEdits(sites: readonly LintFixSite[]): ConfigEdit[];
|
|
|
78
102
|
/** The edit that repoints a finding's token at its fix, the other choice a finding can offer. */
|
|
79
103
|
declare function retargetEdits(retarget: LintRetarget): ConfigEdit[];
|
|
80
104
|
//#endregion
|
|
81
|
-
export { LintFixSite, fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintSeverities, restoreEdits, retargetEdits, rulesOf, severityEdits };
|
|
105
|
+
export { LintFixSite, fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintNameEdits, lintSeverities, removeRuleEdits, restoreEdits, retargetEdits, rulesOf, severityEdits };
|
package/dist/lint/edits.js
CHANGED
|
@@ -3,6 +3,7 @@ import { styleSetEdits } from "../entities/system/component-style-set.js";
|
|
|
3
3
|
import { Token } from "../entities/system/Token.js";
|
|
4
4
|
import "../index.js";
|
|
5
5
|
import { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, flatLintSeverities, nestLintSeverities, ruleSeverity } from "./rules.js";
|
|
6
|
+
import { isBuiltInRule, isLintGroup, lintNames, removedLintRules } from "./catalog.js";
|
|
6
7
|
//#region src/lint/edits.ts
|
|
7
8
|
/**
|
|
8
9
|
* The lint's settings and fixes as config edits: how loud a rule is, a finding kept on purpose, and
|
|
@@ -54,6 +55,44 @@ function severityEdits({ config, name, severity }) {
|
|
|
54
55
|
}
|
|
55
56
|
return settingsUpdate(config, { "lint.rules": Object.keys(severities).length > 0 ? nestLintSeverities(severities) : null });
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* The settings edit that gives a rule or a group the system's own label and description. A value the
|
|
60
|
+
* lint already gives it, or an empty one, drops the system's entry, so the lint's words show again.
|
|
61
|
+
*/
|
|
62
|
+
function lintNameEdits({ config, name, text }) {
|
|
63
|
+
let lint;
|
|
64
|
+
if (isLintGroup(name)) {
|
|
65
|
+
const about = AUTHORING_LINT_GROUPS[name];
|
|
66
|
+
lint = {
|
|
67
|
+
label: about.title,
|
|
68
|
+
description: about.about
|
|
69
|
+
};
|
|
70
|
+
} else if (isBuiltInRule(name)) {
|
|
71
|
+
const about = AUTHORING_LINT_RULES[name];
|
|
72
|
+
lint = {
|
|
73
|
+
label: about.label,
|
|
74
|
+
description: about.detects
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (!lint) return [];
|
|
78
|
+
const label = text.label?.trim();
|
|
79
|
+
const description = text.description?.trim();
|
|
80
|
+
const entry = {
|
|
81
|
+
...label && label !== lint.label ? { label } : {},
|
|
82
|
+
...description && description !== lint.description ? { description } : {}
|
|
83
|
+
};
|
|
84
|
+
const names = { ...lintNames(config) };
|
|
85
|
+
if (Object.keys(entry).length > 0) names[name] = entry;
|
|
86
|
+
else delete names[name];
|
|
87
|
+
return settingsUpdate(config, { "lint.names": Object.keys(names).length > 0 ? names : null });
|
|
88
|
+
}
|
|
89
|
+
/** The settings edit that takes a rule out of the system, or (`removed: false`) puts it back. */
|
|
90
|
+
function removeRuleEdits({ config, rule, removed }) {
|
|
91
|
+
const out = new Set(removedLintRules(config));
|
|
92
|
+
if (removed) out.add(rule);
|
|
93
|
+
else out.delete(rule);
|
|
94
|
+
return settingsUpdate(config, { "lint.removed": out.size > 0 ? [...out] : null });
|
|
95
|
+
}
|
|
57
96
|
/** A finding's entry in `settings.lint.ignore`: as narrow as the finding says where it is. */
|
|
58
97
|
function ignoreEntry(site, reason) {
|
|
59
98
|
return {
|
|
@@ -130,4 +169,4 @@ function retargetEdits(retarget) {
|
|
|
130
169
|
}];
|
|
131
170
|
}
|
|
132
171
|
//#endregion
|
|
133
|
-
export { fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintSeverities, restoreEdits, retargetEdits, rulesOf, severityEdits };
|
|
172
|
+
export { fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintNameEdits, lintSeverities, removeRuleEdits, restoreEdits, retargetEdits, rulesOf, severityEdits };
|
package/dist/lint/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, AuthoringLintFix, AuthoringLintGroup, AuthoringLintRule, AuthoringLintRuleSettings, AuthoringLintSeverity, CONFIG_LINT_RULES, ConfigLintCheck, ConfigReadLintRule, LintReads, LintRuleSettingNote, flatLintSeverities, lintReads, lintRuleSettingNotes, nestLintSeverities, ruleSeverity } from "./rules.js";
|
|
2
1
|
import { ConfigLintFinding, ConfigLintOptions, LintIgnore, ignoredBy } from "./context.js";
|
|
3
|
-
import {
|
|
2
|
+
import { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, AuthoringLintFix, AuthoringLintGroup, AuthoringLintRule, AuthoringLintRuleSettings, AuthoringLintSeverity, CONFIG_LINT_RULES, ConfigLintCheck, ConfigReadLintRule, LintReads, LintRuleSettingNote, flatLintSeverities, lintReads, lintRuleSettingNotes, nestLintSeverities, ruleSeverity } from "./rules.js";
|
|
3
|
+
import { LintCatalog, LintCatalogGroup, LintCatalogRule, LintRuleText, isBuiltInRule, isLintGroup, lintCatalog, lintNames, removedLintRules } from "./catalog.js";
|
|
4
|
+
import { LintFixSite, fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintNameEdits, lintSeverities, removeRuleEdits, restoreEdits, retargetEdits, rulesOf, severityEdits } from "./edits.js";
|
|
4
5
|
import { AuthoringLintEdit, AuthoringLintFinding, AuthoringLintResult, LintIgnoreProblem, LintRun, LintSources, lint, lintConfig } from "./lint.js";
|
|
5
|
-
export { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, AuthoringLintEdit, AuthoringLintFinding, AuthoringLintFix, AuthoringLintGroup, AuthoringLintResult, AuthoringLintRule, AuthoringLintRuleSettings, AuthoringLintSeverity, CONFIG_LINT_RULES, ConfigLintCheck, type ConfigLintFinding, type ConfigLintOptions, ConfigReadLintRule, LintFixSite, type LintIgnore, LintIgnoreProblem, LintReads, LintRuleSettingNote, LintRun, LintSources, fixEdits, flatLintSeverities, groupSeverity, hasFix, ignoreEdits, ignoreEntry, ignoredBy, lint, lintConfig, lintIgnores, lintReads, lintRuleSettingNotes, lintSeverities, nestLintSeverities, restoreEdits, retargetEdits, ruleSeverity, rulesOf, severityEdits };
|
|
6
|
+
export { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, AuthoringLintEdit, AuthoringLintFinding, AuthoringLintFix, AuthoringLintGroup, AuthoringLintResult, AuthoringLintRule, AuthoringLintRuleSettings, AuthoringLintSeverity, CONFIG_LINT_RULES, ConfigLintCheck, type ConfigLintFinding, type ConfigLintOptions, ConfigReadLintRule, LintCatalog, LintCatalogGroup, LintCatalogRule, LintFixSite, type LintIgnore, LintIgnoreProblem, LintReads, LintRuleSettingNote, LintRuleText, LintRun, LintSources, fixEdits, flatLintSeverities, groupSeverity, hasFix, ignoreEdits, ignoreEntry, ignoredBy, isBuiltInRule, isLintGroup, lint, lintCatalog, lintConfig, lintIgnores, lintNameEdits, lintNames, lintReads, lintRuleSettingNotes, lintSeverities, nestLintSeverities, removeRuleEdits, removedLintRules, restoreEdits, retargetEdits, ruleSeverity, rulesOf, severityEdits };
|
package/dist/lint/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ignoredBy } from "./context.js";
|
|
2
2
|
import { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, CONFIG_LINT_RULES, flatLintSeverities, lintReads, lintRuleSettingNotes, nestLintSeverities, ruleSeverity } from "./rules.js";
|
|
3
|
-
import {
|
|
3
|
+
import { isBuiltInRule, isLintGroup, lintCatalog, lintNames, removedLintRules } from "./catalog.js";
|
|
4
|
+
import { fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintNameEdits, lintSeverities, removeRuleEdits, restoreEdits, retargetEdits, rulesOf, severityEdits } from "./edits.js";
|
|
4
5
|
import { lint, lintConfig } from "./lint.js";
|
|
5
|
-
export { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, CONFIG_LINT_RULES, fixEdits, flatLintSeverities, groupSeverity, hasFix, ignoreEdits, ignoreEntry, ignoredBy, lint, lintConfig, lintIgnores, lintReads, lintRuleSettingNotes, lintSeverities, nestLintSeverities, restoreEdits, retargetEdits, ruleSeverity, rulesOf, severityEdits };
|
|
6
|
+
export { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, CONFIG_LINT_RULES, fixEdits, flatLintSeverities, groupSeverity, hasFix, ignoreEdits, ignoreEntry, ignoredBy, isBuiltInRule, isLintGroup, lint, lintCatalog, lintConfig, lintIgnores, lintNameEdits, lintNames, lintReads, lintRuleSettingNotes, lintSeverities, nestLintSeverities, removeRuleEdits, removedLintRules, restoreEdits, retargetEdits, ruleSeverity, rulesOf, severityEdits };
|
package/dist/lint/lint.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Config } from "../framework/Config.js";
|
|
2
|
-
import { AuthoringLintFix, AuthoringLintRule, AuthoringLintSeverity, LintRuleSettingNote } from "./rules.js";
|
|
3
2
|
import { ConfigLintFinding, ConfigLintOptions } from "./context.js";
|
|
3
|
+
import { AuthoringLintFix, AuthoringLintRule, AuthoringLintSeverity, LintRuleSettingNote } from "./rules.js";
|
|
4
4
|
|
|
5
5
|
//#region src/lint/lint.d.ts
|
|
6
6
|
/** One text replacement an `auto` fix makes: `text` in place of `[start, end)` in `file`. */
|
package/dist/lint/lint.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Settings } from "../entities/system/Settings.js";
|
|
|
2
2
|
import "../index.js";
|
|
3
3
|
import { configLintContext, ignoredBy } from "./context.js";
|
|
4
4
|
import { AUTHORING_LINT_RULES, lintReads } from "./rules.js";
|
|
5
|
+
import { removedLintRules } from "./catalog.js";
|
|
5
6
|
//#region src/lint/lint.ts
|
|
6
7
|
/**
|
|
7
8
|
* Running the lint. `lintConfig` runs the rules that read the config, synchronously, wherever a config
|
|
@@ -79,14 +80,19 @@ function lintConfig(config, options = {}) {
|
|
|
79
80
|
*/
|
|
80
81
|
async function lint(config, { sources } = {}) {
|
|
81
82
|
const ignores = Settings.get(config)?.lint?.ignore ?? [];
|
|
82
|
-
const
|
|
83
|
+
const removed = removedLintRules(config);
|
|
84
|
+
const found = lintConfig(sources?.prepare ? await sources.prepare(config) : config, sources ? {} : { rules: Object.keys(AUTHORING_LINT_RULES).filter((rule) => lintReads(rule) !== "code") }).filter((finding) => !removed.has(finding.rule) && !ignoredBy(ignores, finding));
|
|
83
85
|
if (!sources) return { config: found };
|
|
86
|
+
const result = await sources.lint({
|
|
87
|
+
config,
|
|
88
|
+
configFindings: found
|
|
89
|
+
});
|
|
84
90
|
return {
|
|
85
91
|
config: found,
|
|
86
|
-
sources:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
92
|
+
sources: {
|
|
93
|
+
...result,
|
|
94
|
+
findings: result.findings.filter((finding) => !removed.has(finding.rule))
|
|
95
|
+
}
|
|
90
96
|
};
|
|
91
97
|
}
|
|
92
98
|
//#endregion
|
package/dist/lint/rules.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { unmappedNativeStyleKeys } from "./native-style-keys.js";
|
|
2
1
|
import { ConfigLintContext, ConfigLintReport, LintLayer, LintValue, LintedComponent } from "./context.js";
|
|
2
|
+
import { unmappedNativeStyleKeys } from "./native-style-keys.js";
|
|
3
3
|
|
|
4
4
|
//#region src/lint/rules.d.ts
|
|
5
5
|
declare const AUTHORING_LINT_GROUPS: {
|
|
6
6
|
readonly portability: {
|
|
7
|
-
readonly title: "
|
|
7
|
+
readonly title: "Linking & Extending";
|
|
8
8
|
readonly about: "Values that reach a component only through code, so a team that links or extends your system can’t change them.";
|
|
9
9
|
};
|
|
10
10
|
readonly editability: {
|
|
11
|
-
readonly title: "
|
|
11
|
+
readonly title: "Hidden from Create";
|
|
12
12
|
readonly about: "Behavior and styling decided in code, where Create can't show or change it. Turn this group off if your system is only ever edited in code.";
|
|
13
13
|
};
|
|
14
14
|
readonly maintainability: {
|
|
15
|
-
readonly title: "
|
|
15
|
+
readonly title: "Redundancies";
|
|
16
16
|
readonly about: "Styles written longer than they need to be: values your tokens already hold, the same value repeated under every option, and settings that change nothing. Each makes the next change harder.";
|
|
17
17
|
};
|
|
18
18
|
readonly design: {
|
|
19
|
-
readonly title: "
|
|
19
|
+
readonly title: "Accessibility";
|
|
20
20
|
readonly about: "Contrast, spacing and sizing your users will notice: text that is hard to read, values just off your scale, colors that stay the same in dark mode, and targets too small to tap.";
|
|
21
21
|
};
|
|
22
22
|
readonly compatibility: {
|
|
23
|
-
readonly title: "
|
|
23
|
+
readonly title: "Future-proofing";
|
|
24
24
|
readonly about: "Reliance on parts of the platform that are changing or internal, which a future update can break.";
|
|
25
25
|
};
|
|
26
26
|
readonly nursery: {
|
|
27
|
-
readonly title: "
|
|
27
|
+
readonly title: "Beta";
|
|
28
28
|
readonly about: "New rules still being tuned. They are off unless you turn them on, and their advice may change."; /** Naming the group turns none of them on: a nursery rule is taken up one at a time. */
|
|
29
29
|
readonly defaultSeverity: "off";
|
|
30
30
|
};
|
package/dist/lint/rules.js
CHANGED
|
@@ -19,27 +19,27 @@ import { unmappedNativeStyleKeys } from "./native-style-keys.js";
|
|
|
19
19
|
*/
|
|
20
20
|
const AUTHORING_LINT_GROUPS = {
|
|
21
21
|
portability: {
|
|
22
|
-
title: "
|
|
22
|
+
title: "Linking & Extending",
|
|
23
23
|
about: "Values that reach a component only through code, so a team that links or extends your system can’t change them."
|
|
24
24
|
},
|
|
25
25
|
editability: {
|
|
26
|
-
title: "
|
|
26
|
+
title: "Hidden from Create",
|
|
27
27
|
about: "Behavior and styling decided in code, where Create can't show or change it. Turn this group off if your system is only ever edited in code."
|
|
28
28
|
},
|
|
29
29
|
maintainability: {
|
|
30
|
-
title: "
|
|
30
|
+
title: "Redundancies",
|
|
31
31
|
about: "Styles written longer than they need to be: values your tokens already hold, the same value repeated under every option, and settings that change nothing. Each makes the next change harder."
|
|
32
32
|
},
|
|
33
33
|
design: {
|
|
34
|
-
title: "
|
|
34
|
+
title: "Accessibility",
|
|
35
35
|
about: "Contrast, spacing and sizing your users will notice: text that is hard to read, values just off your scale, colors that stay the same in dark mode, and targets too small to tap."
|
|
36
36
|
},
|
|
37
37
|
compatibility: {
|
|
38
|
-
title: "
|
|
38
|
+
title: "Future-proofing",
|
|
39
39
|
about: "Reliance on parts of the platform that are changing or internal, which a future update can break."
|
|
40
40
|
},
|
|
41
41
|
nursery: {
|
|
42
|
-
title: "
|
|
42
|
+
title: "Beta",
|
|
43
43
|
about: "New rules still being tuned. They are off unless you turn them on, and their advice may change.",
|
|
44
44
|
/** Naming the group turns none of them on: a nursery rule is taken up one at a time. */
|
|
45
45
|
defaultSeverity: "off"
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Lint settings take `names` and `removed`; stored configs and draft patches keep their shape. */
|
|
2
|
+
import type { SchemaMigration } from '../framework/schema-version';
|
|
3
|
+
export declare const LINT_NAMES_REMOVED_VERSION = 20261118171253;
|
|
4
|
+
export declare const lintNamesRemovedMigration: SchemaMigration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/migrations/20261118171253_lint_names_removed.ts
|
|
2
|
+
const LINT_NAMES_REMOVED_VERSION = 20261118171253;
|
|
3
|
+
const lintNamesRemovedMigration = {
|
|
4
|
+
version: LINT_NAMES_REMOVED_VERSION,
|
|
5
|
+
up(json) {
|
|
6
|
+
return json;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { LINT_NAMES_REMOVED_VERSION, lintNamesRemovedMigration };
|