@yahoo/uds-create-config 5.94.1 → 5.94.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 +6 -0
- package/dist/configs/react-native-system.d.ts +6 -0
- package/dist/configs/system.js +2 -0
- package/dist/entities/native/NativeSettings.d.ts +6 -0
- package/dist/entities/system/Modifier.d.ts +1 -1
- package/dist/entities/system/Settings.d.ts +12 -0
- package/dist/entities/system/Settings.js +6 -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/context.d.ts +9 -0
- package/dist/lint/context.js +1 -1
- package/dist/lint/edits.d.ts +2 -0
- package/dist/lint/edits.js +2 -0
- package/dist/lint/lint.js +2 -0
- package/dist/lint/native-style-keys.d.ts +7 -0
- package/dist/lint/native-style-keys.js +170 -0
- package/dist/lint/rules.d.ts +11 -0
- package/dist/lint/rules.js +9 -0
- package/dist/migrations/20261112145536_native_lint_locations.d.ts +5 -0
- package/dist/migrations/20261112145536_native_lint_locations.js +10 -0
- package/dist/react-native/style-keys.generated.d.ts +2 -4
- package/dist/react-native/style-keys.generated.js +150 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -57,6 +57,12 @@ export declare function yosNative(): import("..").ConfigInstance<{
|
|
|
57
57
|
rule: import("zod").ZodString;
|
|
58
58
|
component: import("zod").ZodOptional<import("zod").ZodString>;
|
|
59
59
|
token: import("zod").ZodOptional<import("zod").ZodString>;
|
|
60
|
+
composite: import("zod").ZodOptional<import("zod").ZodString>;
|
|
61
|
+
field: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
62
|
+
styles: "styles";
|
|
63
|
+
defaultProps: "defaultProps";
|
|
64
|
+
defaultPropsWhen: "defaultPropsWhen";
|
|
65
|
+
}>>;
|
|
60
66
|
layer: import("zod").ZodOptional<import("zod").ZodString>;
|
|
61
67
|
prop: import("zod").ZodOptional<import("zod").ZodString>;
|
|
62
68
|
when: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -75,6 +75,12 @@ declare const ReactNativeSystemDefinition: ConfigClass<{
|
|
|
75
75
|
rule: _$zod.ZodString;
|
|
76
76
|
component: _$zod.ZodOptional<_$zod.ZodString>;
|
|
77
77
|
token: _$zod.ZodOptional<_$zod.ZodString>;
|
|
78
|
+
composite: _$zod.ZodOptional<_$zod.ZodString>;
|
|
79
|
+
field: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
80
|
+
styles: "styles";
|
|
81
|
+
defaultProps: "defaultProps";
|
|
82
|
+
defaultPropsWhen: "defaultPropsWhen";
|
|
83
|
+
}>>;
|
|
78
84
|
layer: _$zod.ZodOptional<_$zod.ZodString>;
|
|
79
85
|
prop: _$zod.ZodOptional<_$zod.ZodString>;
|
|
80
86
|
when: _$zod.ZodOptional<_$zod.ZodString>;
|
package/dist/configs/system.js
CHANGED
|
@@ -49,6 +49,7 @@ import { stringPropUniqueIdsMigration } from "../migrations/20261109205852_strin
|
|
|
49
49
|
import { anatomyNodeOverridesMigration } from "../migrations/20261109214535_anatomy_node_overrides.js";
|
|
50
50
|
import { computedVisibilityMigration } from "../migrations/20261110145811_computed_visibility.js";
|
|
51
51
|
import { anatomyNodeStatesMigration } from "../migrations/20261110171151_anatomy_node_states.js";
|
|
52
|
+
import { nativeLintLocationsMigration } from "../migrations/20261112145536_native_lint_locations.js";
|
|
52
53
|
import { CanvasRole } from "../entities/system/CanvasRole.js";
|
|
53
54
|
import { GlobalStyle } from "../entities/system/GlobalStyle.js";
|
|
54
55
|
import { Guidance } from "../entities/system/Guidance.js";
|
|
@@ -234,5 +235,6 @@ if (!registeredSchemaMigrations().has(20261109205852)) registerSchemaMigrations(
|
|
|
234
235
|
if (!registeredSchemaMigrations().has(20261109214535)) registerSchemaMigrations(anatomyNodeOverridesMigration);
|
|
235
236
|
if (!registeredSchemaMigrations().has(20261110145811)) registerSchemaMigrations(computedVisibilityMigration);
|
|
236
237
|
if (!registeredSchemaMigrations().has(20261110171151)) registerSchemaMigrations(anatomyNodeStatesMigration);
|
|
238
|
+
if (!registeredSchemaMigrations().has(20261112145536)) registerSchemaMigrations(nativeLintLocationsMigration);
|
|
237
239
|
//#endregion
|
|
238
240
|
export { System };
|
|
@@ -64,6 +64,12 @@ declare const NativeSettings: EntityClass<z.ZodObject<Omit<{
|
|
|
64
64
|
rule: z.ZodString;
|
|
65
65
|
component: z.ZodOptional<z.ZodString>;
|
|
66
66
|
token: z.ZodOptional<z.ZodString>;
|
|
67
|
+
composite: z.ZodOptional<z.ZodString>;
|
|
68
|
+
field: z.ZodOptional<z.ZodEnum<{
|
|
69
|
+
styles: "styles";
|
|
70
|
+
defaultProps: "defaultProps";
|
|
71
|
+
defaultPropsWhen: "defaultPropsWhen";
|
|
72
|
+
}>>;
|
|
67
73
|
layer: z.ZodOptional<z.ZodString>;
|
|
68
74
|
prop: z.ZodOptional<z.ZodString>;
|
|
69
75
|
when: z.ZodOptional<z.ZodString>;
|
|
@@ -43,8 +43,8 @@ type ModifierGroupMeta = z.infer<typeof modifierGroupFields> & {
|
|
|
43
43
|
};
|
|
44
44
|
declare const ModifierDefinition: EntityClass<z.ZodObject<{
|
|
45
45
|
type: z.ZodEnum<{
|
|
46
|
-
selector: "selector";
|
|
47
46
|
composite: "composite";
|
|
47
|
+
selector: "selector";
|
|
48
48
|
"media-query": "media-query";
|
|
49
49
|
"starting-style": "starting-style";
|
|
50
50
|
}>;
|
|
@@ -118,6 +118,12 @@ declare const LintSectionDefinition: SubEntityClass<z.ZodObject<{
|
|
|
118
118
|
rule: z.ZodString;
|
|
119
119
|
component: z.ZodOptional<z.ZodString>;
|
|
120
120
|
token: z.ZodOptional<z.ZodString>;
|
|
121
|
+
composite: z.ZodOptional<z.ZodString>;
|
|
122
|
+
field: z.ZodOptional<z.ZodEnum<{
|
|
123
|
+
styles: "styles";
|
|
124
|
+
defaultProps: "defaultProps";
|
|
125
|
+
defaultPropsWhen: "defaultPropsWhen";
|
|
126
|
+
}>>;
|
|
121
127
|
layer: z.ZodOptional<z.ZodString>;
|
|
122
128
|
prop: z.ZodOptional<z.ZodString>;
|
|
123
129
|
when: z.ZodOptional<z.ZodString>;
|
|
@@ -232,6 +238,12 @@ declare const SettingsDefinition: EntityClass<z.ZodObject<{
|
|
|
232
238
|
rule: z.ZodString;
|
|
233
239
|
component: z.ZodOptional<z.ZodString>;
|
|
234
240
|
token: z.ZodOptional<z.ZodString>;
|
|
241
|
+
composite: z.ZodOptional<z.ZodString>;
|
|
242
|
+
field: z.ZodOptional<z.ZodEnum<{
|
|
243
|
+
styles: "styles";
|
|
244
|
+
defaultProps: "defaultProps";
|
|
245
|
+
defaultPropsWhen: "defaultPropsWhen";
|
|
246
|
+
}>>;
|
|
235
247
|
layer: z.ZodOptional<z.ZodString>;
|
|
236
248
|
prop: z.ZodOptional<z.ZodString>;
|
|
237
249
|
when: z.ZodOptional<z.ZodString>;
|
|
@@ -211,6 +211,12 @@ const lintFields = z.strictObject({
|
|
|
211
211
|
rule: z.string(),
|
|
212
212
|
component: z.string().optional(),
|
|
213
213
|
token: z.string().optional(),
|
|
214
|
+
composite: z.string().optional(),
|
|
215
|
+
field: z.enum([
|
|
216
|
+
"styles",
|
|
217
|
+
"defaultProps",
|
|
218
|
+
"defaultPropsWhen"
|
|
219
|
+
]).optional(),
|
|
214
220
|
layer: z.string().optional(),
|
|
215
221
|
prop: z.string().optional(),
|
|
216
222
|
when: z.string().optional(),
|
|
@@ -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 = 20261112145536;
|
|
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
|
@@ -6583,7 +6583,7 @@ var Config = class Config {
|
|
|
6583
6583
|
* links from the provided sources. A declared `linkedKind` with no provided source throws. */
|
|
6584
6584
|
hydrateFrom(stored, options) {
|
|
6585
6585
|
const claimed = schemaVersionOf(stored);
|
|
6586
|
-
if (claimed >
|
|
6586
|
+
if (claimed > 20261112145536) throw new SchemaVersionTooNew(claimed);
|
|
6587
6587
|
const wire = upgradeSerializedConfig(stored);
|
|
6588
6588
|
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.`);
|
|
6589
6589
|
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 = 20261112145536;
|
|
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 = 20261112145536;
|
|
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 > 20261112145536) 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 ?? 20261112145536;
|
|
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 ?? 20261112145536;
|
|
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 ?? 20261112145536;
|
|
183
183
|
const entries = [];
|
|
184
184
|
const held = [];
|
|
185
185
|
const retired = [];
|
package/dist/lint/context.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ interface ConfigLintFindingBody {
|
|
|
9
9
|
readonly component?: string;
|
|
10
10
|
/** The token it's about, by path. */
|
|
11
11
|
readonly token?: string;
|
|
12
|
+
readonly composite?: string;
|
|
13
|
+
readonly field?: 'styles' | 'defaultProps' | 'defaultPropsWhen';
|
|
12
14
|
/** The style rule the value is written in, by its key (`*`, `size=xs`). */
|
|
13
15
|
readonly when?: string;
|
|
14
16
|
/** That rule's condition as prop values (`{ size: 'xs' }`), `null` for the rule every cell gets:
|
|
@@ -36,8 +38,11 @@ interface ConfigLintFinding extends ConfigLintFindingBody {
|
|
|
36
38
|
interface LintReport {
|
|
37
39
|
/** The style value it's about; the finding is placed there. */
|
|
38
40
|
readonly at?: LintValue;
|
|
41
|
+
readonly modifiers?: readonly string[];
|
|
39
42
|
/** For a finding about a token rather than a style value. */
|
|
40
43
|
readonly token?: string;
|
|
44
|
+
readonly composite?: string;
|
|
45
|
+
readonly field?: 'styles' | 'defaultProps' | 'defaultPropsWhen';
|
|
41
46
|
readonly prop?: string;
|
|
42
47
|
readonly value?: string;
|
|
43
48
|
readonly message: string;
|
|
@@ -61,6 +66,8 @@ interface LintIgnore {
|
|
|
61
66
|
readonly rule: string;
|
|
62
67
|
readonly component?: string;
|
|
63
68
|
readonly token?: string;
|
|
69
|
+
readonly composite?: string;
|
|
70
|
+
readonly field?: 'styles' | 'defaultProps' | 'defaultPropsWhen';
|
|
64
71
|
readonly layer?: string;
|
|
65
72
|
readonly prop?: string;
|
|
66
73
|
readonly when?: string;
|
|
@@ -74,6 +81,8 @@ declare function ignoredBy(ignores: readonly LintIgnore[], finding: {
|
|
|
74
81
|
readonly rule: string;
|
|
75
82
|
readonly component?: string;
|
|
76
83
|
readonly token?: string;
|
|
84
|
+
readonly composite?: string;
|
|
85
|
+
readonly field?: 'styles' | 'defaultProps' | 'defaultPropsWhen';
|
|
77
86
|
readonly layer?: string;
|
|
78
87
|
readonly prop?: string;
|
|
79
88
|
readonly when?: string;
|
package/dist/lint/context.js
CHANGED
|
@@ -25,7 +25,7 @@ import "../index.js";
|
|
|
25
25
|
* or token, then layer, style key and rule) the finding's own. An entry naming less reaches more.
|
|
26
26
|
*/
|
|
27
27
|
function ignoredBy(ignores, finding) {
|
|
28
|
-
return ignores.find((entry) => entry.rule === finding.rule && (entry.component === void 0 || entry.component === finding.component) && (entry.token === void 0 || entry.token === finding.token) && (entry.layer === void 0 || entry.layer === finding.layer) && (entry.prop === void 0 || entry.prop === finding.prop) && (entry.when === void 0 || entry.when === finding.when));
|
|
28
|
+
return ignores.find((entry) => entry.rule === finding.rule && (entry.component === void 0 || entry.component === finding.component) && (entry.token === void 0 || entry.token === finding.token) && (entry.composite === void 0 || entry.composite === finding.composite) && (entry.field === void 0 || entry.field === (finding.field ?? "styles")) && (entry.layer === void 0 || entry.layer === finding.layer) && (entry.prop === void 0 || entry.prop === finding.prop) && (entry.when === void 0 || entry.when === finding.when));
|
|
29
29
|
}
|
|
30
30
|
const tokenOf = (value) => isRef(value) && kindOf(value) === "token" ? pathOf(value) : void 0;
|
|
31
31
|
const BREAKPOINTS = new Set([
|
package/dist/lint/edits.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ interface LintFixSite {
|
|
|
9
9
|
readonly rule: AuthoringLintRule;
|
|
10
10
|
readonly component?: string;
|
|
11
11
|
readonly token?: string;
|
|
12
|
+
readonly composite?: string;
|
|
13
|
+
readonly field?: ConfigLintFinding['field'];
|
|
12
14
|
readonly when?: string;
|
|
13
15
|
readonly whenProps?: ConfigLintFinding['whenProps'];
|
|
14
16
|
readonly layer?: string;
|
package/dist/lint/edits.js
CHANGED
|
@@ -59,6 +59,8 @@ function ignoreEntry(site, reason) {
|
|
|
59
59
|
rule: site.rule,
|
|
60
60
|
...site.component ? { component: site.component } : {},
|
|
61
61
|
...site.token ? { token: site.token } : {},
|
|
62
|
+
...site.composite ? { composite: site.composite } : {},
|
|
63
|
+
...site.field ? { field: site.field } : {},
|
|
62
64
|
...site.layer ? { layer: site.layer } : {},
|
|
63
65
|
...site.prop ? { prop: site.prop } : {},
|
|
64
66
|
...site.when ? { when: site.when } : {},
|
package/dist/lint/lint.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfigLintContext, ConfigLintReport } from "./context.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lint/native-style-keys.d.ts
|
|
4
|
+
/** Native style and interaction bags that would otherwise silently drop a value. */
|
|
5
|
+
declare function unmappedNativeStyleKeys(ctx: ConfigLintContext, report: ConfigLintReport): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { unmappedNativeStyleKeys };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { isExtendedRef, isRef, kindOf, memberOf, pathOf } from "../framework/utils/refs.js";
|
|
2
|
+
import { isPlainObject } from "../framework/utils/field-path.js";
|
|
3
|
+
import { storedDefaultConditions } from "../framework/default-conditions.js";
|
|
4
|
+
import { rootLayerOf } from "../entities/system/element.js";
|
|
5
|
+
import { declaredPropRouting, resolveComponentProps, stylePropertiesWriting, stylePropertyPathFor } from "../framework/projections.js";
|
|
6
|
+
import { standsInForCode } from "../framework/prop-surface.js";
|
|
7
|
+
import { RN_HOST_STYLE_PROPS, RN_STYLE_KEYS } from "../react-native/style-keys.generated.js";
|
|
8
|
+
import "../index.js";
|
|
9
|
+
import { written } from "./context.js";
|
|
10
|
+
//#region src/lint/native-style-keys.ts
|
|
11
|
+
const styleKeys = new Set(RN_STYLE_KEYS);
|
|
12
|
+
const reanimatedHosts = new Set([
|
|
13
|
+
"View",
|
|
14
|
+
"Text",
|
|
15
|
+
"Image",
|
|
16
|
+
"ScrollView",
|
|
17
|
+
"FlatList"
|
|
18
|
+
]);
|
|
19
|
+
const hostProps = RN_HOST_STYLE_PROPS;
|
|
20
|
+
/** A known native receiver that ignores `key`, following only components whose props are known. */
|
|
21
|
+
function ignoresKey({ config, element, key }) {
|
|
22
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23
|
+
while (isRef(element) && kindOf(element) === "component") {
|
|
24
|
+
const path = pathOf(element);
|
|
25
|
+
if (seen.has(path) || standsInForCode(config, path)) return false;
|
|
26
|
+
seen.add(path);
|
|
27
|
+
const json = config.resolve("component", path)?.toJSON();
|
|
28
|
+
if (!json || resolveComponentProps(config, path)[key] || json.renderProps?.includes(key)) return false;
|
|
29
|
+
element = rootLayerOf(json.layers ?? {})[1];
|
|
30
|
+
}
|
|
31
|
+
if (!isRef(element) || kindOf(element) !== "package") return false;
|
|
32
|
+
const pkg = pathOf(element);
|
|
33
|
+
let name = memberOf(element);
|
|
34
|
+
if (pkg === "react-native") name = name?.replace(/^Animated\./, "");
|
|
35
|
+
else if (pkg === "react-native-reanimated") {
|
|
36
|
+
name = name?.replace(/^(default|Animated)\./, "");
|
|
37
|
+
if (!name || !reanimatedHosts.has(name)) return false;
|
|
38
|
+
} else return false;
|
|
39
|
+
return name !== void 0 && Object.hasOwn(hostProps, name) && !hostProps[name]?.includes(key);
|
|
40
|
+
}
|
|
41
|
+
/** Authored keys, treating native arrays and composed objects as single values. */
|
|
42
|
+
function* sites({ styles, modifierKeys }) {
|
|
43
|
+
function* walk({ bag, place }) {
|
|
44
|
+
if (!isPlainObject(bag)) return;
|
|
45
|
+
for (const [prop, value] of Object.entries(bag)) if (modifierKeys.has(prop)) yield* walk({
|
|
46
|
+
bag: value,
|
|
47
|
+
place: {
|
|
48
|
+
...place,
|
|
49
|
+
modifiers: [...place.modifiers, prop]
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
else yield {
|
|
53
|
+
...place,
|
|
54
|
+
prop,
|
|
55
|
+
value
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
for (const [when, entry] of Object.entries(styles ?? {})) {
|
|
59
|
+
const rule = entry;
|
|
60
|
+
for (const [layer, bag] of Object.entries(rule?.layers ?? {})) yield* walk({
|
|
61
|
+
bag,
|
|
62
|
+
place: {
|
|
63
|
+
when,
|
|
64
|
+
whenValue: rule?.when,
|
|
65
|
+
layer,
|
|
66
|
+
modifiers: []
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Native style and interaction bags that would otherwise silently drop a value. */
|
|
72
|
+
function unmappedNativeStyleKeys(ctx, report) {
|
|
73
|
+
if (!ctx.platform.native) return;
|
|
74
|
+
const { config } = ctx;
|
|
75
|
+
const modifiers = config.list("modifier");
|
|
76
|
+
const modifierKeys = new Set(modifiers.map((one) => `_${one.leaf}`));
|
|
77
|
+
const stateKeys = new Set(modifiers.filter((one) => one.toJSON().type === "state").map((one) => `_${one.leaf}`));
|
|
78
|
+
const problem = ({ key, state, element, author, composite = false }) => {
|
|
79
|
+
if (key.startsWith("_")) return modifierKeys.has(key) ? void 0 : `\`${key}\` is not a registered native modifier, so this block sets nothing.`;
|
|
80
|
+
if (key === "composite" || config.resolve("composite", key)) return;
|
|
81
|
+
const mapped = (author ? declaredPropRouting(config, author).get(key) : void 0) ?? stylePropertyPathFor({
|
|
82
|
+
config,
|
|
83
|
+
through: [isRef(element) && kindOf(element) === "component" ? pathOf(element) : void 0],
|
|
84
|
+
key
|
|
85
|
+
});
|
|
86
|
+
if (mapped && config.resolve("style-property", mapped)) return;
|
|
87
|
+
if (state) return `\`${key}\` is an element prop inside a native state block, where element props are not applied. Use a registered style property, or set the prop in a rule conditioned on a component state.`;
|
|
88
|
+
if (!styleKeys.has(key) || !composite && !ignoresKey({
|
|
89
|
+
config,
|
|
90
|
+
element,
|
|
91
|
+
key
|
|
92
|
+
})) return;
|
|
93
|
+
const names = stylePropertiesWriting(config, key).filter((one) => one.properties.length === 1 && !one.negates && !one.opacityOf).map((one) => `\`${one.path}\``);
|
|
94
|
+
let advice = `Declare a style property that writes \`${key}\`, then use its name here.`;
|
|
95
|
+
if (names.length > 0) advice = `Use ${names.join(" or ")} instead of \`${key}\`.`;
|
|
96
|
+
return `\`${key}\` has no style-property mapping and sets no native style. ${advice}`;
|
|
97
|
+
};
|
|
98
|
+
for (const { path } of config.list("component")) {
|
|
99
|
+
const stored = config.snapshot.slice("component").items.get(path)?.toJSON();
|
|
100
|
+
const authored = isExtendedRef(stored) ? stored.extend : stored;
|
|
101
|
+
if (!isPlainObject(authored) || isRef(authored)) continue;
|
|
102
|
+
if (!isExtendedRef(stored) && !ctx.own("component", path)) continue;
|
|
103
|
+
const json = config.resolve("component", path)?.toJSON();
|
|
104
|
+
if (!json) continue;
|
|
105
|
+
const component = {
|
|
106
|
+
path,
|
|
107
|
+
json,
|
|
108
|
+
sites: [],
|
|
109
|
+
cells: []
|
|
110
|
+
};
|
|
111
|
+
const root = rootLayerOf(json.layers ?? {})[0];
|
|
112
|
+
const own = resolveComponentProps(config, path);
|
|
113
|
+
const bags = [
|
|
114
|
+
{ styles: authored.styles },
|
|
115
|
+
{
|
|
116
|
+
styles: { "*": { layers: { [root]: authored.defaultProps } } },
|
|
117
|
+
field: "defaultProps"
|
|
118
|
+
},
|
|
119
|
+
...Object.entries(storedDefaultConditions(authored)).map(([when, entry]) => ({
|
|
120
|
+
styles: { [when]: {
|
|
121
|
+
when: entry.when,
|
|
122
|
+
layers: { [root]: entry.props }
|
|
123
|
+
} },
|
|
124
|
+
field: "defaultPropsWhen"
|
|
125
|
+
}))
|
|
126
|
+
];
|
|
127
|
+
for (const { styles, field } of bags) for (const site of sites({
|
|
128
|
+
styles,
|
|
129
|
+
modifierKeys
|
|
130
|
+
})) {
|
|
131
|
+
const declared = own[site.prop];
|
|
132
|
+
if (field && declared && declared.type !== "styleProperty") continue;
|
|
133
|
+
const message = problem({
|
|
134
|
+
key: site.prop,
|
|
135
|
+
state: site.modifiers.some((key) => stateKeys.has(key)),
|
|
136
|
+
element: json.layers?.[site.layer],
|
|
137
|
+
author: path
|
|
138
|
+
});
|
|
139
|
+
if (message) report({
|
|
140
|
+
at: ctx.value(component, site),
|
|
141
|
+
...field ? { field } : {},
|
|
142
|
+
message
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const { path } of config.list("composite")) {
|
|
147
|
+
const stored = config.snapshot.slice("composite").items.get(path)?.toJSON();
|
|
148
|
+
const authored = isExtendedRef(stored) ? stored.extend : stored;
|
|
149
|
+
if (!isPlainObject(authored) || isRef(authored)) continue;
|
|
150
|
+
for (const site of sites({
|
|
151
|
+
styles: { "*": { layers: { root: authored.styles } } },
|
|
152
|
+
modifierKeys
|
|
153
|
+
})) {
|
|
154
|
+
const message = problem({
|
|
155
|
+
key: site.prop,
|
|
156
|
+
state: site.modifiers.some((key) => stateKeys.has(key)),
|
|
157
|
+
composite: true
|
|
158
|
+
});
|
|
159
|
+
if (message) report({
|
|
160
|
+
composite: path,
|
|
161
|
+
prop: site.prop,
|
|
162
|
+
modifiers: site.modifiers,
|
|
163
|
+
value: written(site.value),
|
|
164
|
+
message
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
export { unmappedNativeStyleKeys };
|
package/dist/lint/rules.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unmappedNativeStyleKeys } from "./native-style-keys.js";
|
|
1
2
|
import { ConfigLintContext, ConfigLintReport, LintLayer, LintValue, LintedComponent } from "./context.js";
|
|
2
3
|
|
|
3
4
|
//#region src/lint/rules.d.ts
|
|
@@ -30,6 +31,16 @@ declare const AUTHORING_LINT_GROUPS: {
|
|
|
30
31
|
};
|
|
31
32
|
type AuthoringLintGroup = keyof typeof AUTHORING_LINT_GROUPS;
|
|
32
33
|
declare const AUTHORING_LINT_RULES: {
|
|
34
|
+
readonly 'unmapped-native-style-key': {
|
|
35
|
+
readonly reads: "config";
|
|
36
|
+
readonly group: "maintainability";
|
|
37
|
+
readonly label: "Native style that sets nothing";
|
|
38
|
+
readonly detects: "A native style or state rule that accepts a value but never applies it. This includes unrecognized style names and element props inside state blocks.";
|
|
39
|
+
readonly fix: "use the declared style-property name, or declare a style property for the native key";
|
|
40
|
+
readonly check: {
|
|
41
|
+
readonly system: typeof unmappedNativeStyleKeys;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
33
44
|
readonly 'inline-style-on-layer': {
|
|
34
45
|
readonly group: "portability";
|
|
35
46
|
readonly label: "Inline style";
|
package/dist/lint/rules.js
CHANGED
|
@@ -4,6 +4,7 @@ import { contrastRatio } from "../framework/utils/color.js";
|
|
|
4
4
|
import { parseCssLength } from "../framework/utils/css-length.js";
|
|
5
5
|
import "../index.js";
|
|
6
6
|
import { MIN_CONTRAST, SCALE_STEP, TRANSPARENT, written } from "./context.js";
|
|
7
|
+
import { unmappedNativeStyleKeys } from "./native-style-keys.js";
|
|
7
8
|
//#region src/lint/rules.ts
|
|
8
9
|
/**
|
|
9
10
|
* Every lint rule: its group, what it detects, how to fix it, how loud it is by default, and what it
|
|
@@ -44,6 +45,14 @@ const AUTHORING_LINT_GROUPS = {
|
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
const AUTHORING_LINT_RULES = {
|
|
48
|
+
"unmapped-native-style-key": {
|
|
49
|
+
reads: "config",
|
|
50
|
+
group: "maintainability",
|
|
51
|
+
label: "Native style that sets nothing",
|
|
52
|
+
detects: "A native style or state rule that accepts a value but never applies it. This includes unrecognized style names and element props inside state blocks.",
|
|
53
|
+
fix: "use the declared style-property name, or declare a style property for the native key",
|
|
54
|
+
check: { system: unmappedNativeStyleKeys }
|
|
55
|
+
},
|
|
47
56
|
"inline-style-on-layer": {
|
|
48
57
|
group: "portability",
|
|
49
58
|
label: "Inline style",
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Lint ignores can target a composite or a component's defaults independently of its rules.
|
|
2
|
+
* These optional location fields add no stored defaults, so existing envelopes and patches pass through. */
|
|
3
|
+
import type { SchemaMigration } from '../framework/schema-version';
|
|
4
|
+
export declare const NATIVE_LINT_LOCATIONS_VERSION = 20261112145536;
|
|
5
|
+
export declare const nativeLintLocationsMigration: SchemaMigration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/migrations/20261112145536_native_lint_locations.ts
|
|
2
|
+
const NATIVE_LINT_LOCATIONS_VERSION = 20261112145536;
|
|
3
|
+
const nativeLintLocationsMigration = {
|
|
4
|
+
version: NATIVE_LINT_LOCATIONS_VERSION,
|
|
5
|
+
up(json) {
|
|
6
|
+
return json;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { NATIVE_LINT_LOCATIONS_VERSION, nativeLintLocationsMigration };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
//#region src/react-native/style-keys.generated.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* GENERATED — do not edit. `bun scripts/generate-rn-style-keys.ts`
|
|
4
|
-
* Native
|
|
5
|
-
* `TextStyle` and `ImageStyle` accept, including inherited interfaces. `NativeStyleProperty`
|
|
6
|
-
* validates against this, so the native style vocabulary is React Native's, not a hand-kept list.
|
|
3
|
+
* GENERATED — do not edit. Run `bun scripts/generate-rn-style-keys.ts` in packages/config.
|
|
4
|
+
* React Native 0.86.3: ViewStyle, TextStyle, ImageStyle, and exported host prop declarations.
|
|
7
5
|
*/
|
|
8
6
|
declare const RN_STYLE_KEYS: readonly ["alignContent", "alignItems", "alignSelf", "aspectRatio", "backfaceVisibility", "backgroundColor", "borderBlockColor", "borderBlockEndColor", "borderBlockStartColor", "borderBottomColor", "borderBottomEndRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "borderBottomStartRadius", "borderBottomWidth", "borderColor", "borderCurve", "borderEndColor", "borderEndEndRadius", "borderEndStartRadius", "borderEndWidth", "borderLeftColor", "borderLeftWidth", "borderRadius", "borderRightColor", "borderRightWidth", "borderStartColor", "borderStartEndRadius", "borderStartStartRadius", "borderStartWidth", "borderStyle", "borderTopColor", "borderTopEndRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderTopStartRadius", "borderTopWidth", "borderWidth", "bottom", "boxShadow", "boxSizing", "color", "columnGap", "cursor", "direction", "display", "elevation", "end", "experimental_backgroundImage", "experimental_backgroundPosition", "experimental_backgroundRepeat", "experimental_backgroundSize", "filter", "flex", "flexBasis", "flexDirection", "flexGrow", "flexShrink", "flexWrap", "fontFamily", "fontSize", "fontStyle", "fontVariant", "fontWeight", "gap", "height", "includeFontPadding", "inset", "insetBlock", "insetBlockEnd", "insetBlockStart", "insetInline", "insetInlineEnd", "insetInlineStart", "isolation", "justifyContent", "left", "letterSpacing", "lineHeight", "margin", "marginBlock", "marginBlockEnd", "marginBlockStart", "marginBottom", "marginEnd", "marginHorizontal", "marginInline", "marginInlineEnd", "marginInlineStart", "marginLeft", "marginRight", "marginStart", "marginTop", "marginVertical", "maxHeight", "maxWidth", "minHeight", "minWidth", "mixBlendMode", "objectFit", "opacity", "outlineColor", "outlineOffset", "outlineStyle", "outlineWidth", "overflow", "overlayColor", "padding", "paddingBlock", "paddingBlockEnd", "paddingBlockStart", "paddingBottom", "paddingEnd", "paddingHorizontal", "paddingInline", "paddingInlineEnd", "paddingInlineStart", "paddingLeft", "paddingRight", "paddingStart", "paddingTop", "paddingVertical", "pointerEvents", "position", "resizeMode", "right", "rotation", "rowGap", "scaleX", "scaleY", "shadowColor", "shadowOffset", "shadowOpacity", "shadowRadius", "start", "textAlign", "textAlignVertical", "textDecorationColor", "textDecorationLine", "textDecorationStyle", "textShadowColor", "textShadowOffset", "textShadowRadius", "textTransform", "tintColor", "top", "transform", "transformMatrix", "transformOrigin", "translateX", "translateY", "userSelect", "verticalAlign", "width", "writingDirection", "zIndex"];
|
|
9
7
|
//#endregion
|