onsystem 0.5.0 → 0.6.0

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.
@@ -12,6 +12,26 @@ interface ImportMapping {
12
12
  /** File or pattern relative to the root, with forward slashes. */
13
13
  target: string;
14
14
  }
15
+ /**
16
+ * A dependency whose package.json declares its onsystem config
17
+ * (`"onsystem": "./onsystem.config.json"`): a design-system package set up for the apps that
18
+ * use it.
19
+ */
20
+ interface DesignSystemPackage {
21
+ /** Its package name: `@acme/ui`. */
22
+ name: string;
23
+ /** Its folder, absolute: the workspace package's sources, or where it is installed. */
24
+ dir: string;
25
+ /** The JSON config its package.json names, absolute. */
26
+ config: string;
27
+ /** Installed from a registry into `node_modules`, rather than a workspace package. */
28
+ installed: boolean;
29
+ /**
30
+ * The folder its config's paths must stay in: its own folder when installed, else the
31
+ * workspace root (a sibling package's tokens, `../tokens/...`), or its own folder outside one.
32
+ */
33
+ boundary: string;
34
+ }
15
35
  /** One of several design systems an app uses, and how often its code imports it. */
16
36
  interface DesignSystemSource {
17
37
  source: string;
@@ -19,170 +39,6 @@ interface DesignSystemSource {
19
39
  imports: number;
20
40
  }
21
41
  //#endregion
22
- //#region src/config.d.ts
23
- declare const RULE_IDS: readonly ["no-hardcoded-color", "no-hardcoded-spacing", "no-hardcoded-radius", "prefer-design-system-component", "no-unknown-component", "no-unknown-prop", "no-unknown-variant", "icon-button-accessible-name"];
24
- type RuleId = (typeof RULE_IDS)[number];
25
- declare const severitySchema: z.ZodEnum<{
26
- off: "off";
27
- warn: "warn";
28
- error: "error";
29
- }>;
30
- type RuleSeverity = z.infer<typeof severitySchema>;
31
- declare const ruleOptionsSchema: z.ZodObject<{
32
- allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
- }, z.core.$strict>;
34
- type RuleOptions = z.infer<typeof ruleOptionsSchema>;
35
- declare const configSchema: z.ZodObject<{
36
- $schema: z.ZodOptional<z.ZodString>;
37
- components: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
38
- exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
39
- tokens: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
40
- path: z.ZodString;
41
- prefix: z.ZodOptional<z.ZodString>;
42
- }, z.core.$strict>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
43
- path: z.ZodString;
44
- prefix: z.ZodOptional<z.ZodString>;
45
- }, z.core.$strict>]>>]>>;
46
- docs: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
47
- tsconfig: z.ZodOptional<z.ZodString>;
48
- importPath: z.ZodOptional<z.ZodString>;
49
- elements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
50
- includeDesignSystem: z.ZodOptional<z.ZodBoolean>;
51
- rules: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
52
- "no-hardcoded-color": "no-hardcoded-color";
53
- "no-hardcoded-spacing": "no-hardcoded-spacing";
54
- "no-hardcoded-radius": "no-hardcoded-radius";
55
- "prefer-design-system-component": "prefer-design-system-component";
56
- "no-unknown-component": "no-unknown-component";
57
- "no-unknown-prop": "no-unknown-prop";
58
- "no-unknown-variant": "no-unknown-variant";
59
- "icon-button-accessible-name": "icon-button-accessible-name";
60
- }> & z.core.$partial, z.ZodUnion<readonly [z.ZodEnum<{
61
- off: "off";
62
- warn: "warn";
63
- error: "error";
64
- }>, z.ZodTuple<[z.ZodEnum<{
65
- off: "off";
66
- warn: "warn";
67
- error: "error";
68
- }>], null>, z.ZodTuple<[z.ZodEnum<{
69
- off: "off";
70
- warn: "warn";
71
- error: "error";
72
- }>, z.ZodObject<{
73
- allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
74
- }, z.core.$strict>], null>]>>>;
75
- overrides: z.ZodOptional<z.ZodArray<z.ZodObject<{
76
- files: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
77
- rules: z.ZodRecord<z.ZodEnum<{
78
- "no-hardcoded-color": "no-hardcoded-color";
79
- "no-hardcoded-spacing": "no-hardcoded-spacing";
80
- "no-hardcoded-radius": "no-hardcoded-radius";
81
- "prefer-design-system-component": "prefer-design-system-component";
82
- "no-unknown-component": "no-unknown-component";
83
- "no-unknown-prop": "no-unknown-prop";
84
- "no-unknown-variant": "no-unknown-variant";
85
- "icon-button-accessible-name": "icon-button-accessible-name";
86
- }> & z.core.$partial, z.ZodUnion<readonly [z.ZodEnum<{
87
- off: "off";
88
- warn: "warn";
89
- error: "error";
90
- }>, z.ZodTuple<[z.ZodEnum<{
91
- off: "off";
92
- warn: "warn";
93
- error: "error";
94
- }>], null>, z.ZodTuple<[z.ZodEnum<{
95
- off: "off";
96
- warn: "warn";
97
- error: "error";
98
- }>, z.ZodObject<{
99
- allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
100
- }, z.core.$strict>], null>]>>;
101
- }, z.core.$strict>>>;
102
- }, z.core.$strict>;
103
- type Config = z.input<typeof configSchema>;
104
- /** Identity helper for typed `onsystem.config.ts` files. */
105
- declare function defineConfig(config: Config): Config;
106
- interface TokenSourceConfig {
107
- path: string;
108
- prefix?: string | undefined;
109
- }
110
- interface ResolvedRule {
111
- severity: RuleSeverity;
112
- options: RuleOptions;
113
- }
114
- /** Rule settings for the files that match `files` (root-relative globs). */
115
- interface ResolvedOverride {
116
- files: string[];
117
- rules: Partial<Record<RuleId, ResolvedRule>>;
118
- }
119
- interface ResolvedConfig {
120
- root: string;
121
- configFile?: string | undefined;
122
- components: string[];
123
- exclude: string[];
124
- tokens: TokenSourceConfig[];
125
- docs: string[];
126
- tsconfig?: string | undefined;
127
- importPath?: string | undefined;
128
- /** Import specifiers for component files, from the `exports` of the package that holds them. */
129
- imports?: ImportMapping[] | undefined;
130
- /** How the design system was found when the config does not say (`components.json`, a workspace package). */
131
- detected?: string | undefined;
132
- /**
133
- * Several design systems found at once, the most imported first: its components win
134
- * where two share a name, and are the ones suggested for native elements.
135
- */
136
- designSystems?: DesignSystemSource[] | undefined;
137
- /** A Tailwind v3 config, which maps color classes to custom properties (`primary` → `hsl(var(--primary))`). */
138
- tailwindConfig?: string | undefined;
139
- elements: Record<string, string>;
140
- /** `check` lints the component files themselves, which it skips by default. */
141
- includeDesignSystem: boolean;
142
- rules: Record<RuleId, ResolvedRule>;
143
- /** Per-file rule settings, applied in order over `rules`. */
144
- overrides?: ResolvedOverride[] | undefined;
145
- /**
146
- * The folder `overrides` globs are relative to, when it is not the root: the workspace
147
- * root, for a project that takes its settings from a config there.
148
- */
149
- base?: string | undefined;
150
- /** `components` comes from the config file or `--components`, not from detection or the defaults. */
151
- configured?: boolean | undefined;
152
- /**
153
- * What to tell the user about the config's name: a config file found under its name from
154
- * before the rename to onsystem. The CLI prints these once per run, the server logs them once.
155
- */
156
- deprecations?: string[] | undefined;
157
- }
158
- interface LoadConfigOptions {
159
- /** Where to look for a config file when `root` and `config` are not given. */
160
- cwd?: string;
161
- /** Project root. Defaults to the config file's directory, then `cwd`. */
162
- root?: string | undefined;
163
- /** Explicit config file path. */
164
- config?: string | undefined;
165
- /**
166
- * The folder the config file's paths and globs are written relative to, when it is not
167
- * the root: a workspace root whose config a project in it takes on.
168
- */
169
- base?: string | undefined;
170
- /** CLI overrides; replace the config file's values when set. */
171
- components?: string[] | undefined;
172
- tokens?: string[] | undefined;
173
- docs?: string[] | undefined;
174
- includeDesignSystem?: boolean | undefined;
175
- /**
176
- * Read a JSON config only: a JavaScript or TypeScript config is an error rather than run.
177
- * For a project the MCP server found from the path a tool call names, which a prompt can
178
- * choose, unlike the folder the server was started in.
179
- */
180
- jsonConfigOnly?: boolean | undefined;
181
- }
182
- declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedConfig>;
183
- /** JSON Schema for editor completion in `onsystem.config.json`. */
184
- declare function configJsonSchema(): Record<string, unknown>;
185
- //#endregion
186
42
  //#region src/types.d.ts
187
43
  /**
188
44
  * The design-system model the server exposes. Everything here is plain JSON so
@@ -220,8 +76,12 @@ interface Token {
220
76
  deprecated?: string | true;
221
77
  /** Name of the token this one aliases, if any. */
222
78
  aliasOf?: string;
223
- /** Where the value comes from. `tailwind-default` marks Tailwind built-ins such as `--spacing`. */
224
- origin?: 'tailwind-default';
79
+ /**
80
+ * Where the value comes from. `tailwind-default` marks Tailwind built-ins such as `--spacing`;
81
+ * `library` a value of a library's theme (MUI's `createTheme`), whose spacing and radius are
82
+ * listed but do not drive the length rules, whose scales are Tailwind's.
83
+ */
84
+ origin?: 'tailwind-default' | 'library';
225
85
  source: SourceLocation;
226
86
  }
227
87
  interface PropInfo {
@@ -307,6 +167,26 @@ interface ComponentInfo {
307
167
  classNames: string[];
308
168
  /** CSS custom properties referenced in the component source. */
309
169
  cssVars: string[];
170
+ /**
171
+ * The published library it comes from, read from its type declarations rather than from
172
+ * source: `@mui/material`. The app's own components win where they share a name.
173
+ */
174
+ library?: string;
175
+ /**
176
+ * A prop that renders another element or component in its place and takes that one's props
177
+ * (`component` in MUI): when it is set, the props cannot be checked.
178
+ */
179
+ polymorphic?: string;
180
+ /** Another module that exports it as its default: `@mui/material/Button`. */
181
+ defaultImport?: string;
182
+ /**
183
+ * A prop whose text the component gives its child element as its accessible name (MUI's
184
+ * Tooltip `title`), unless the `unless` prop is set (`describeChild` makes it a description).
185
+ */
186
+ labelsChild?: {
187
+ prop: string;
188
+ unless?: string;
189
+ };
310
190
  }
311
191
  interface DesignSystemModel {
312
192
  version: 1;
@@ -383,4 +263,220 @@ interface CheckResult {
383
263
  skipped?: string;
384
264
  }
385
265
  //#endregion
386
- export { RuleId as C, loadConfig as D, defineConfig as E, ImportMapping as O, ResolvedRule as S, configJsonSchema as T, VariantInfo as _, DesignSystemModel as a, RULE_IDS as b, ExampleInfo as c, Severity as d, SourceLocation as f, TokenCategory as g, Token as h, CompoundVariantInfo as i, InheritedProps as l, TextEdit as m, ComponentDocs as n, Diagnostic as o, TOKEN_CATEGORIES as p, ComponentInfo as r, DocSection as s, CheckResult as t, PropInfo as u, Config as v, RuleOptions as w, ResolvedConfig as x, LoadConfigOptions as y };
266
+ //#region src/libraries/index.d.ts
267
+ /** The ids of the libraries onsystem can read, for the config's `libraries` list. */
268
+ declare const LIBRARY_IDS: readonly ["mui"];
269
+ type LibraryId = (typeof LIBRARY_IDS)[number];
270
+ /** A library an app depends on, and where it is installed. */
271
+ interface LibrarySource {
272
+ package: string;
273
+ /** The installed package's folder, absolute; undefined when it is a dependency but not installed. */
274
+ dir?: string | undefined;
275
+ /** The installed version. */
276
+ version?: string | undefined;
277
+ }
278
+ //#endregion
279
+ //#region src/config.d.ts
280
+ declare const RULE_IDS: readonly ["no-hardcoded-color", "no-hardcoded-spacing", "no-hardcoded-radius", "prefer-design-system-component", "no-unknown-component", "no-unknown-prop", "no-unknown-variant", "icon-button-accessible-name"];
281
+ type RuleId = (typeof RULE_IDS)[number];
282
+ declare const severitySchema: z.ZodEnum<{
283
+ error: "error";
284
+ off: "off";
285
+ warn: "warn";
286
+ }>;
287
+ type RuleSeverity = z.infer<typeof severitySchema>;
288
+ declare const ruleOptionsSchema: z.ZodObject<{
289
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
290
+ }, z.core.$strict>;
291
+ type RuleOptions = z.infer<typeof ruleOptionsSchema>;
292
+ declare const configSchema: z.ZodObject<{
293
+ $schema: z.ZodOptional<z.ZodString>;
294
+ components: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
295
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
296
+ tokens: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
297
+ path: z.ZodString;
298
+ prefix: z.ZodOptional<z.ZodString>;
299
+ }, z.core.$strict>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
300
+ path: z.ZodString;
301
+ prefix: z.ZodOptional<z.ZodString>;
302
+ }, z.core.$strict>]>>]>>;
303
+ docs: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
304
+ tsconfig: z.ZodOptional<z.ZodString>;
305
+ importPath: z.ZodOptional<z.ZodString>;
306
+ elements: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
307
+ libraries: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodArray<z.ZodEnum<{
308
+ mui: "mui";
309
+ }>>]>>;
310
+ includeDesignSystem: z.ZodOptional<z.ZodBoolean>;
311
+ rules: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
312
+ "no-hardcoded-color": "no-hardcoded-color";
313
+ "no-hardcoded-spacing": "no-hardcoded-spacing";
314
+ "no-hardcoded-radius": "no-hardcoded-radius";
315
+ "prefer-design-system-component": "prefer-design-system-component";
316
+ "no-unknown-component": "no-unknown-component";
317
+ "no-unknown-prop": "no-unknown-prop";
318
+ "no-unknown-variant": "no-unknown-variant";
319
+ "icon-button-accessible-name": "icon-button-accessible-name";
320
+ }> & z.core.$partial, z.ZodUnion<readonly [z.ZodEnum<{
321
+ error: "error";
322
+ off: "off";
323
+ warn: "warn";
324
+ }>, z.ZodTuple<[z.ZodEnum<{
325
+ error: "error";
326
+ off: "off";
327
+ warn: "warn";
328
+ }>], null>, z.ZodTuple<[z.ZodEnum<{
329
+ error: "error";
330
+ off: "off";
331
+ warn: "warn";
332
+ }>, z.ZodObject<{
333
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
334
+ }, z.core.$strict>], null>]>>>;
335
+ overrides: z.ZodOptional<z.ZodArray<z.ZodObject<{
336
+ files: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
337
+ rules: z.ZodRecord<z.ZodEnum<{
338
+ "no-hardcoded-color": "no-hardcoded-color";
339
+ "no-hardcoded-spacing": "no-hardcoded-spacing";
340
+ "no-hardcoded-radius": "no-hardcoded-radius";
341
+ "prefer-design-system-component": "prefer-design-system-component";
342
+ "no-unknown-component": "no-unknown-component";
343
+ "no-unknown-prop": "no-unknown-prop";
344
+ "no-unknown-variant": "no-unknown-variant";
345
+ "icon-button-accessible-name": "icon-button-accessible-name";
346
+ }> & z.core.$partial, z.ZodUnion<readonly [z.ZodEnum<{
347
+ error: "error";
348
+ off: "off";
349
+ warn: "warn";
350
+ }>, z.ZodTuple<[z.ZodEnum<{
351
+ error: "error";
352
+ off: "off";
353
+ warn: "warn";
354
+ }>], null>, z.ZodTuple<[z.ZodEnum<{
355
+ error: "error";
356
+ off: "off";
357
+ warn: "warn";
358
+ }>, z.ZodObject<{
359
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
360
+ }, z.core.$strict>], null>]>>;
361
+ }, z.core.$strict>>>;
362
+ }, z.core.$strict>;
363
+ type Config = z.input<typeof configSchema>;
364
+ /** Identity helper for typed `onsystem.config.ts` files. */
365
+ declare function defineConfig(config: Config): Config;
366
+ interface TokenSourceConfig {
367
+ path: string;
368
+ prefix?: string | undefined;
369
+ /** Read only when no other source finds a token file (zero config's `DESIGN.md`). */
370
+ fallback?: boolean | undefined;
371
+ }
372
+ interface ResolvedRule {
373
+ severity: RuleSeverity;
374
+ options: RuleOptions;
375
+ }
376
+ /** Rule settings for the files that match `files` (root-relative globs). */
377
+ interface ResolvedOverride {
378
+ files: string[];
379
+ rules: Partial<Record<RuleId, ResolvedRule>>;
380
+ }
381
+ interface ResolvedConfig {
382
+ root: string;
383
+ configFile?: string | undefined;
384
+ components: string[];
385
+ /** What `check`, the ESLint plugin and the hook leave out of the project's own files. */
386
+ exclude: string[];
387
+ /**
388
+ * What finding the design system's own files (components, tokens, docs) leaves out, when it
389
+ * is not `exclude`: a design-system package's own list, rebased onto the package. An app that
390
+ * takes on the package's config leaves out the default `exclude` patterns as well.
391
+ */
392
+ designSystemExclude?: string[] | undefined;
393
+ tokens: TokenSourceConfig[];
394
+ docs: string[];
395
+ tsconfig?: string | undefined;
396
+ importPath?: string | undefined;
397
+ /** Import specifiers for component files, from the `exports` of the package that holds them. */
398
+ imports?: ImportMapping[] | undefined;
399
+ /** How the design system was found when the config does not say (`components.json`, a workspace package). */
400
+ detected?: string | undefined;
401
+ /**
402
+ * Several design systems found at once, the most imported first: its components win
403
+ * where two share a name, and are the ones suggested for native elements.
404
+ */
405
+ designSystems?: DesignSystemSource[] | undefined;
406
+ /** A Tailwind v3 config, which maps color classes to custom properties (`primary` → `hsl(var(--primary))`). */
407
+ tailwindConfig?: string | undefined;
408
+ /**
409
+ * Published component libraries the project depends on, read from their type declarations
410
+ * (MUI), whatever the config says about `components`: their components are checked where
411
+ * the code imports them, and the project's own components win a shared name.
412
+ */
413
+ libraries?: LibrarySource[] | undefined;
414
+ /**
415
+ * The config's `libraries`: the ids of the libraries to read, or false for none. Undefined
416
+ * reads every library onsystem supports.
417
+ */
418
+ libraryIds?: false | LibraryId[] | undefined;
419
+ /** Libraries the project depends on that `libraries` leaves out, so they are not read. */
420
+ librariesOff?: LibrarySource[] | undefined;
421
+ elements: Record<string, string>;
422
+ /** `check` lints the component files themselves, which it skips by default. */
423
+ includeDesignSystem: boolean;
424
+ rules: Record<RuleId, ResolvedRule>;
425
+ /** Per-file rule settings, applied in order over `rules`. */
426
+ overrides?: ResolvedOverride[] | undefined;
427
+ /**
428
+ * The folder `overrides` globs are relative to, when it is not the root: the workspace
429
+ * root, for a project that takes its settings from a config there.
430
+ */
431
+ base?: string | undefined;
432
+ /**
433
+ * The design-system package whose config this is: a dependency whose package.json declares it
434
+ * (`"onsystem": "./onsystem.config.json"`), taken on by a project with no config of its own.
435
+ * Its paths are rebased from the package; its `tsconfig`, `overrides` and
436
+ * `includeDesignSystem` stay with it.
437
+ */
438
+ designSystemPackage?: DesignSystemPackage | undefined;
439
+ /** `components` comes from the config file or `--components`, not from detection or the defaults. */
440
+ configured?: boolean | undefined;
441
+ /**
442
+ * What to tell the user about the config's name: a config file found under its name from
443
+ * before the rename to onsystem. The CLI prints these once per run, the server logs them once.
444
+ */
445
+ deprecations?: string[] | undefined;
446
+ /**
447
+ * What to tell the user about a design-system package's config: one installed from a
448
+ * registry whose declaration cannot be read, which was skipped, or paths in one that point
449
+ * outside it, which were ignored. The CLI prints these once per run, the server logs them
450
+ * once, and the ESLint plugin writes them once to stderr.
451
+ */
452
+ warnings?: string[] | undefined;
453
+ }
454
+ interface LoadConfigOptions {
455
+ /** Where to look for a config file when `root` and `config` are not given. */
456
+ cwd?: string;
457
+ /** Project root. Defaults to the config file's directory, then `cwd`. */
458
+ root?: string | undefined;
459
+ /** Explicit config file path. */
460
+ config?: string | undefined;
461
+ /**
462
+ * The folder the config file's paths and globs are written relative to, when it is not
463
+ * the root: a workspace root whose config a project in it takes on.
464
+ */
465
+ base?: string | undefined;
466
+ /** CLI overrides; replace the config file's values when set. */
467
+ components?: string[] | undefined;
468
+ tokens?: string[] | undefined;
469
+ docs?: string[] | undefined;
470
+ includeDesignSystem?: boolean | undefined;
471
+ /**
472
+ * Read a JSON config only: a JavaScript or TypeScript config is an error rather than run.
473
+ * For a project the MCP server found from the path a tool call names, which a prompt can
474
+ * choose, unlike the folder the server was started in.
475
+ */
476
+ jsonConfigOnly?: boolean | undefined;
477
+ }
478
+ declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedConfig>;
479
+ /** JSON Schema for editor completion in `onsystem.config.json`. */
480
+ declare function configJsonSchema(): Record<string, unknown>;
481
+ //#endregion
482
+ export { TOKEN_CATEGORIES as C, VariantInfo as D, TokenCategory as E, ImportMapping as O, SourceLocation as S, Token as T, DocSection as _, ResolvedRule as a, PropInfo as b, configJsonSchema as c, CheckResult as d, ComponentDocs as f, Diagnostic as g, DesignSystemModel as h, ResolvedConfig as i, defineConfig as l, CompoundVariantInfo as m, LoadConfigOptions as n, RuleId as o, ComponentInfo as p, RULE_IDS as r, RuleOptions as s, Config as t, loadConfig as u, ExampleInfo as v, TextEdit as w, Severity as x, InheritedProps as y };