@maggioli-design-system/magma 2.6.0 → 2.7.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.
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +24 -0
- package/agents/assets.md +23 -9
- package/agents/conventions.md +2 -1
- package/agents/lint.md +37 -9
- package/agents/mcp.md +6 -2
- package/agents/reporting.md +53 -2
- package/dist/collection/components/mds-accordion/AGENTS.md +1 -1
- package/dist/collection/components/mds-accordion/documentation.json +1 -1
- package/dist/collection/components/mds-accordion-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-accordion-item/documentation.json +1 -1
- package/dist/collection/components/mds-accordion-timer/AGENTS.md +1 -1
- package/dist/collection/components/mds-accordion-timer/documentation.json +1 -1
- package/dist/collection/components/mds-accordion-timer-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-accordion-timer-item/documentation.json +1 -1
- package/dist/collection/components/mds-author/AGENTS.md +1 -1
- package/dist/collection/components/mds-author/documentation.json +1 -1
- package/dist/collection/components/mds-avatar/AGENTS.md +1 -1
- package/dist/collection/components/mds-avatar/documentation.json +1 -1
- package/dist/collection/components/mds-avatar-stack/AGENTS.md +1 -1
- package/dist/collection/components/mds-avatar-stack/documentation.json +1 -1
- package/dist/collection/components/mds-avatar-stack-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-avatar-stack-item/documentation.json +1 -1
- package/dist/collection/components/mds-badge/AGENTS.md +1 -1
- package/dist/collection/components/mds-badge/documentation.json +1 -1
- package/dist/collection/components/mds-banner/AGENTS.md +1 -1
- package/dist/collection/components/mds-banner/documentation.json +1 -1
- package/dist/collection/components/mds-benchmark-bar/AGENTS.md +1 -1
- package/dist/collection/components/mds-benchmark-bar/documentation.json +1 -1
- package/dist/collection/components/mds-bibliography/AGENTS.md +1 -1
- package/dist/collection/components/mds-bibliography/documentation.json +1 -1
- package/dist/collection/components/mds-book/AGENTS.md +1 -1
- package/dist/collection/components/mds-book/documentation.json +1 -1
- package/dist/collection/components/mds-breadcrumb/AGENTS.md +1 -1
- package/dist/collection/components/mds-breadcrumb/documentation.json +1 -1
- package/dist/collection/components/mds-breadcrumb-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-breadcrumb-item/documentation.json +1 -1
- package/dist/collection/components/mds-button/AGENTS.md +1 -1
- package/dist/collection/components/mds-button/documentation.json +1 -1
- package/dist/collection/components/mds-button-dropdown/AGENTS.md +1 -1
- package/dist/collection/components/mds-button-dropdown/documentation.json +1 -1
- package/dist/collection/components/mds-button-group/AGENTS.md +1 -1
- package/dist/collection/components/mds-button-group/documentation.json +1 -1
- package/dist/collection/components/mds-calendar/AGENTS.md +1 -1
- package/dist/collection/components/mds-calendar/documentation.json +1 -1
- package/dist/collection/components/mds-calendar-cell/AGENTS.md +1 -1
- package/dist/collection/components/mds-calendar-cell/documentation.json +1 -1
- package/dist/collection/components/mds-card/AGENTS.md +1 -1
- package/dist/collection/components/mds-card/documentation.json +1 -1
- package/dist/collection/components/mds-card-content/AGENTS.md +1 -1
- package/dist/collection/components/mds-card-content/documentation.json +1 -1
- package/dist/collection/components/mds-card-footer/AGENTS.md +1 -1
- package/dist/collection/components/mds-card-footer/documentation.json +1 -1
- package/dist/collection/components/mds-card-header/AGENTS.md +1 -1
- package/dist/collection/components/mds-card-header/documentation.json +1 -1
- package/dist/collection/components/mds-card-media/AGENTS.md +1 -1
- package/dist/collection/components/mds-card-media/documentation.json +1 -1
- package/dist/collection/components/mds-chip/AGENTS.md +1 -1
- package/dist/collection/components/mds-chip/documentation.json +1 -1
- package/dist/collection/components/mds-details/AGENTS.md +1 -1
- package/dist/collection/components/mds-details/documentation.json +1 -1
- package/dist/collection/components/mds-dropdown/AGENTS.md +1 -1
- package/dist/collection/components/mds-dropdown/documentation.json +1 -1
- package/dist/collection/components/mds-emoji/AGENTS.md +1 -1
- package/dist/collection/components/mds-emoji/documentation.json +1 -1
- package/dist/collection/components/mds-entity/AGENTS.md +1 -1
- package/dist/collection/components/mds-entity/documentation.json +1 -1
- package/dist/collection/components/mds-file/AGENTS.md +1 -1
- package/dist/collection/components/mds-file/documentation.json +1 -1
- package/dist/collection/components/mds-file-preview/AGENTS.md +1 -1
- package/dist/collection/components/mds-file-preview/documentation.json +1 -1
- package/dist/collection/components/mds-filter/AGENTS.md +1 -1
- package/dist/collection/components/mds-filter/documentation.json +1 -1
- package/dist/collection/components/mds-filter-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-filter-item/documentation.json +1 -1
- package/dist/collection/components/mds-header/AGENTS.md +1 -1
- package/dist/collection/components/mds-header/documentation.json +1 -1
- package/dist/collection/components/mds-header-bar/AGENTS.md +1 -1
- package/dist/collection/components/mds-header-bar/documentation.json +1 -1
- package/dist/collection/components/mds-help/AGENTS.md +1 -1
- package/dist/collection/components/mds-help/documentation.json +1 -1
- package/dist/collection/components/mds-horizontal-scroll/AGENTS.md +1 -1
- package/dist/collection/components/mds-horizontal-scroll/documentation.json +1 -1
- package/dist/collection/components/mds-hr/AGENTS.md +1 -1
- package/dist/collection/components/mds-hr/documentation.json +1 -1
- package/dist/collection/components/mds-icon/AGENTS.md +1 -1
- package/dist/collection/components/mds-icon/documentation.json +1 -1
- package/dist/collection/components/mds-img/AGENTS.md +1 -1
- package/dist/collection/components/mds-img/documentation.json +1 -1
- package/dist/collection/components/mds-input/AGENTS.md +1 -1
- package/dist/collection/components/mds-input/documentation.json +1 -1
- package/dist/collection/components/mds-input-date/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-date/documentation.json +1 -1
- package/dist/collection/components/mds-input-date-range/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-date-range/documentation.json +1 -1
- package/dist/collection/components/mds-input-date-range-preselection/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-date-range-preselection/documentation.json +1 -1
- package/dist/collection/components/mds-input-field/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-field/documentation.json +1 -1
- package/dist/collection/components/mds-input-otp/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-otp/documentation.json +1 -1
- package/dist/collection/components/mds-input-range/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-range/documentation.json +1 -1
- package/dist/collection/components/mds-input-select/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-select/documentation.json +1 -1
- package/dist/collection/components/mds-input-switch/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-switch/documentation.json +1 -1
- package/dist/collection/components/mds-input-tip/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-tip/documentation.json +1 -1
- package/dist/collection/components/mds-input-tip-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-tip-item/documentation.json +1 -1
- package/dist/collection/components/mds-input-upload/AGENTS.md +1 -1
- package/dist/collection/components/mds-input-upload/documentation.json +1 -1
- package/dist/collection/components/mds-keyboard/AGENTS.md +1 -1
- package/dist/collection/components/mds-keyboard/documentation.json +1 -1
- package/dist/collection/components/mds-keyboard-key/AGENTS.md +1 -1
- package/dist/collection/components/mds-keyboard-key/documentation.json +1 -1
- package/dist/collection/components/mds-kpi/AGENTS.md +1 -1
- package/dist/collection/components/mds-kpi/documentation.json +1 -1
- package/dist/collection/components/mds-kpi-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-kpi-item/documentation.json +1 -1
- package/dist/collection/components/mds-label/AGENTS.md +1 -1
- package/dist/collection/components/mds-label/documentation.json +1 -1
- package/dist/collection/components/mds-link/AGENTS.md +1 -1
- package/dist/collection/components/mds-link/documentation.json +1 -1
- package/dist/collection/components/mds-list/AGENTS.md +1 -1
- package/dist/collection/components/mds-list/documentation.json +1 -1
- package/dist/collection/components/mds-list-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-list-item/documentation.json +1 -1
- package/dist/collection/components/mds-mention/AGENTS.md +1 -1
- package/dist/collection/components/mds-mention/documentation.json +1 -1
- package/dist/collection/components/mds-modal/AGENTS.md +1 -1
- package/dist/collection/components/mds-modal/documentation.json +1 -1
- package/dist/collection/components/mds-note/AGENTS.md +1 -1
- package/dist/collection/components/mds-note/documentation.json +1 -1
- package/dist/collection/components/mds-notification/AGENTS.md +1 -1
- package/dist/collection/components/mds-notification/documentation.json +1 -1
- package/dist/collection/components/mds-paginator/AGENTS.md +1 -1
- package/dist/collection/components/mds-paginator/documentation.json +1 -1
- package/dist/collection/components/mds-paginator-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-paginator-item/documentation.json +1 -1
- package/dist/collection/components/mds-policy-ai/AGENTS.md +1 -1
- package/dist/collection/components/mds-policy-ai/documentation.json +1 -1
- package/dist/collection/components/mds-pref/AGENTS.md +1 -1
- package/dist/collection/components/mds-pref/documentation.json +1 -1
- package/dist/collection/components/mds-pref-animation/AGENTS.md +1 -1
- package/dist/collection/components/mds-pref-animation/documentation.json +1 -1
- package/dist/collection/components/mds-pref-consumption/AGENTS.md +1 -1
- package/dist/collection/components/mds-pref-consumption/documentation.json +1 -1
- package/dist/collection/components/mds-pref-contrast/AGENTS.md +1 -1
- package/dist/collection/components/mds-pref-contrast/documentation.json +1 -1
- package/dist/collection/components/mds-pref-language/AGENTS.md +1 -1
- package/dist/collection/components/mds-pref-language/documentation.json +1 -1
- package/dist/collection/components/mds-pref-language-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-pref-language-item/documentation.json +1 -1
- package/dist/collection/components/mds-pref-mode/AGENTS.md +1 -1
- package/dist/collection/components/mds-pref-mode/documentation.json +1 -1
- package/dist/collection/components/mds-pref-theme/AGENTS.md +1 -1
- package/dist/collection/components/mds-pref-theme/documentation.json +1 -1
- package/dist/collection/components/mds-pref-theme-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-pref-theme-item/documentation.json +1 -1
- package/dist/collection/components/mds-price-table/AGENTS.md +1 -1
- package/dist/collection/components/mds-price-table/documentation.json +1 -1
- package/dist/collection/components/mds-price-table-features/AGENTS.md +1 -1
- package/dist/collection/components/mds-price-table-features/documentation.json +1 -1
- package/dist/collection/components/mds-price-table-features-cell/AGENTS.md +1 -1
- package/dist/collection/components/mds-price-table-features-cell/documentation.json +1 -1
- package/dist/collection/components/mds-price-table-features-row/AGENTS.md +1 -1
- package/dist/collection/components/mds-price-table-features-row/documentation.json +1 -1
- package/dist/collection/components/mds-price-table-header/AGENTS.md +1 -1
- package/dist/collection/components/mds-price-table-header/documentation.json +1 -1
- package/dist/collection/components/mds-price-table-list/AGENTS.md +1 -1
- package/dist/collection/components/mds-price-table-list/documentation.json +1 -1
- package/dist/collection/components/mds-price-table-list-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-price-table-list-item/documentation.json +1 -1
- package/dist/collection/components/mds-progress/AGENTS.md +1 -1
- package/dist/collection/components/mds-progress/documentation.json +1 -1
- package/dist/collection/components/mds-push-notification/AGENTS.md +1 -1
- package/dist/collection/components/mds-push-notification/documentation.json +1 -1
- package/dist/collection/components/mds-push-notification-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-push-notification-item/documentation.json +1 -1
- package/dist/collection/components/mds-quote/AGENTS.md +1 -1
- package/dist/collection/components/mds-quote/documentation.json +1 -1
- package/dist/collection/components/mds-radial-menu/AGENTS.md +1 -1
- package/dist/collection/components/mds-radial-menu/documentation.json +1 -1
- package/dist/collection/components/mds-radial-menu-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-radial-menu-item/documentation.json +1 -1
- package/dist/collection/components/mds-radial-progress/AGENTS.md +1 -1
- package/dist/collection/components/mds-radial-progress/documentation.json +1 -1
- package/dist/collection/components/mds-separator/AGENTS.md +1 -1
- package/dist/collection/components/mds-separator/documentation.json +1 -1
- package/dist/collection/components/mds-spinner/AGENTS.md +1 -1
- package/dist/collection/components/mds-spinner/documentation.json +1 -1
- package/dist/collection/components/mds-status-bar/AGENTS.md +1 -1
- package/dist/collection/components/mds-status-bar/documentation.json +1 -1
- package/dist/collection/components/mds-stepper-bar/AGENTS.md +1 -1
- package/dist/collection/components/mds-stepper-bar/documentation.json +1 -1
- package/dist/collection/components/mds-stepper-bar-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-stepper-bar-item/documentation.json +1 -1
- package/dist/collection/components/mds-tab/AGENTS.md +1 -1
- package/dist/collection/components/mds-tab/documentation.json +1 -1
- package/dist/collection/components/mds-tab-bar/AGENTS.md +1 -1
- package/dist/collection/components/mds-tab-bar/documentation.json +1 -1
- package/dist/collection/components/mds-tab-bar-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-tab-bar-item/documentation.json +1 -1
- package/dist/collection/components/mds-tab-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-tab-item/documentation.json +1 -1
- package/dist/collection/components/mds-table/AGENTS.md +1 -1
- package/dist/collection/components/mds-table/documentation.json +1 -1
- package/dist/collection/components/mds-table-body/AGENTS.md +1 -1
- package/dist/collection/components/mds-table-body/documentation.json +1 -1
- package/dist/collection/components/mds-table-cell/AGENTS.md +1 -1
- package/dist/collection/components/mds-table-cell/documentation.json +1 -1
- package/dist/collection/components/mds-table-footer/AGENTS.md +1 -1
- package/dist/collection/components/mds-table-footer/documentation.json +1 -1
- package/dist/collection/components/mds-table-header/AGENTS.md +1 -1
- package/dist/collection/components/mds-table-header/documentation.json +1 -1
- package/dist/collection/components/mds-table-header-cell/AGENTS.md +1 -1
- package/dist/collection/components/mds-table-header-cell/documentation.json +1 -1
- package/dist/collection/components/mds-table-row/AGENTS.md +1 -1
- package/dist/collection/components/mds-table-row/documentation.json +1 -1
- package/dist/collection/components/mds-text/AGENTS.md +1 -1
- package/dist/collection/components/mds-text/documentation.json +1 -1
- package/dist/collection/components/mds-toast/AGENTS.md +1 -1
- package/dist/collection/components/mds-toast/documentation.json +1 -1
- package/dist/collection/components/mds-toast-region/AGENTS.md +1 -1
- package/dist/collection/components/mds-toast-region/documentation.json +1 -1
- package/dist/collection/components/mds-tooltip/AGENTS.md +1 -1
- package/dist/collection/components/mds-tooltip/documentation.json +1 -1
- package/dist/collection/components/mds-tree/AGENTS.md +1 -1
- package/dist/collection/components/mds-tree/documentation.json +1 -1
- package/dist/collection/components/mds-tree-item/AGENTS.md +1 -1
- package/dist/collection/components/mds-tree-item/documentation.json +1 -1
- package/dist/collection/components/mds-url-view/AGENTS.md +1 -1
- package/dist/collection/components/mds-url-view/documentation.json +1 -1
- package/dist/collection/components/mds-usage/AGENTS.md +1 -1
- package/dist/collection/components/mds-usage/documentation.json +1 -1
- package/dist/collection/components/mds-video-wall/AGENTS.md +1 -1
- package/dist/collection/components/mds-video-wall/documentation.json +1 -1
- package/dist/collection/components/mds-zero/AGENTS.md +1 -1
- package/dist/collection/components/mds-zero/documentation.json +1 -1
- package/dist/documentation.json +1 -1
- package/dist/lint/core/checks.d.ts +16 -2
- package/dist/lint/core/checks.js +32 -24
- package/dist/lint/core/data.d.ts +8 -0
- package/dist/lint/core/data.js +15 -0
- package/dist/lint/core/element.d.ts +1 -1
- package/dist/lint/eslint/adapters.d.ts +2 -0
- package/dist/lint/eslint/adapters.js +50 -13
- package/dist/lint/eslint/index.js +5 -4
- package/dist/lint/mcp/checks.js +60 -24
- package/dist/lint/mcp/components.js +7 -7
- package/dist/lint/mcp/context.d.ts +11 -0
- package/dist/lint/mcp/context.js +11 -0
- package/dist/lint/mcp/icons.js +46 -20
- package/dist/lint/mcp/protocol.d.ts +17 -0
- package/dist/lint/mcp/protocol.js +15 -10
- package/dist/lint/mcp/server.d.ts +17 -0
- package/dist/lint/mcp/server.js +7 -1
- package/dist/lint/mcp/tokens.d.ts +15 -0
- package/dist/lint/mcp/tokens.js +170 -48
- package/dist/lint/mcp/tools.json +962 -0
- package/dist/lint/stylelint/index.js +80 -14
- package/dist/lint/stylelint/recommended.js +1 -0
- package/dist/lint/stylelint/strict.js +1 -0
- package/dist/stats.json +1 -1
- package/package.json +2 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# mds-url-view
|
|
8
8
|
|
|
9
|
-
> `@maggioli-design-system/magma` 2.
|
|
9
|
+
> `@maggioli-design-system/magma` 2.7.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.
|
|
10
10
|
|
|
11
11
|
The `<mds-url-view>` web component renders an embedded preview of an external web page inside a framed browser-like window, wrapping a native `<iframe>` with a titled header, an identifying icon, and a dismiss control. It is the Magma way to surface remote content (typically inside a `mds-modal`) without hand-building chrome around the raw iframe.
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# mds-usage
|
|
8
8
|
|
|
9
|
-
> `@maggioli-design-system/magma` 2.
|
|
9
|
+
> `@maggioli-design-system/magma` 2.7.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.
|
|
10
10
|
|
|
11
11
|
The `<mds-usage>` web component is a documentation-oriented annotation block of the Magma Design System used to frame example content as a recommendation, a warning, or an informational note. It wraps slotted content in a labelled, status-colored container and has no native HTML primitive equivalent - it is a presentational guidance device, typically used inside design-system docs and Storybook.
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# mds-video-wall
|
|
8
8
|
|
|
9
|
-
> `@maggioli-design-system/magma` 2.
|
|
9
|
+
> `@maggioli-design-system/magma` 2.7.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.
|
|
10
10
|
|
|
11
11
|
The `<mds-video-wall>` web component is the Magma Design System's full-bleed background video surface, used to render an autoplaying, looping ambient video behind foreground content. It wraps the native `<video>` element, adding an optional grain/noise overlay and a dedicated content layer for captions or call-to-action overlays.
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# mds-zero
|
|
8
8
|
|
|
9
|
-
> `@maggioli-design-system/magma` 2.
|
|
9
|
+
> `@maggioli-design-system/magma` 2.7.0. Shadow DOM: style it only through the public CSS custom properties and the parts below.
|
|
10
10
|
|
|
11
11
|
The `<mds-zero>` web component is the empty-state (zero-data) panel of the Magma Design System: a centered, vertically stacked layout that pairs an illustration, explanatory copy, and a call-to-action to guide users when a list, search, or section has no content to show. It is a pure structural container with no props - composition happens entirely through its slots.
|
|
12
12
|
|
package/dist/documentation.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentInfo, PaletteInfo, StyleInfo } from './data.js';
|
|
2
|
-
import { type Finding, type LintElement } from './element.js';
|
|
2
|
+
import { type Finding, type LintCustomProperty, type LintElement } from './element.js';
|
|
3
3
|
/** `<mds-banner tone="outline">`: a value outside the closed union of the prop. */
|
|
4
4
|
export declare const validAttributeValues: (element: LintElement, component: ComponentInfo) => Finding[];
|
|
5
5
|
/** `disabled="false"`: the attribute is there, so the boolean is not reliably off. */
|
|
@@ -15,6 +15,11 @@ export declare const noFalseBoolean: (element: LintElement, component: Component
|
|
|
15
15
|
export declare const accessibleName: (element: LintElement, component: ComponentInfo) => Finding[];
|
|
16
16
|
/** `dark:hover:!bg-white/50` -> `bg-white`: no variants, no important, no opacity. */
|
|
17
17
|
export declare const utilityOf: (name: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* What is wrong with the class `name`, undefined when it does not paint with a raw palette.
|
|
20
|
+
* Shared by the ESLint and the Stylelint rule.
|
|
21
|
+
*/
|
|
22
|
+
export declare const rawPaletteMessage: (name: string, palette: PaletteInfo) => string | undefined;
|
|
18
23
|
/** A colour class that paints the interface with a raw palette instead of a role. */
|
|
19
24
|
export declare const noRawPaletteClasses: (element: LintElement, palette: PaletteInfo) => Finding[];
|
|
20
25
|
/**
|
|
@@ -22,5 +27,14 @@ export declare const noRawPaletteClasses: (element: LintElement, palette: Palett
|
|
|
22
27
|
* component promises it. Shared by the ESLint and the Stylelint rule.
|
|
23
28
|
*/
|
|
24
29
|
export declare const internalTokenMessage: (name: string, style: StyleInfo | undefined) => string | undefined;
|
|
25
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* The `--mds-*` names a class sets or reads through Tailwind, read through its variants and
|
|
32
|
+
* `!` as `utilityOf` reads them: an arbitrary property (`dark:[--mds-x:red]`, also on a parent
|
|
33
|
+
* that sets it for its descendants) or an arbitrary value (`bg-[var(--mds-x)]`, `bg-(--mds-x)`).
|
|
34
|
+
*/
|
|
35
|
+
export declare const classCustomPropertiesOf: (element: LintElement) => LintCustomProperty[];
|
|
36
|
+
/**
|
|
37
|
+
* `style="--mds-chip-icon-color: ..."`, `class="[--mds-chip-icon-color:red]"`: an `--mds-*`
|
|
38
|
+
* that no component promises, in every form the template writes one.
|
|
39
|
+
*/
|
|
26
40
|
export declare const noInternalTokens: (element: LintElement, styles: Map<string, StyleInfo>) => Finding[];
|
package/dist/lint/core/checks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { attributeOf, isSet } from './element.js';
|
|
1
|
+
import { attributeOf, customPropertiesOf, isSet, } from './element.js';
|
|
2
2
|
/** `<mds-banner tone="outline">`: a value outside the closed union of the prop. */
|
|
3
3
|
export const validAttributeValues = (element, component) => {
|
|
4
4
|
const found = [];
|
|
@@ -94,28 +94,27 @@ export const utilityOf = (name) => {
|
|
|
94
94
|
.replace(/^!|!$/g, '')
|
|
95
95
|
.replace(/\/[\w.[\]()%-]+$/, '');
|
|
96
96
|
};
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
found.push({
|
|
113
|
-
node,
|
|
114
|
-
message: `${name} paints with Tailwind's palette, which ignores Magma's mode, themes and contrast: use a role (bg-surface-*, text-fg-*, border-border-*), see agents/color.md.`,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
return found;
|
|
97
|
+
/**
|
|
98
|
+
* What is wrong with the class `name`, undefined when it does not paint with a raw palette.
|
|
99
|
+
* Shared by the ESLint and the Stylelint rule.
|
|
100
|
+
*/
|
|
101
|
+
export const rawPaletteMessage = (name, palette) => {
|
|
102
|
+
const utility = utilityOf(name);
|
|
103
|
+
const root = palette.colorUtilities.find((one) => utility.startsWith(`${one}-`));
|
|
104
|
+
if (!root)
|
|
105
|
+
return undefined;
|
|
106
|
+
const key = utility.slice(root.length + 1);
|
|
107
|
+
if (palette.rawKeys.has(key))
|
|
108
|
+
return `${name} paints with a raw Magma step, which follows the mode only: use a role (bg-surface-*, text-fg-*, border-border-*), see agents/color.md; label-* and brand-* are for colour that encodes data.`;
|
|
109
|
+
if (TAILWIND_PALETTE.test(key))
|
|
110
|
+
return `${name} paints with Tailwind's palette, which ignores Magma's mode, themes and contrast: use a role (bg-surface-*, text-fg-*, border-border-*), see agents/color.md.`;
|
|
111
|
+
return undefined;
|
|
118
112
|
};
|
|
113
|
+
/** A colour class that paints the interface with a raw palette instead of a role. */
|
|
114
|
+
export const noRawPaletteClasses = (element, palette) => element.classes.flatMap(({ name, node }) => {
|
|
115
|
+
const message = rawPaletteMessage(name, palette);
|
|
116
|
+
return message ? [{ node, message }] : [];
|
|
117
|
+
});
|
|
119
118
|
/**
|
|
120
119
|
* What is wrong with setting or reading the custom property `name`, undefined when a
|
|
121
120
|
* component promises it. Shared by the ESLint and the Stylelint rule.
|
|
@@ -128,8 +127,17 @@ export const internalTokenMessage = (name, style) => {
|
|
|
128
127
|
? `"${name}" is an internal custom property of ${style.tags.map((tag) => `<${tag}>`).join(', ')}: it may change in any release. Instead, ${instead}.`
|
|
129
128
|
: `"${name}" is not a custom property any Magma component promises: ${instead}.`;
|
|
130
129
|
};
|
|
131
|
-
/**
|
|
132
|
-
|
|
130
|
+
/**
|
|
131
|
+
* The `--mds-*` names a class sets or reads through Tailwind, read through its variants and
|
|
132
|
+
* `!` as `utilityOf` reads them: an arbitrary property (`dark:[--mds-x:red]`, also on a parent
|
|
133
|
+
* that sets it for its descendants) or an arbitrary value (`bg-[var(--mds-x)]`, `bg-(--mds-x)`).
|
|
134
|
+
*/
|
|
135
|
+
export const classCustomPropertiesOf = (element) => element.classes.flatMap(({ name, node }) => customPropertiesOf(utilityOf(name), node));
|
|
136
|
+
/**
|
|
137
|
+
* `style="--mds-chip-icon-color: ..."`, `class="[--mds-chip-icon-color:red]"`: an `--mds-*`
|
|
138
|
+
* that no component promises, in every form the template writes one.
|
|
139
|
+
*/
|
|
140
|
+
export const noInternalTokens = (element, styles) => [...element.customProperties, ...classCustomPropertiesOf(element)].flatMap(({ name, node }) => {
|
|
133
141
|
const message = internalTokenMessage(name, styles.get(name));
|
|
134
142
|
return message ? [{ node, message }] : [];
|
|
135
143
|
});
|
package/dist/lint/core/data.d.ts
CHANGED
|
@@ -54,6 +54,14 @@ declare const PACKAGE: {
|
|
|
54
54
|
* dependencies, when they ship inside it); else resolved from the root, the linted project.
|
|
55
55
|
*/
|
|
56
56
|
export declare const locate: (kind: keyof typeof PACKAGE, settings?: MagmaSettings) => string;
|
|
57
|
+
/** The version of the magma these rules ship in; undefined in the sources of the repository. */
|
|
58
|
+
export declare const shippedVersion: () => string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* A section of the lint guide at the release these rules ship in, its tag `magma@<version>`:
|
|
61
|
+
* a project on an older version reads the rule it runs, not the one on main. Main only from
|
|
62
|
+
* the sources, which belong to no release.
|
|
63
|
+
*/
|
|
64
|
+
export declare const lintGuideUrl: (anchor: string, version?: string | undefined) => string;
|
|
57
65
|
/** A data file as it is, parsed once per process: for the tools that need more than the rules. */
|
|
58
66
|
export declare const readData: <T = unknown>(kind: keyof typeof PACKAGE, settings?: MagmaSettings) => T;
|
|
59
67
|
/** The root of the installed magma package: two folders above its dist/documentation.json. */
|
package/dist/lint/core/data.js
CHANGED
|
@@ -56,6 +56,21 @@ export const locate = (kind, settings = {}) => {
|
|
|
56
56
|
return found;
|
|
57
57
|
throw new Error(`The Magma lint reads ${PACKAGE[kind]} from the installed packages and could not find it from ${root}: install @maggioli-design-system/magma, or set its path in the "${kind}" setting.`);
|
|
58
58
|
};
|
|
59
|
+
/** Inside magma this module is dist/lint/core/data.js: the manifest of magma is three folders up. */
|
|
60
|
+
const OWN_MANIFEST = path.resolve(path.dirname(HERE), '../../../package.json');
|
|
61
|
+
/** The version of the magma these rules ship in; undefined in the sources of the repository. */
|
|
62
|
+
export const shippedVersion = () => {
|
|
63
|
+
if (!existsSync(OWN_MANIFEST))
|
|
64
|
+
return undefined;
|
|
65
|
+
const { name, version } = JSON.parse(readFileSync(OWN_MANIFEST, 'utf8'));
|
|
66
|
+
return name === '@maggioli-design-system/magma' ? version : undefined;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A section of the lint guide at the release these rules ship in, its tag `magma@<version>`:
|
|
70
|
+
* a project on an older version reads the rule it runs, not the one on main. Main only from
|
|
71
|
+
* the sources, which belong to no release.
|
|
72
|
+
*/
|
|
73
|
+
export const lintGuideUrl = (anchor, version = shippedVersion()) => `https://github.com/magma-design-system/magma/blob/${version ? `magma@${version}` : 'main'}/docs/agents/lint.md#${anchor}`;
|
|
59
74
|
const cache = new Map();
|
|
60
75
|
/** What `build` makes of a JSON file, once per `key` (the file, and what else it depends on). */
|
|
61
76
|
const readJson = (file, build, key = file) => {
|
|
@@ -19,7 +19,7 @@ export interface LintAttribute {
|
|
|
19
19
|
export interface LintClass {
|
|
20
20
|
/** One class, as written (`dark:bg-white/50`). */
|
|
21
21
|
name: string;
|
|
22
|
-
/** What to report on: the attribute that holds it. */
|
|
22
|
+
/** What to report on: the attribute or binding that holds it, in JSX the literal. */
|
|
23
23
|
node: unknown;
|
|
24
24
|
}
|
|
25
25
|
export interface LintCustomProperty {
|
|
@@ -37,11 +37,13 @@ export declare const fromJsx: (node: JsxNode) => LintElement | undefined;
|
|
|
37
37
|
interface AngularNode {
|
|
38
38
|
type: string;
|
|
39
39
|
name?: string;
|
|
40
|
+
/** A static value, or the expression of a binding, its AST and its text as written. */
|
|
40
41
|
value?: string | {
|
|
41
42
|
ast?: {
|
|
42
43
|
type: string;
|
|
43
44
|
value?: unknown;
|
|
44
45
|
};
|
|
46
|
+
source?: string;
|
|
45
47
|
};
|
|
46
48
|
attributes?: AngularNode[];
|
|
47
49
|
inputs?: AngularNode[];
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
- Angular: the `Element` of @angular-eslint/template-parser, static attributes, property
|
|
7
7
|
bindings (`[disabled]`), attribute bindings (`[attr.disabled]`) and style bindings
|
|
8
8
|
(`[style.--mds-x]`, for the custom properties).
|
|
9
|
+
The classes are read where the codemod reads them (projects/codemod/src/surfaces): the
|
|
10
|
+
static `class`; in JSX, every string and template literal of a `className` or `class`
|
|
11
|
+
expression (react.ts); in Angular, the key of `[class.x]` and the quoted strings of
|
|
12
|
+
`[ngClass]`, `[class]` and `[attr.class]` (angular.ts).
|
|
9
13
|
The nodes are typed by what the adapters read: the parsers are optional peers of the
|
|
10
14
|
consumer, not dependencies of this package.
|
|
11
15
|
*/
|
|
@@ -81,18 +85,34 @@ const jsxValue = (value) => {
|
|
|
81
85
|
return expression.quasis?.[0]?.value.cooked ?? undefined;
|
|
82
86
|
return undefined;
|
|
83
87
|
};
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
/**
|
|
89
|
+
* The classes of a `className` or `class` value, each on the literal that holds it: every
|
|
90
|
+
* string literal anywhere in the expression, as the codemod rewrites them (`clsx()` and
|
|
91
|
+
* `classnames()` arguments and object keys, both branches of a ternary, a `||` fallback),
|
|
92
|
+
* and the fixed parts of every template literal. A string compared in a condition is read
|
|
93
|
+
* too, as the codemod reads it: it is reported only when it is itself a class the rule
|
|
94
|
+
* rejects.
|
|
95
|
+
*/
|
|
96
|
+
const jsxClasses = (value) => {
|
|
97
|
+
const found = [];
|
|
98
|
+
const walk = (node) => {
|
|
99
|
+
if (Array.isArray(node)) {
|
|
100
|
+
node.forEach(walk);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (!node || typeof node !== 'object' || typeof node.type !== 'string')
|
|
104
|
+
return;
|
|
105
|
+
const current = node;
|
|
106
|
+
if (current.type === 'Literal' && typeof current.value === 'string')
|
|
107
|
+
found.push(...classesOf(current.value, current));
|
|
108
|
+
if (current.type === 'TemplateLiteral')
|
|
109
|
+
found.push(...classesOf((current.quasis ?? []).map((quasi) => quasi.value.cooked ?? '').join(' '), current));
|
|
110
|
+
for (const [key, child] of Object.entries(current))
|
|
111
|
+
if (key !== 'parent')
|
|
112
|
+
walk(child);
|
|
113
|
+
};
|
|
114
|
+
walk(value);
|
|
115
|
+
return found;
|
|
96
116
|
};
|
|
97
117
|
const jsxContent = (element) => (element?.children ?? []).some((child) => {
|
|
98
118
|
if (child.type === 'JSXText')
|
|
@@ -144,7 +164,7 @@ export const fromJsx = (node) => {
|
|
|
144
164
|
const value = attribute.value;
|
|
145
165
|
attributes.push({ name: key, binding: 'property', value: jsxValue(value), node: attribute });
|
|
146
166
|
if (key === 'className' || key === 'class')
|
|
147
|
-
classes.push(...
|
|
167
|
+
classes.push(...jsxClasses(value));
|
|
148
168
|
if (key === 'style')
|
|
149
169
|
customProperties.push(...jsxCustomProperties(value, attribute));
|
|
150
170
|
}
|
|
@@ -172,6 +192,17 @@ const angularValue = (input) => {
|
|
|
172
192
|
const ast = typeof input.value === 'object' ? input.value.ast : undefined;
|
|
173
193
|
return ast?.type === 'LiteralPrimitive' ? ast.value : undefined;
|
|
174
194
|
};
|
|
195
|
+
/** A quoted string of a bound expression, matched as the codemod matches it (angular.ts). */
|
|
196
|
+
const QUOTED = /(['"`])((?:\\.|(?!\1)[^\\])*)\1/g;
|
|
197
|
+
/**
|
|
198
|
+
* The classes of `[ngClass]`, `[class]` and `[attr.class]`: the quoted strings of the
|
|
199
|
+
* expression, as the codemod reads them (object keys, array items, both branches of a
|
|
200
|
+
* ternary). An unquoted `[ngClass]` key is a single word, never a class the rules reject.
|
|
201
|
+
*/
|
|
202
|
+
const angularClasses = (input) => {
|
|
203
|
+
const source = typeof input.value === 'object' ? (input.value.source ?? '') : '';
|
|
204
|
+
return [...source.matchAll(QUOTED)].flatMap(([, , text]) => classesOf(text ?? '', input));
|
|
205
|
+
};
|
|
175
206
|
export const fromAngular = (node) => {
|
|
176
207
|
if (!node.name)
|
|
177
208
|
return undefined;
|
|
@@ -195,9 +226,15 @@ export const fromAngular = (node) => {
|
|
|
195
226
|
// [style.--mds-x] sets a custom property; the parser writes its name as --%NS%mds-x
|
|
196
227
|
if (kind === 3)
|
|
197
228
|
customProperties.push(...customPropertiesOf(input.name.replace('%NS%', ''), input));
|
|
229
|
+
// [class.bg-white]="on" toggles the class of its key
|
|
230
|
+
if (kind === 2)
|
|
231
|
+
classes.push(...classesOf(input.name, input));
|
|
198
232
|
// [class.x] and [style.x] bind a class or a style, not the prop of the same name
|
|
199
233
|
if (kind === 2 || kind === 3)
|
|
200
234
|
continue;
|
|
235
|
+
// [ngClass] and [class] are property bindings, [attr.class] an attribute binding
|
|
236
|
+
if ((kind === 0 && input.name === 'ngClass') || input.name === 'class')
|
|
237
|
+
classes.push(...angularClasses(input));
|
|
201
238
|
attributes.push({
|
|
202
239
|
name: input.name,
|
|
203
240
|
binding: kind === 1 ? 'attribute' : 'property',
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
elsewhere: { root, documentation, tokens, consumption }.
|
|
11
11
|
*/
|
|
12
12
|
import path from 'node:path';
|
|
13
|
-
import { loadComponents, loadPalette, loadStyles, } from '../core/data.js';
|
|
13
|
+
import { lintGuideUrl, loadComponents, loadPalette, loadStyles, } from '../core/data.js';
|
|
14
14
|
import { accessibleName, noFalseBoolean, noInternalTokens, noRawPaletteClasses, validAttributeValues, } from '../core/checks.js';
|
|
15
15
|
import { fromAngular, fromHtml, fromJsx } from './adapters.js';
|
|
16
|
-
const DOCS = 'https://github.com/magma-design-system/magma/blob/main/docs/agents/lint.md';
|
|
17
16
|
/** A check that applies to the Magma components only. */
|
|
18
17
|
const onComponents = (check) => (element, data) => {
|
|
19
18
|
if (!element.tag.startsWith('mds-'))
|
|
@@ -24,7 +23,7 @@ const onComponents = (check) => (element, data) => {
|
|
|
24
23
|
const createRule = (name, description, check) => ({
|
|
25
24
|
meta: {
|
|
26
25
|
type: 'problem',
|
|
27
|
-
docs: { description, url:
|
|
26
|
+
docs: { description, url: lintGuideUrl(name) },
|
|
28
27
|
schema: [],
|
|
29
28
|
},
|
|
30
29
|
create(context) {
|
|
@@ -54,7 +53,9 @@ const rules = {
|
|
|
54
53
|
'no-false-boolean': createRule('no-false-boolean', 'A boolean prop is turned off by removing its attribute, never with "false".', onComponents(noFalseBoolean)),
|
|
55
54
|
'accessible-name': createRule('accessible-name', 'An icon-only Magma control has a label or an aria-label, a Magma image an alt.', onComponents(accessibleName)),
|
|
56
55
|
'no-raw-palette-classes': createRule('no-raw-palette-classes', "Colour classes name a role, not Tailwind's palette or a raw Magma step.", (element, data) => (element.classes.length ? noRawPaletteClasses(element, data.palette()) : [])),
|
|
57
|
-
'no-internal-tokens': createRule('no-internal-tokens', 'An inline style sets or reads only the custom properties a Magma component promises.', (element, data) => element.customProperties.length
|
|
56
|
+
'no-internal-tokens': createRule('no-internal-tokens', 'An inline style or a Tailwind class sets or reads only the custom properties a Magma component promises.', (element, data) => element.customProperties.length || element.classes.some(({ name }) => name.includes('--mds-'))
|
|
57
|
+
? noInternalTokens(element, data.styles())
|
|
58
|
+
: []),
|
|
58
59
|
};
|
|
59
60
|
const plugin = {
|
|
60
61
|
meta: { name: '@maggioli-design-system/magma/eslint' },
|
package/dist/lint/mcp/checks.js
CHANGED
|
@@ -37,18 +37,20 @@ const TEMPLATES = {
|
|
|
37
37
|
jsx: { file: 'snippet.jsx' },
|
|
38
38
|
tsx: { parser: '@typescript-eslint/parser', file: 'snippet.tsx' },
|
|
39
39
|
};
|
|
40
|
-
/**
|
|
41
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The Stylelint rules that read the installed data, and the settings that point each at it:
|
|
42
|
+
* the secondary options it takes (../stylelint/index.ts).
|
|
43
|
+
*/
|
|
44
|
+
const DATA_RULES = {
|
|
45
|
+
'magma/no-internal-tokens': ['root', 'documentation'],
|
|
46
|
+
'magma/no-raw-color': ['root', 'documentation'],
|
|
47
|
+
'magma/no-raw-palette-classes': ['root', 'tokens', 'consumption'],
|
|
48
|
+
};
|
|
42
49
|
/** A Stylelint config whose data rules read the data of the context, as the ESLint rules read `settings.magma`. */
|
|
43
50
|
const withData = (config, settings) => {
|
|
44
|
-
const data = {
|
|
45
|
-
...(settings.root ? { root: settings.root } : {}),
|
|
46
|
-
...(settings.documentation ? { documentation: settings.documentation } : {}),
|
|
47
|
-
};
|
|
48
|
-
if (!Object.keys(data).length)
|
|
49
|
-
return config;
|
|
50
51
|
const rules = Object.fromEntries(Object.entries((config.rules ?? {})).map(([name, value]) => {
|
|
51
|
-
|
|
52
|
+
const data = Object.fromEntries((DATA_RULES[name] ?? []).flatMap((key) => (settings[key] ? [[key, settings[key]]] : [])));
|
|
53
|
+
if (!Object.keys(data).length)
|
|
52
54
|
return [name, value];
|
|
53
55
|
const [primary, secondary] = Array.isArray(value) ? value : [value, {}];
|
|
54
56
|
return [name, [primary, { ...secondary, ...data }]];
|
|
@@ -58,7 +60,7 @@ const withData = (config, settings) => {
|
|
|
58
60
|
export const checkMarkup = (context) => ({
|
|
59
61
|
name: 'check_markup',
|
|
60
62
|
title: 'Check a snippet with the Magma lint',
|
|
61
|
-
description: 'Run the Magma lint on a snippet before writing it: prop values outside their union, "false" booleans, icon-only controls without a name, raw palette classes (templates), raw colours and prefers-color-scheme queries (CSS). Uses the ESLint, Stylelint and parsers the project installed; strict preset by default, so every finding is shown.',
|
|
63
|
+
description: 'Run the Magma lint on a snippet before writing it: prop values outside their union, "false" booleans, icon-only controls without a name, raw palette classes (templates and @apply), raw colours and prefers-color-scheme queries (CSS). Uses the ESLint, Stylelint and parsers the project installed; strict preset by default, so every finding is shown.',
|
|
62
64
|
inputSchema: {
|
|
63
65
|
type: 'object',
|
|
64
66
|
properties: {
|
|
@@ -215,6 +217,40 @@ const sourceFiles = (root, limit = 3000) => {
|
|
|
215
217
|
return found;
|
|
216
218
|
};
|
|
217
219
|
const firstExisting = (root, names) => names.map((name) => path.join(root, name)).find((file) => existsSync(file));
|
|
220
|
+
/**
|
|
221
|
+
* How a project tells mds-icon where the icons are: the ways IconsSetService reads the path
|
|
222
|
+
* (agents/assets.md, "Tell mds-icon where the icons are"; mds-icon, 2. Pattern.md), that is
|
|
223
|
+
* setSvgPath() of IconsSetService or of an mds-icon, and the mdsIconSvgPath key of
|
|
224
|
+
* sessionStorage. Any other mention of the name (`window.mdsIconSvgPath = ...`) is read by no one.
|
|
225
|
+
*/
|
|
226
|
+
const ICON_PATH_SETTERS = [
|
|
227
|
+
/\bsetSvgPath\s*\(/,
|
|
228
|
+
/sessionStorage\s*\.\s*setItem\s*\(\s*['"`]mdsIconSvgPath['"`]/,
|
|
229
|
+
];
|
|
230
|
+
/**
|
|
231
|
+
* The configuration files each tool loads, in the order it looks for them: ESLint 9
|
|
232
|
+
* (`FLAT_CONFIG_FILENAMES` of eslint/lib/config/config-loader.js), Stylelint 16 (the default
|
|
233
|
+
* search places of cosmiconfig 9, after the `stylelint` key of package.json). A project that
|
|
234
|
+
* extends the preset from any of them is set up: a check that knows fewer would send the agent
|
|
235
|
+
* to write a second one.
|
|
236
|
+
*/
|
|
237
|
+
const ESLINT_CONFIGS = [
|
|
238
|
+
'eslint.config.js',
|
|
239
|
+
'eslint.config.mjs',
|
|
240
|
+
'eslint.config.cjs',
|
|
241
|
+
'eslint.config.ts',
|
|
242
|
+
'eslint.config.mts',
|
|
243
|
+
'eslint.config.cts',
|
|
244
|
+
];
|
|
245
|
+
const RC_EXTENSIONS = ['', '.json', '.yaml', '.yml', '.js', '.ts', '.cjs', '.mjs'];
|
|
246
|
+
const STYLELINT_CONFIGS = [
|
|
247
|
+
...RC_EXTENSIONS.map((extension) => `.stylelintrc${extension}`),
|
|
248
|
+
...RC_EXTENSIONS.map((extension) => `.config/stylelintrc${extension}`),
|
|
249
|
+
'stylelint.config.js',
|
|
250
|
+
'stylelint.config.ts',
|
|
251
|
+
'stylelint.config.cjs',
|
|
252
|
+
'stylelint.config.mjs',
|
|
253
|
+
];
|
|
218
254
|
/** The Magma plugin is enabled in these Claude Code settings (`enabledPlugins`, `magma@magma`). */
|
|
219
255
|
export const pluginEnabled = (file) => readJsonFile(file)?.enabledPlugins?.['magma@magma'] === true;
|
|
220
256
|
/**
|
|
@@ -342,22 +378,26 @@ export const checkSetup = (context) => ({
|
|
|
342
378
|
: 'No icon set and no iconsauce configuration: mds-icon renders nothing.',
|
|
343
379
|
guide: 'agents/assets.md (Icons)',
|
|
344
380
|
});
|
|
345
|
-
const sources = sourceFiles(root);
|
|
346
|
-
const
|
|
381
|
+
const sources = sourceFiles(root).map((file) => ({ file, text: readFileSync(file, 'utf8') }));
|
|
382
|
+
const setter = sources.find(({ text }) => ICON_PATH_SETTERS.some((one) => one.test(text)));
|
|
383
|
+
const stray = sources.find(({ text }) => text.includes('mdsIconSvgPath'));
|
|
347
384
|
checks.push({
|
|
348
385
|
id: 'icon-path',
|
|
349
|
-
ok:
|
|
350
|
-
detail:
|
|
351
|
-
?
|
|
352
|
-
:
|
|
386
|
+
ok: Boolean(setter),
|
|
387
|
+
detail: setter
|
|
388
|
+
? `${path.relative(root, setter.file)} sets the icon path.`
|
|
389
|
+
: stray
|
|
390
|
+
? `${path.relative(root, stray.file)} names mdsIconSvgPath, but mds-icon reads the path only from IconsSetService.setSvgPath() and from sessionStorage.setItem('mdsIconSvgPath', ...).`
|
|
391
|
+
: 'Nothing in the sources sets the icon path: mds-icon does not know where the icons are. Call IconsSetService.setSvgPath() from @maggioli-design-system/magma/services before the first mds-icon renders.',
|
|
353
392
|
guide: 'agents/assets.md (Tell mds-icon where the icons are)',
|
|
354
393
|
});
|
|
355
394
|
// the lint, and this server
|
|
395
|
+
// the file the tool loads, the first it finds, has to name the preset
|
|
356
396
|
const mentions = (names, text) => {
|
|
357
397
|
const file = firstExisting(root, names);
|
|
358
398
|
return Boolean(file && readFileSync(file, 'utf8').includes(text));
|
|
359
399
|
};
|
|
360
|
-
const eslintOk = mentions(
|
|
400
|
+
const eslintOk = mentions(ESLINT_CONFIGS, '@maggioli-design-system/magma/eslint');
|
|
361
401
|
checks.push({
|
|
362
402
|
id: 'lint-eslint',
|
|
363
403
|
ok: eslintOk,
|
|
@@ -366,13 +406,9 @@ export const checkSetup = (context) => ({
|
|
|
366
406
|
: 'The ESLint configuration does not load @maggioli-design-system/magma/eslint.',
|
|
367
407
|
guide: 'agents/lint.md',
|
|
368
408
|
});
|
|
369
|
-
const stylelintOk =
|
|
370
|
-
|
|
371
|
-
'stylelint
|
|
372
|
-
'stylelint.config.cjs',
|
|
373
|
-
'.stylelintrc.json',
|
|
374
|
-
'.stylelintrc',
|
|
375
|
-
], '@maggioli-design-system/magma/stylelint');
|
|
409
|
+
const stylelintOk = project.stylelint !== undefined
|
|
410
|
+
? JSON.stringify(project.stylelint).includes('@maggioli-design-system/magma/stylelint')
|
|
411
|
+
: mentions(STYLELINT_CONFIGS, '@maggioli-design-system/magma/stylelint');
|
|
376
412
|
checks.push({
|
|
377
413
|
id: 'lint-stylelint',
|
|
378
414
|
ok: stylelintOk,
|
|
@@ -7,7 +7,7 @@ import path from 'node:path';
|
|
|
7
7
|
import { magmaRoot, propInfo, readData } from '../core/data.js';
|
|
8
8
|
import { tagOf } from '../core/element.js';
|
|
9
9
|
import { ToolError } from './protocol.js';
|
|
10
|
-
import { firstSentence, pascalOf, wordsOf } from './context.js';
|
|
10
|
+
import { firstSentence, GAP, GAP_SCHEMA, pascalOf, wordsOf } from './context.js';
|
|
11
11
|
const componentsOf = (context) => readData('documentation', context.settings).components;
|
|
12
12
|
const summaryOf = (component) => firstSentence(component.usage?.['1. Description'] || component.docs);
|
|
13
13
|
/** The component of a tag or of a React or Angular class name; a tool error, with the near ones, when there is none. */
|
|
@@ -50,6 +50,7 @@ export const findComponent = (context) => ({
|
|
|
50
50
|
required: ['tag', 'summary', 'score'],
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
|
+
gap: GAP_SCHEMA,
|
|
53
54
|
},
|
|
54
55
|
required: ['components'],
|
|
55
56
|
},
|
|
@@ -67,12 +68,11 @@ export const findComponent = (context) => ({
|
|
|
67
68
|
(text.includes(word) ? 1 : 0), 0);
|
|
68
69
|
return { tag: component.tag, summary: summaryOf(component), score };
|
|
69
70
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
71
|
+
const components = scored
|
|
72
|
+
.filter(({ score }) => score > 0)
|
|
73
|
+
.sort((a, b) => b.score - a.score || a.tag.localeCompare(b.tag))
|
|
74
|
+
.slice(0, typeof limit === 'number' && limit > 0 ? limit : 8);
|
|
75
|
+
return { components, ...(components.length ? {} : { gap: GAP }) };
|
|
76
76
|
},
|
|
77
77
|
});
|
|
78
78
|
/** The literal values of a prop, when its type is a closed union. */
|
|
@@ -23,3 +23,14 @@ export declare const wordsOf: (text: string) => string[];
|
|
|
23
23
|
export declare const pascalOf: (tag: string) => string;
|
|
24
24
|
/** The first sentence of a markdown text, without links, headings or tables. */
|
|
25
25
|
export declare const firstSentence: (markdown?: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* What an answer adds when the installed Magma has nothing for a well-formed question (a
|
|
28
|
+
* search that matches nothing, a value it cannot read): the gap is Magma's to fill, and the
|
|
29
|
+
* agent proposes an issue (agents/reporting.md, section 7, #1137). An input error is not a gap.
|
|
30
|
+
*/
|
|
31
|
+
export declare const GAP = "Magma has nothing for this. If it should, tell the user, and at the end of the task propose an issue on Magma: get_guide reporting, section \"A tool or an answer the MCP server is missing\".";
|
|
32
|
+
/** The output schema of the optional `gap` of an answer. */
|
|
33
|
+
export declare const GAP_SCHEMA: {
|
|
34
|
+
type: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
package/dist/lint/mcp/context.js
CHANGED
|
@@ -85,3 +85,14 @@ export const firstSentence = (markdown = '') => {
|
|
|
85
85
|
const plain = line.replace(/\[([^\]]+)\]\([^)]*\)/g, '$1');
|
|
86
86
|
return (plain.split(/\.\s/)[0] ?? plain).replace(/\s+/g, ' ').trim().replace(/\.$/, '') + '.';
|
|
87
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* What an answer adds when the installed Magma has nothing for a well-formed question (a
|
|
90
|
+
* search that matches nothing, a value it cannot read): the gap is Magma's to fill, and the
|
|
91
|
+
* agent proposes an issue (agents/reporting.md, section 7, #1137). An input error is not a gap.
|
|
92
|
+
*/
|
|
93
|
+
export const GAP = 'Magma has nothing for this. If it should, tell the user, and at the end of the task propose an issue on Magma: get_guide reporting, section "A tool or an answer the MCP server is missing".';
|
|
94
|
+
/** The output schema of the optional `gap` of an answer. */
|
|
95
|
+
export const GAP_SCHEMA = {
|
|
96
|
+
type: 'string',
|
|
97
|
+
description: 'Set when Magma has nothing for the question: a gap to report.',
|
|
98
|
+
};
|