@reqvire-org/ads 0.3.53 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -94
- package/dist/a11y.mjs +108 -29
- package/dist/analysis/compiler-options.mjs +13 -0
- package/dist/analysis/context.mjs +46 -0
- package/dist/analysis/file-tree.mjs +52 -0
- package/dist/analysis/helpers.mjs +140 -0
- package/dist/analysis/impact.mjs +20 -0
- package/dist/analysis/inputs.mjs +15 -0
- package/dist/analysis/native-adapter.mjs +180 -0
- package/dist/analysis/native-project.mjs +323 -0
- package/dist/analysis/queries.mjs +133 -0
- package/dist/analysis/service.mjs +146 -0
- package/dist/analysis/standalone.mjs +57 -0
- package/dist/analysis/syntax.mjs +164 -0
- package/dist/analysis/worker.mjs +182 -0
- package/dist/assets.mjs +6 -6
- package/dist/atomic-composition.mjs +191 -70
- package/dist/atomic-trace.mjs +120 -50
- package/dist/behavior-libraries.mjs +106 -37
- package/dist/behaviors.mjs +222 -79
- package/dist/boundaries.mjs +137 -40
- package/dist/brand-assets.mjs +219 -47
- package/dist/brands.mjs +86 -27
- package/dist/bun-compiler.mjs +34 -13
- package/dist/bun-worker.mjs +7 -5
- package/dist/capture/worker.mjs +15 -4
- package/dist/capture-store.mjs +4 -2
- package/dist/capture.mjs +17 -14
- package/dist/check-service.mjs +66 -0
- package/dist/check.mjs +756 -196
- package/dist/cli.mjs +203 -100
- package/dist/color-values.mjs +21 -21
- package/dist/component-contrast.mjs +2 -2
- package/dist/config.mjs +308 -163
- package/dist/construction-styles.cjs +10 -0
- package/dist/contracts.d.mts +9 -0
- package/dist/control-padding.mjs +45 -25
- package/dist/css-values.mjs +3 -2
- package/dist/declarative-flow.mjs +209 -109
- package/dist/design-values.mjs +136 -51
- package/dist/development-runtime.mjs +4 -6
- package/dist/draft-boundary.mjs +11 -6
- package/dist/evidence.mjs +1 -1
- package/dist/finding-rules.mjs +7 -5
- package/dist/font-rules.mjs +2 -2
- package/dist/fonts-generated.mjs +4 -2
- package/dist/foundation-views.mjs +238 -0
- package/dist/foundation.mjs +63 -39
- package/dist/generated-entries.mjs +198 -0
- package/dist/icons.mjs +80 -33
- package/dist/image-attributes.mjs +109 -36
- package/dist/image-size.mjs +1 -1
- package/dist/index.mjs +0 -2
- package/dist/init.mjs +128 -68
- package/dist/investigations.mjs +2 -2
- package/dist/layers.mjs +300 -127
- package/dist/layout-widths.mjs +180 -85
- package/dist/linaria/preserve-values.cjs +7 -0
- package/dist/linaria/spatial-inputs.cjs +56 -0
- package/dist/lockup-composition.mjs +44 -0
- package/dist/lockup-model.cjs +64 -0
- package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
- package/dist/mcp/apps.mjs +4 -30
- package/dist/mcp/behavior-pages.mjs +72 -24
- package/dist/mcp/build-status.mjs +257 -64
- package/dist/mcp/catalog.mjs +91 -26
- package/dist/mcp/context.mjs +17 -18
- package/dist/mcp/draft-discovery.mjs +44 -21
- package/dist/mcp/drafts.mjs +978 -343
- package/dist/mcp/execution-coordinator.mjs +417 -167
- package/dist/mcp/execution-results.mjs +7 -7
- package/dist/mcp/mutations.mjs +701 -219
- package/dist/mcp/preview-watch.mjs +465 -161
- package/dist/mcp/preview-widget.bundle.js +44 -50
- package/dist/mcp/prompts.mjs +6 -6
- package/dist/mcp/result-pages.mjs +1 -1
- package/dist/mcp/sandbox-host.mjs +1 -1
- package/dist/mcp/server.mjs +2436 -570
- package/dist/mcp/showcase-host.mjs +176 -39
- package/dist/mcp/skills.mjs +1 -1
- package/dist/mcp/text-diff.mjs +29 -10
- package/dist/paint-contracts.mjs +174 -81
- package/dist/palette-generated.mjs +2 -2
- package/dist/preview-bun.mjs +493 -187
- package/dist/preview-failure.mjs +1 -1
- package/dist/preview-files.mjs +13 -13
- package/dist/preview-imports.mjs +104 -55
- package/dist/preview-inputs.mjs +2 -2
- package/dist/preview-requests.mjs +24 -0
- package/dist/preview-resources.mjs +288 -147
- package/dist/preview-scope.mjs +5 -4
- package/dist/program-cache.mjs +10 -0
- package/dist/project-documents.mjs +1 -1
- package/dist/public-api.mjs +70 -31
- package/dist/public-props.mjs +39 -22
- package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
- package/dist/{browser-audit → render-audit}/image-shape.mjs +2 -2
- package/dist/{browser-audit → render-audit}/layout-overflow.mjs +86 -23
- package/dist/{browser-audit → render-audit}/non-text-contrast.mjs +86 -27
- package/dist/{browser-audit → render-audit}/render-states.mjs +208 -52
- package/dist/{browser-audit → render-audit}/worker.mjs +86 -30
- package/dist/render-audit.mjs +828 -0
- package/dist/render-color-probe.mjs +96 -42
- package/dist/resource-limits.mjs +229 -97
- package/dist/runtime-contracts.mjs +467 -185
- package/dist/scenario-groups.mjs +22 -10
- package/dist/scenario-inspector.mjs +6 -43
- package/dist/scenario-program.mjs +8 -25
- package/dist/scenario-registry.mjs +72 -30
- package/dist/scenario-selectors.mjs +161 -64
- package/dist/scenario-slots.mjs +149 -56
- package/dist/scenario-trace.mjs +215 -109
- package/dist/scenarios-compiler.mjs +768 -359
- package/dist/scenarios-vite.d.mts +1 -3
- package/dist/scenarios-vite.mjs +2 -81
- package/dist/scenarios.mjs +424 -159
- package/dist/selector-match.mjs +2 -2
- package/dist/showcase/client.bundle.js +57 -56
- package/dist/showcase/draft-navigation.js +18 -0
- package/dist/showcase/favicon.ico +0 -0
- package/dist/showcase/favicon.svg +1 -0
- package/dist/showcase/foundation-view.css +55 -0
- package/dist/showcase/foundation-view.mjs +252 -0
- package/dist/showcase/guide-controls.ads.review.mjs +32 -0
- package/dist/showcase/icons.js +1 -145
- package/dist/showcase/index.html +3 -31
- package/dist/showcase/preview-frame.ads.review.css +46 -0
- package/dist/showcase/preview-frame.ads.review.d.mts +11 -0
- package/dist/showcase/preview-frame.ads.review.mjs +22 -0
- package/dist/showcase/preview-state.js +0 -9
- package/dist/showcase/refresh-scheduler.js +23 -0
- package/dist/showcase/style.css +5 -47
- package/dist/showcase/ui/ui.css +1353 -0
- package/dist/showcase/ui/ui.js +1062 -0
- package/dist/showcase-coverage.mjs +58 -37
- package/dist/skills/README.md +24 -23
- package/dist/skills/ads-designer/README.md +8 -2
- package/dist/skills/ads-designer/SKILL.md +152 -144
- package/dist/skills/ads-designer/references/accessibility.md +14 -11
- package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
- package/dist/skills/ads-designer/references/behaviors.md +34 -30
- package/dist/skills/ads-designer/references/branding.md +98 -10
- package/dist/skills/ads-designer/references/captures.md +31 -31
- package/dist/skills/ads-designer/references/cli.md +21 -20
- package/dist/skills/ads-designer/references/contracts.md +63 -29
- package/dist/skills/ads-designer/references/design-data.md +49 -52
- package/dist/skills/ads-designer/references/drafts.md +71 -52
- package/dist/skills/ads-designer/references/evidence.md +1 -5
- package/dist/skills/ads-designer/references/guarded-editing.md +58 -51
- package/dist/skills/ads-designer/references/layers.md +1 -1
- package/dist/skills/ads-designer/references/layout.md +347 -0
- package/dist/skills/ads-designer/references/mobile.md +2 -1
- package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
- package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
- package/dist/skills/ads-designer/references/performance.md +3 -2
- package/dist/skills/ads-designer/references/review.md +42 -38
- package/dist/skills/ads-designer/references/runtimes.md +33 -30
- package/dist/skills/ads-designer/references/scenarios.md +17 -19
- package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
- package/dist/skills/ads-designer/references/stress-test.md +68 -0
- package/dist/skills/ads-designer/references/validation.md +83 -71
- package/dist/skills/ads-designer/references/workflows.md +19 -37
- package/dist/skills/ads-import/SKILL.md +43 -328
- package/dist/skills/ads-import/references/atomic-styles.md +4 -4
- package/dist/skills/ads-import/references/behaviors.md +34 -30
- package/dist/skills/ads-import/references/branding.md +5 -5
- package/dist/skills/ads-import/references/captures.md +31 -31
- package/dist/skills/ads-import/references/cli.md +21 -20
- package/dist/skills/ads-import/references/compatibility.md +1 -1
- package/dist/skills/ads-import/references/contracts.md +63 -29
- package/dist/skills/ads-import/references/design-data.md +49 -52
- package/dist/skills/ads-import/references/drafts.md +71 -52
- package/dist/skills/ads-import/references/evidence.md +1 -5
- package/dist/skills/ads-import/references/guarded-editing.md +58 -51
- package/dist/skills/ads-import/references/implementation.md +2 -1
- package/dist/skills/ads-import/references/layers.md +1 -1
- package/dist/skills/ads-import/references/layout.md +347 -0
- package/dist/skills/ads-import/references/review.md +42 -38
- package/dist/skills/ads-import/references/runtimes.md +33 -30
- package/dist/skills/ads-import/references/scenarios.md +17 -19
- package/dist/skills/ads-import/references/tokens.md +3 -3
- package/dist/skills/ads-import/references/validation.md +83 -71
- package/dist/skills/ads-import/references/workflows.md +19 -37
- package/dist/skills/ads-migrate/SKILL.md +56 -0
- package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
- package/dist/skills/ads-port/SKILL.md +54 -346
- package/dist/skills/ads-port/references/atomic-styles.md +4 -4
- package/dist/skills/ads-port/references/behaviors.md +34 -30
- package/dist/skills/ads-port/references/captures.md +31 -31
- package/dist/skills/ads-port/references/cli.md +21 -20
- package/dist/skills/ads-port/references/contracts.md +63 -29
- package/dist/skills/ads-port/references/design-data.md +49 -52
- package/dist/skills/ads-port/references/drafts.md +71 -52
- package/dist/skills/ads-port/references/evidence.md +1 -5
- package/dist/skills/ads-port/references/guarded-editing.md +58 -51
- package/dist/skills/ads-port/references/layers.md +1 -1
- package/dist/skills/ads-port/references/layout.md +347 -0
- package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
- package/dist/skills/ads-port/references/native-implementation.md +8 -7
- package/dist/skills/ads-port/references/review.md +42 -38
- package/dist/skills/ads-port/references/runtimes.md +33 -30
- package/dist/skills/ads-port/references/scenarios.md +17 -19
- package/dist/skills/ads-port/references/validation.md +83 -71
- package/dist/skills/ads-port/references/workflows.md +19 -37
- package/dist/source-symbols.mjs +1 -8
- package/dist/source-values.mjs +266 -128
- package/dist/spatial-composition.mjs +322 -0
- package/dist/spatial-contexts.cjs +56 -0
- package/dist/spatial-css.cjs +351 -0
- package/dist/spatial-inputs.cjs +80 -0
- package/dist/spatial-metadata.mjs +18 -0
- package/dist/spatial-model.cjs +322 -0
- package/dist/spatial.mjs +21 -0
- package/dist/stage-timing.cjs +20 -0
- package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +105 -0
- package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +275 -0
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
- package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +8 -0
- package/dist/starters/preact/ds.config.json +24 -19
- package/dist/starters/preact/package.json +4 -8
- package/dist/starters/preact/tsconfig.json +4 -5
- package/dist/starters/preact/vite.config.ts +3 -3
- package/dist/starters/react/ADS.md +42 -47
- package/dist/starters/react/README.md +54 -52
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +18 -2
- package/dist/starters/react/design-system/components/Actions/IconButton/README.md +3 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +5 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
- package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/index.ts +5 -8
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
- package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
- package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
- package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
- package/dist/starters/react/design-system/styles.css +1 -0
- package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
- package/dist/starters/react/design-system/tokens/colors.css +1 -1
- package/dist/starters/react/design-system/tokens/spacing.css +22 -32
- package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
- package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
- package/dist/starters/react/ds.config.json +24 -19
- package/dist/starters/react/package.json +2 -6
- package/dist/starters/react/tsconfig.json +2 -3
- package/dist/starters/react/vite.config.ts +3 -3
- package/dist/style-boundaries.mjs +73 -27
- package/dist/task-cache.mjs +173 -72
- package/dist/task-worker.mjs +22 -11
- package/dist/test-boundaries.mjs +133 -60
- package/dist/themes-generated.mjs +1 -1
- package/dist/themes-watch.mjs +60 -19
- package/dist/themes.mjs +176 -73
- package/dist/token-export.mjs +39 -14
- package/dist/token-policy.mjs +6 -3
- package/dist/token-quality.mjs +6 -6
- package/dist/token-samples.mjs +16 -5
- package/dist/tokens.mjs +71 -26
- package/dist/ui-framework.mjs +16 -14
- package/dist/unit-contracts.mjs +270 -89
- package/dist/units.mjs +215 -180
- package/dist/usage.mjs +138 -38
- package/dist/validation-checks.mjs +121 -38
- package/dist/validation-inputs.mjs +187 -78
- package/dist/validation.mjs +268 -102
- package/dist/verification/browser.mjs +27 -5
- package/dist/verification.mjs +711 -187
- package/docs/ADS.md +100 -89
- package/docs/ARCHITECTURE.md +353 -159
- package/docs/BEHAVIORS.md +33 -28
- package/docs/CACHING.md +55 -11
- package/docs/CHANGELOG.md +358 -17
- package/docs/COMPARISON.md +1 -1
- package/docs/CONTRACTS.md +22 -29
- package/docs/DESIGN-REFERENCES.md +40 -0
- package/docs/GUIDE.md +313 -292
- package/docs/MCP.md +261 -439
- package/docs/SPATIAL-CHECKS.md +69 -0
- package/docs/benchmarks/README.md +39 -0
- package/package.json +42 -34
- package/dist/browser-audit.mjs +0 -424
- package/dist/contract-migration.mjs +0 -110
- package/dist/create.mjs +0 -48
- package/dist/lint-config.mjs +0 -48
- package/dist/mcp/draft-exports.mjs +0 -40
- package/dist/mcp/edit-preparation.mjs +0 -115
- package/dist/mcp/project-widget.bundle.js +0 -114
- package/dist/mcp/reports.mjs +0 -101
- package/dist/mcp/widget.bundle.js +0 -147
- package/dist/oxlint.mjs +0 -88
- package/dist/preview-builder.mjs +0 -133
- package/dist/preview-workers.mjs +0 -184
- package/dist/showcase.mjs +0 -77
- package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
- package/dist/skills/ads-break-ui/README.md +0 -16
- package/dist/skills/ads-break-ui/SKILL.md +0 -415
- package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
- package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
- package/dist/skills/ads-break-ui/references/behaviors.md +0 -411
- package/dist/skills/ads-break-ui/references/captures.md +0 -160
- package/dist/skills/ads-break-ui/references/contracts.md +0 -284
- package/dist/skills/ads-break-ui/references/design-data.md +0 -354
- package/dist/skills/ads-break-ui/references/drafts.md +0 -178
- package/dist/skills/ads-break-ui/references/evidence.md +0 -128
- package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -154
- package/dist/skills/ads-break-ui/references/layers.md +0 -145
- package/dist/skills/ads-break-ui/references/reporting.md +0 -101
- package/dist/skills/ads-break-ui/references/review.md +0 -96
- package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
- package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
- package/dist/skills/ads-break-ui/references/validation.md +0 -162
- package/dist/skills/ads-break-ui/references/verification.md +0 -58
- package/dist/skills/ads-break-ui/references/workflows.md +0 -83
- package/dist/skills/ads-designer/references/reporting.md +0 -101
- package/dist/skills/ads-import/references/reporting.md +0 -101
- package/dist/skills/ads-motion/LICENSE.upstream +0 -21
- package/dist/skills/ads-motion/README.md +0 -22
- package/dist/skills/ads-motion/SKILL.md +0 -388
- package/dist/skills/ads-motion/agents/openai.yaml +0 -4
- package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
- package/dist/skills/ads-motion/references/audit.md +0 -44
- package/dist/skills/ads-motion/references/behaviors.md +0 -411
- package/dist/skills/ads-motion/references/captures.md +0 -160
- package/dist/skills/ads-motion/references/contracts.md +0 -284
- package/dist/skills/ads-motion/references/design-data.md +0 -354
- package/dist/skills/ads-motion/references/drafts.md +0 -178
- package/dist/skills/ads-motion/references/evidence.md +0 -128
- package/dist/skills/ads-motion/references/guarded-editing.md +0 -154
- package/dist/skills/ads-motion/references/layers.md +0 -145
- package/dist/skills/ads-motion/references/motion-review.md +0 -35
- package/dist/skills/ads-motion/references/reporting.md +0 -101
- package/dist/skills/ads-motion/references/review.md +0 -96
- package/dist/skills/ads-motion/references/runtimes.md +0 -203
- package/dist/skills/ads-motion/references/scenarios.md +0 -246
- package/dist/skills/ads-motion/references/validation.md +0 -162
- package/dist/skills/ads-motion/references/verification.md +0 -39
- package/dist/skills/ads-motion/references/workflows.md +0 -83
- package/dist/skills/ads-port/references/reporting.md +0 -101
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
- package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
- package/dist/starters/react/design-system/review/index.ts +0 -5
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
- package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
- package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
- package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
- package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
- package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
- package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
- package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
- package/dist/starters/react/package-lock.json +0 -4707
- package/dist/token-fixtures.mjs +0 -30
- package/docs/benchmarks/bun-previews.md +0 -91
- package/docs/benchmarks/preview-memory.md +0 -147
- package/docs/benchmarks/turbo-poc.md +0 -284
- package/docs/plans/execution-coordination.md +0 -57
- /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
- /package/dist/{browser-audit → render-audit}/layout-shift.mjs +0 -0
package/dist/check.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { jsxImportSource } from "./analysis/helpers.mjs";
|
|
2
|
+
import { withProjectAnalysis } from "./analysis/standalone.mjs";
|
|
3
|
+
import { currentAnalysis } from "./analysis/context.mjs";
|
|
4
|
+
import { eachChild, walkAsync } from "./analysis/queries.mjs";
|
|
1
5
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
6
|
import path from "node:path";
|
|
3
|
-
import ts from "
|
|
7
|
+
import ts from "./analysis/syntax.mjs";
|
|
4
8
|
import postcss from "postcss";
|
|
5
9
|
import valueParser from "postcss-value-parser";
|
|
6
10
|
import { importViolation, isInside, loadConfig, sourceFiles, isDevelopmentFile, isTestFile, isReviewFile } from "./config.mjs";
|
|
@@ -8,17 +12,26 @@ import { inspectTokens, references } from "./tokens.mjs";
|
|
|
8
12
|
import { displaySwitches, generatedPaletteFile, generatedThemeFiles } from "./themes-generated.mjs";
|
|
9
13
|
import { createRenderColorProbe } from "./render-color-probe.mjs";
|
|
10
14
|
import { themeAncestorSelector } from "./themes.mjs";
|
|
11
|
-
import {
|
|
15
|
+
import { isSharedToken } from "./token-policy.mjs";
|
|
12
16
|
import { inspectAssets } from "./assets.mjs";
|
|
13
17
|
import { a11ySourceAdvisories } from "./a11y.mjs";
|
|
14
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
appImportViolation,
|
|
20
|
+
showcaseImportViolation,
|
|
21
|
+
checkComponentVariable,
|
|
22
|
+
tokenNameGuidance,
|
|
23
|
+
variableLayer,
|
|
24
|
+
importResolver,
|
|
25
|
+
projectCompilerOptions,
|
|
26
|
+
isUiCssProperties,
|
|
27
|
+
styleWriteViolation,
|
|
28
|
+
} from "./boundaries.mjs";
|
|
15
29
|
import { inspectPublicProps } from "./public-props.mjs";
|
|
16
30
|
import { adsFileRole } from "./config.mjs";
|
|
17
31
|
import { inspectPaintContracts, inspectTokenValueFlows } from "./paint-contracts.mjs";
|
|
18
|
-
import { runtimeBindingOwner } from "./unit-contracts.mjs";
|
|
32
|
+
import { ownerStylePolicy, runtimeBindingOwner } from "./unit-contracts.mjs";
|
|
19
33
|
import { inspectRuntimeContracts } from "./runtime-contracts.mjs";
|
|
20
34
|
import { inspectHtml, isMountCss } from "./html.mjs";
|
|
21
|
-
import { inspectShowcasePages } from "./showcase.mjs";
|
|
22
35
|
import { inspectShowcaseCoverage } from "./showcase-coverage.mjs";
|
|
23
36
|
import { inspectScenarioCoverage } from "./scenarios.mjs";
|
|
24
37
|
import { uiOperation, importedUiApi } from "./ui-framework.mjs";
|
|
@@ -27,6 +40,8 @@ import { inspectBehaviors, inspectControllers } from "./behaviors.mjs";
|
|
|
27
40
|
import { numericCssUnit, tokenLengthLiteral } from "./css-values.mjs";
|
|
28
41
|
import { foundationDeclaration, foundationSelector } from "./foundation.mjs";
|
|
29
42
|
import { inspectUnits } from "./units.mjs";
|
|
43
|
+
import { generatedEntryDiagnostics } from "./generated-entries.mjs";
|
|
44
|
+
import { cachedProgram } from "./program-cache.mjs";
|
|
30
45
|
import { createAtomicCompositionReview } from "./atomic-composition.mjs";
|
|
31
46
|
import { createScenarioTrace } from "./scenario-trace.mjs";
|
|
32
47
|
import { createScenarioSlots } from "./scenario-slots.mjs";
|
|
@@ -34,7 +49,7 @@ import { createScenarioSelectors } from "./scenario-selectors.mjs";
|
|
|
34
49
|
import { architectureEvidence, failure } from "./evidence.mjs";
|
|
35
50
|
import { propertyRegistration } from "./property-registrations.mjs";
|
|
36
51
|
import { createLayerBoundaries, layerSourceFiles } from "./layers.mjs";
|
|
37
|
-
import { createDesignValues, inspectDesignAliases, isColorKeyword } from "./design-values.mjs";
|
|
52
|
+
import { createDesignValues, designTemplateVariants, inspectDesignAliases, isColorKeyword } from "./design-values.mjs";
|
|
38
53
|
import { inspectTestBoundaries } from "./test-boundaries.mjs";
|
|
39
54
|
import { inspectBehaviorLibraries } from "./behavior-libraries.mjs";
|
|
40
55
|
import { inspectUsage } from "./usage.mjs";
|
|
@@ -44,351 +59,896 @@ import { createFontRules } from "./font-rules.mjs";
|
|
|
44
59
|
import { createLayoutWidths, globMatcher } from "./layout-widths.mjs";
|
|
45
60
|
import { imageAttributeFindings } from "./image-attributes.mjs";
|
|
46
61
|
import { findingSeverity, routeFindings } from "./finding-rules.mjs";
|
|
62
|
+
import construction from "./construction-styles.cjs";
|
|
63
|
+
import spatialCss from "./spatial-css.cjs";
|
|
64
|
+
import { inspectSpatial } from "./spatial.mjs";
|
|
65
|
+
import { createSpatialComposition } from "./spatial-composition.mjs";
|
|
66
|
+
import timing from "./stage-timing.cjs";
|
|
47
67
|
|
|
48
|
-
const scenarioLayoutGuidance =
|
|
49
|
-
|
|
68
|
+
const scenarioLayoutGuidance =
|
|
69
|
+
"Use ADS preview framing for generic layouts. Put project-specific demonstration sizing in a marked .ads.review.* helper. Patterns are production UI. Keep required behavior in the runtime owner; add component props for deliberate product API needs.";
|
|
70
|
+
const inlineStyleGuidance = `Own visual styles in component/pattern Linaria. ${scenarioLayoutGuidance} Reserve the owner contract's styles.inline for documented measured geometry, not demo layout.`;
|
|
50
71
|
|
|
51
|
-
const showcaseControls = new Set([
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
const showcaseControls = new Set([
|
|
73
|
+
"a",
|
|
74
|
+
"button",
|
|
75
|
+
"input",
|
|
76
|
+
"select",
|
|
77
|
+
"textarea",
|
|
78
|
+
"option",
|
|
79
|
+
"optgroup",
|
|
80
|
+
"table",
|
|
81
|
+
"thead",
|
|
82
|
+
"tbody",
|
|
83
|
+
"tfoot",
|
|
84
|
+
"tr",
|
|
85
|
+
"td",
|
|
86
|
+
"th",
|
|
87
|
+
"dialog",
|
|
88
|
+
"details",
|
|
89
|
+
"summary",
|
|
90
|
+
"progress",
|
|
91
|
+
"meter",
|
|
92
|
+
]);
|
|
93
|
+
const svgTags = new Set([
|
|
94
|
+
"svg",
|
|
95
|
+
"g",
|
|
96
|
+
"path",
|
|
97
|
+
"circle",
|
|
98
|
+
"rect",
|
|
99
|
+
"ellipse",
|
|
100
|
+
"line",
|
|
101
|
+
"polyline",
|
|
102
|
+
"polygon",
|
|
103
|
+
"text",
|
|
104
|
+
"tspan",
|
|
105
|
+
"use",
|
|
106
|
+
"defs",
|
|
107
|
+
"clipPath",
|
|
108
|
+
"mask",
|
|
109
|
+
"filter",
|
|
110
|
+
"linearGradient",
|
|
111
|
+
"radialGradient",
|
|
112
|
+
"stop",
|
|
113
|
+
"marker",
|
|
114
|
+
"pattern",
|
|
115
|
+
]);
|
|
116
|
+
const svgPresentation = new Set([
|
|
117
|
+
"strokeWidth",
|
|
118
|
+
"strokeLinecap",
|
|
119
|
+
"strokeLinejoin",
|
|
120
|
+
"strokeDasharray",
|
|
121
|
+
"strokeDashoffset",
|
|
122
|
+
"strokeOpacity",
|
|
123
|
+
"strokeMiterlimit",
|
|
124
|
+
"fillRule",
|
|
125
|
+
"fillOpacity",
|
|
126
|
+
"clipRule",
|
|
127
|
+
"clipPath",
|
|
128
|
+
"colorInterpolation",
|
|
129
|
+
"colorInterpolationFilters",
|
|
130
|
+
"floodColor",
|
|
131
|
+
"floodOpacity",
|
|
132
|
+
"stopColor",
|
|
133
|
+
"stopOpacity",
|
|
134
|
+
"fontFamily",
|
|
135
|
+
"fontSize",
|
|
136
|
+
"fontStyle",
|
|
137
|
+
"fontWeight",
|
|
138
|
+
"letterSpacing",
|
|
139
|
+
"textAnchor",
|
|
140
|
+
"dominantBaseline",
|
|
141
|
+
"markerStart",
|
|
142
|
+
"markerMid",
|
|
143
|
+
"markerEnd",
|
|
144
|
+
"vectorEffect",
|
|
145
|
+
"shapeRendering",
|
|
146
|
+
"textRendering",
|
|
147
|
+
"paintOrder",
|
|
148
|
+
"alignmentBaseline",
|
|
149
|
+
"baselineShift",
|
|
150
|
+
"transformOrigin",
|
|
151
|
+
]);
|
|
152
|
+
const widgetRoles = new Set([
|
|
153
|
+
"button",
|
|
154
|
+
"link",
|
|
155
|
+
"checkbox",
|
|
156
|
+
"radio",
|
|
157
|
+
"switch",
|
|
158
|
+
"combobox",
|
|
159
|
+
"textbox",
|
|
160
|
+
"listbox",
|
|
161
|
+
"option",
|
|
162
|
+
"slider",
|
|
163
|
+
"spinbutton",
|
|
164
|
+
"tab",
|
|
165
|
+
"tablist",
|
|
166
|
+
"menu",
|
|
167
|
+
"menuitem",
|
|
168
|
+
"tree",
|
|
169
|
+
"treeitem",
|
|
170
|
+
"grid",
|
|
171
|
+
"dialog",
|
|
172
|
+
"alertdialog",
|
|
173
|
+
"progressbar",
|
|
174
|
+
]);
|
|
55
175
|
|
|
56
|
-
export function checkProject(directory, { trackingRoot } = {}) {
|
|
176
|
+
export async function checkProject(directory, { trackingRoot } = {}) {
|
|
177
|
+
// Missing targets fail the structure gate below before any source capture or compiler work.
|
|
178
|
+
if (!currentAnalysis()?.provideProgram && existsSync(directory))
|
|
179
|
+
return withProjectAnalysis(directory, () => checkProject(directory, { trackingRoot })).catch((error) => {
|
|
180
|
+
if (error.diagnostic) return architectureEvidence({ ok: false, diagnostics: [error.diagnostic] });
|
|
181
|
+
throw error;
|
|
182
|
+
});
|
|
183
|
+
return timing.timeStage("architecture-check", () => checkCapturedProject(directory, { trackingRoot }));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function checkCapturedProject(directory, { trackingRoot }) {
|
|
57
187
|
const options = { ...loadConfig(directory), ...(trackingRoot ? { trackingRoot: path.resolve(trackingRoot) } : {}) };
|
|
58
188
|
const { root, config, dsRoot, sourceRoot } = options;
|
|
59
|
-
const diagnostics = [],
|
|
60
|
-
|
|
61
|
-
|
|
189
|
+
const diagnostics = [],
|
|
190
|
+
advisories = [];
|
|
191
|
+
for (const [field, file] of [
|
|
192
|
+
["dsDir", dsRoot],
|
|
193
|
+
["publicEntry", path.join(dsRoot, config.publicEntry)],
|
|
194
|
+
["stylesEntry", path.join(dsRoot, config.stylesEntry)],
|
|
195
|
+
]) {
|
|
196
|
+
if (!existsSync(file) || (field === "dsDir" ? !statSync(file).isDirectory() : !statSync(file).isFile()))
|
|
197
|
+
diagnostics.push({
|
|
198
|
+
rule: "project-structure",
|
|
199
|
+
file: path.relative(root, file),
|
|
200
|
+
line: 1,
|
|
201
|
+
column: 1,
|
|
202
|
+
message: `Missing or invalid ${field}. Bootstrap an empty ADS or configure its actual path.`,
|
|
203
|
+
});
|
|
62
204
|
}
|
|
63
205
|
if (diagnostics.length) return architectureEvidence({ ok: false, diagnostics });
|
|
64
|
-
|
|
206
|
+
diagnostics.push(...(await generatedEntryDiagnostics(options, await inspectUnits(options))));
|
|
207
|
+
const tokenInventory = await inspectTokens(root, options);
|
|
65
208
|
const declaredTokens = new Set(tokenInventory.tokens.map((token) => token.name));
|
|
66
209
|
// Display switches are defined by the generated themes.generated.css, not a token sheet.
|
|
67
210
|
const generatedSwitches = new Set(displaySwitches(config));
|
|
68
211
|
diagnostics.push(...tokenInventory.diagnostics);
|
|
212
|
+
let spatialFoundation;
|
|
213
|
+
try {
|
|
214
|
+
spatialFoundation = inspectSpatial(options)?.model;
|
|
215
|
+
} catch (error) {
|
|
216
|
+
diagnostics.push({ rule: "grid-definition", file: `${config.dsDir}/${config.tokenDir}/spatial.ads.json`, line: 1, column: 1, message: error.message, guidanceUri: "ads://guides/layout" });
|
|
217
|
+
}
|
|
69
218
|
const assetFindings = inspectAssets(options);
|
|
70
|
-
diagnostics.push(...assetFindings.filter(finding => !finding.severity || finding.severity === "error"));
|
|
71
|
-
const assetAdvisories = assetFindings.filter(finding => finding.severity && finding.severity !== "error");
|
|
72
|
-
const resolveImport = importResolver(options);
|
|
73
|
-
const units = inspectUnits(options);
|
|
74
|
-
options.testOwner = file => units.owner(units.relative(path.relative(root,file)));
|
|
75
|
-
const configurationScripts=new Set(
|
|
219
|
+
diagnostics.push(...assetFindings.filter((finding) => !finding.severity || finding.severity === "error"));
|
|
220
|
+
const assetAdvisories = assetFindings.filter((finding) => finding.severity && finding.severity !== "error");
|
|
221
|
+
const resolveImport = await importResolver(options);
|
|
222
|
+
const units = await inspectUnits(options);
|
|
223
|
+
options.testOwner = (file) => units.owner(units.relative(path.relative(root, file)));
|
|
224
|
+
const configurationScripts = new Set(
|
|
225
|
+
(units.units.find((unit) => unit.id === "configuration")?.files ?? [])
|
|
226
|
+
.filter((file) => /\.[cm]?[jt]sx?$/.test(file))
|
|
227
|
+
.map((file) => path.resolve(root, file))
|
|
228
|
+
.filter((file) => existsSync(file) && statSync(file).isFile()),
|
|
229
|
+
);
|
|
76
230
|
const rootHtml = path.join(root, "index.html");
|
|
77
231
|
const files = [...new Set([...sourceFiles(sourceRoot), ...sourceFiles(dsRoot), ...configurationScripts, ...(existsSync(rootHtml) ? [rootHtml] : [])])];
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
232
|
+
const stylePolicy = await ownerStylePolicy(options);
|
|
233
|
+
const boundaryFiles = [...stylePolicy.inlineStyleFiles, ...stylePolicy.styleWrites.map((entry) => entry.file)]
|
|
234
|
+
.map((file) => path.resolve(root, file))
|
|
235
|
+
.filter((file) => existsSync(file) && statSync(file).isFile());
|
|
236
|
+
const scriptFiles = [
|
|
237
|
+
...new Set([
|
|
238
|
+
...(await layerSourceFiles(
|
|
239
|
+
[...new Set([...files, ...boundaryFiles])].filter((file) => /\.[cm]?[jt]sx?$/.test(file)),
|
|
240
|
+
options,
|
|
241
|
+
)),
|
|
242
|
+
...configurationScripts,
|
|
243
|
+
]),
|
|
244
|
+
];
|
|
245
|
+
const compiler = await projectCompilerOptions(options);
|
|
246
|
+
const program = await cachedProgram(`check:${root}`, scriptFiles, {
|
|
247
|
+
...compiler,
|
|
248
|
+
paths: { ...compiler.paths, [config.publicAlias]: [path.join(dsRoot, config.publicEntry)] },
|
|
249
|
+
allowJs: true,
|
|
250
|
+
noResolve: true,
|
|
251
|
+
noLib: true,
|
|
252
|
+
types: [],
|
|
253
|
+
target: ts.ScriptTarget.Latest,
|
|
254
|
+
module: ts.ModuleKind.ESNext,
|
|
255
|
+
jsx: ts.JsxEmit.Preserve,
|
|
256
|
+
});
|
|
82
257
|
const checker = program.getTypeChecker();
|
|
83
|
-
diagnostics.push(...inspectBehaviorLibraries(options, program).diagnostics);
|
|
84
|
-
const designValues = createDesignValues(program,options);
|
|
85
|
-
const
|
|
258
|
+
diagnostics.push(...(await inspectBehaviorLibraries(options, program)).diagnostics);
|
|
259
|
+
const designValues = createDesignValues(program, options);
|
|
260
|
+
const spatialComposition = createSpatialComposition(program, options);
|
|
261
|
+
const paintContracts = await inspectPaintContracts(options);
|
|
86
262
|
diagnostics.push(...paintContracts.diagnostics);
|
|
87
|
-
const runtimeContracts = inspectRuntimeContracts(options, program);
|
|
263
|
+
const runtimeContracts = await inspectRuntimeContracts(options, program);
|
|
88
264
|
diagnostics.push(...runtimeContracts.diagnostics);
|
|
89
265
|
const atomicCompositionReview = createAtomicCompositionReview(program, options);
|
|
90
266
|
const renderColorProbe = createRenderColorProbe(program);
|
|
91
|
-
const scenarioTrace = createScenarioTrace(program, options);
|
|
267
|
+
const scenarioTrace = await createScenarioTrace(program, options);
|
|
92
268
|
let scenarioSlot, scenarioSelector;
|
|
93
269
|
function report(file, rule, message, line = 1, column = 1, detail = {}) {
|
|
94
270
|
diagnostics.push({ file: path.relative(root, file).replaceAll("\\", "/"), rule, message, line, column, ...detail });
|
|
95
271
|
}
|
|
96
|
-
const layers = createLayerBoundaries(program, options, report),
|
|
97
|
-
|
|
272
|
+
const layers = await createLayerBoundaries(program, options, report),
|
|
273
|
+
layerStyles = [];
|
|
274
|
+
await inspectUsage(options, program, report);
|
|
98
275
|
layers.inspectDependencies();
|
|
99
|
-
inspectTokenValueFlows(program, options, tokenInventory, units, report);
|
|
100
|
-
for (const file of layers.runtimeHelpers()) if (!files.includes(file)) files.push(file);
|
|
101
|
-
inspectStyleBoundaries(options, program, report);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
276
|
+
await inspectTokenValueFlows(program, options, tokenInventory, units, report);
|
|
277
|
+
for (const file of await layers.runtimeHelpers()) if (!files.includes(file)) files.push(file);
|
|
278
|
+
await inspectStyleBoundaries(options, program, report);
|
|
279
|
+
await inspectShowcaseCoverage(options, program, report);
|
|
280
|
+
await inspectScenarioCoverage(
|
|
281
|
+
options,
|
|
282
|
+
program,
|
|
283
|
+
report,
|
|
284
|
+
(file, rule, message) => advisories.push({ file: path.relative(root, file).replaceAll("\\", "/"), rule, message, line: 1, column: 1 }),
|
|
285
|
+
scenarioTrace,
|
|
286
|
+
);
|
|
287
|
+
const behaviors = await inspectBehaviors(options, program);
|
|
106
288
|
diagnostics.push(...behaviors.diagnostics);
|
|
107
|
-
diagnostics.push(...inspectTestBoundaries(options,units,behaviors.contracts,program));
|
|
108
|
-
inspectControllers(options, program, report, behaviors.contracts);
|
|
289
|
+
diagnostics.push(...(await inspectTestBoundaries(options, units, behaviors.contracts, program)));
|
|
290
|
+
await inspectControllers(options, program, report, behaviors.contracts);
|
|
109
291
|
// The foundation remains a fixed import-only entry, not an extra styling layer.
|
|
110
292
|
const foundationEntry = path.join(dsRoot, config.stylesEntry);
|
|
111
|
-
const registeredProperties=new Map(),
|
|
293
|
+
const registeredProperties = new Map(),
|
|
294
|
+
controlPaddingSeen = new Set();
|
|
112
295
|
const componentContrast = createComponentContrast(tokenInventory.tokens, config.themes, config.brands);
|
|
113
|
-
const layoutWidths = createLayoutWidths(tokenInventory.tokens, config
|
|
114
|
-
|
|
115
|
-
for (const glob of config.layout.
|
|
296
|
+
const layoutWidths = createLayoutWidths(tokenInventory.tokens, config, spatialFoundation),
|
|
297
|
+
fixedWidthOwner = globMatcher(config.layout.fixedWidthUnits);
|
|
298
|
+
for (const glob of config.layout.widthTokens)
|
|
299
|
+
if (!tokenInventory.tokens.some((token) => globMatcher([glob])(token.name)))
|
|
300
|
+
diagnostics.push({
|
|
301
|
+
rule: "layout-config",
|
|
302
|
+
file: "ds.config.json",
|
|
303
|
+
line: 1,
|
|
304
|
+
column: 1,
|
|
305
|
+
message: `layout.widthTokens entry ${glob} matches no declared token. Remove it or declare the token.`,
|
|
306
|
+
});
|
|
307
|
+
for (const glob of config.layout.fixedWidthUnits)
|
|
308
|
+
if (!units.units.some((unit) => globMatcher([glob])(unit.id) || unit.files.some((file) => globMatcher([glob])(file))))
|
|
309
|
+
diagnostics.push({
|
|
310
|
+
rule: "layout-config",
|
|
311
|
+
file: "ds.config.json",
|
|
312
|
+
line: 1,
|
|
313
|
+
column: 1,
|
|
314
|
+
message: `layout.fixedWidthUnits entry ${glob} matches no unit or owned file. Remove it or correct the path.`,
|
|
315
|
+
});
|
|
116
316
|
const ownerFixedWidths = [];
|
|
117
317
|
const fontRules = createFontRules(options, tokenInventory.tokens);
|
|
118
|
-
function checkRegistrations(file,css,offset={line:1}){
|
|
119
|
-
css
|
|
120
|
-
const line=offset.line+(rule.source?.start.line??1)-1;
|
|
121
|
-
try{
|
|
122
|
-
const registration=propertyRegistration(rule),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
318
|
+
async function checkRegistrations(file, css, offset = { line: 1 }) {
|
|
319
|
+
await walkAsync(css, "walkAtRules", /^property$/i, async (rule) => {
|
|
320
|
+
const line = offset.line + (rule.source?.start.line ?? 1) - 1;
|
|
321
|
+
try {
|
|
322
|
+
const registration = propertyRegistration(rule),
|
|
323
|
+
relative = units.relative(path.relative(root, file));
|
|
324
|
+
const owner = units.owner(relative),
|
|
325
|
+
foundation = isInside(path.join(dsRoot, config.tokenDir), file);
|
|
326
|
+
if (foundation) {
|
|
327
|
+
let defined = false;
|
|
328
|
+
css.walkDecls(registration.name, () => {
|
|
329
|
+
defined = true;
|
|
330
|
+
});
|
|
331
|
+
if (
|
|
332
|
+
!isSharedToken(registration.name) ||
|
|
333
|
+
!declaredTokens.has(registration.name) ||
|
|
334
|
+
!defined ||
|
|
335
|
+
["base.css", "fonts.css"].includes(path.basename(file))
|
|
336
|
+
)
|
|
337
|
+
throw new Error("Shared @property registrations belong beside their real token definitions in foundation value sheets, not base.css or fonts.css.");
|
|
338
|
+
} else {
|
|
339
|
+
if (!owner || !/^(?:components|patterns|review)\//.test(owner))
|
|
340
|
+
throw new Error(
|
|
341
|
+
"@property belongs to its component/pattern/review implementation or real token value sheet, never application, scenario, controller or shared reset styling.",
|
|
342
|
+
);
|
|
343
|
+
const violation = await checkComponentVariable(registration.name, file, options);
|
|
344
|
+
if (violation) throw new Error(violation.message);
|
|
133
345
|
}
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
346
|
+
for (const descriptor of rule.nodes ?? [])
|
|
347
|
+
if (descriptor.type === "decl")
|
|
348
|
+
for (const ref of references(descriptor.value)) {
|
|
349
|
+
if (!/^(?:--ds-|--ux-|--showcase-)/.test(ref.name) && (!isSharedToken(ref.name) || (!declaredTokens.has(ref.name) && !ref.fallback)))
|
|
350
|
+
throw new Error(`Invalid or cross-owner token reference ${ref.name} in registration metadata.`);
|
|
351
|
+
}
|
|
352
|
+
const previous = registeredProperties.get(registration.name);
|
|
353
|
+
if (previous && (previous.owner !== owner || previous.signature !== registration.signature))
|
|
354
|
+
throw new Error(
|
|
355
|
+
`Conflicting @property registration for ${registration.name}; ${path.relative(root, previous.file)} already registers it. Keep one owner and identical descriptors across that owner's modules.`,
|
|
356
|
+
);
|
|
357
|
+
registeredProperties.set(registration.name, { ...registration, owner, file });
|
|
358
|
+
} catch (error) {
|
|
359
|
+
report(file, "property-registration", `${error.message} See ads://guides/atomic-styles.`, line, rule.source?.start.column ?? 1);
|
|
360
|
+
diagnostics.at(-1).guidanceUri = "ads://guides/atomic-styles";
|
|
361
|
+
}
|
|
138
362
|
});
|
|
139
363
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const imports = css.nodes.filter((node) => node.type !== "comment");
|
|
143
|
-
const expected = foundationFiles.filter((name) => name !== "fonts.css" || existsSync(path.join(dsRoot, config.tokenDir, name))).map((name) => path.join(dsRoot, config.tokenDir, name));
|
|
144
|
-
const actual = imports.map(node => foundationImportTarget(node, foundationEntry));
|
|
145
|
-
if (actual.length !== expected.length || actual.some((file, index) => file !== expected[index] || !existsSync(file))) report(foundationEntry, "styles-entry", "Foundation CSS must import only fonts (when present), colors, typography, spacing, elevation, base and the generated themes.generated.css, in that order.");
|
|
146
|
-
} catch (error) { report(foundationEntry, "css-syntax", error.reason ?? error.message, error.line ?? 1); }
|
|
147
|
-
function checkCss(file, text, offset = { line: 1, column: 1 }, foundation = false) {
|
|
364
|
+
async function checkCss(file, text, offset, foundation = false, template) {
|
|
365
|
+
if (offset === undefined) offset = { line: 1, column: 1 };
|
|
148
366
|
let css;
|
|
149
|
-
try {
|
|
150
|
-
|
|
367
|
+
try {
|
|
368
|
+
css = timing.timeStage("check-css-parse", () => postcss.parse(text, { from: file }));
|
|
369
|
+
// This tree is owned by this check. Normalize once so sizing, token,
|
|
370
|
+
// ownership and construction rules all see the same CSS property identity.
|
|
371
|
+
css.walkDecls(decl=>{decl.prop=spatialCss.propertyName(decl.prop);});
|
|
372
|
+
} catch (error) {
|
|
373
|
+
report(file, "css-syntax", error.reason ?? error.message, offset.line + (error.line ?? 1) - 1);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
const spatialFact = spatialComposition.record(template, css);
|
|
378
|
+
construction.expandConstructionStyles(css, spatialFoundation, {deferPlacement:!!template});
|
|
379
|
+
spatialComposition.compiled(spatialFact, css);
|
|
380
|
+
} catch (error) {
|
|
381
|
+
const rule = error.rule ?? "grid-construction", guide = rule === "lockup-construction" ? "branding" : "layout";
|
|
382
|
+
report(file, rule, `${error.message} See ads://guides/${guide}.`, offset.line + (error.line ?? 1) - 1, error.column ?? offset.column);
|
|
383
|
+
diagnostics.at(-1).guidanceUri = `ads://guides/${guide}`;
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
151
386
|
layers.collectComponentStyles(file, css);
|
|
152
387
|
layerStyles.push({ file, css, offset });
|
|
153
388
|
if (foundation || !isDevelopmentFile(file, options)) fontRules.collect(css, file, offset);
|
|
154
|
-
checkRegistrations(file,css,offset);
|
|
155
|
-
if (!foundation && !isDevelopmentFile(file, options) && ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file)))
|
|
156
|
-
|
|
157
|
-
|
|
389
|
+
await checkRegistrations(file, css, offset);
|
|
390
|
+
if (!foundation && !isDevelopmentFile(file, options) && ["components", "patterns"].some((layer) => isInside(path.join(dsRoot, layer), file)))
|
|
391
|
+
componentContrast.collect(path.relative(root, file).replaceAll("\\", "/"), css, offset);
|
|
392
|
+
if (
|
|
393
|
+
!foundation &&
|
|
394
|
+
(isInside(path.join(dsRoot, "composition"), file) ||
|
|
395
|
+
(!isDevelopmentFile(file, options) && ["components", "patterns"].some((layer) => isInside(path.join(dsRoot, layer), file))))
|
|
396
|
+
) {
|
|
397
|
+
const relative = path.relative(root, file).replaceAll("\\", "/"),
|
|
398
|
+
owner = units.owner(units.relative(path.relative(root, file)));
|
|
158
399
|
const widths = layoutWidths.inspect(css, relative, offset);
|
|
159
400
|
if (!fixedWidthOwner(relative) && !(owner && fixedWidthOwner(owner))) advisories.push(...widths);
|
|
160
|
-
else ownerFixedWidths.push(...widths.filter(finding => finding.rule === "layout-fixed-width"));
|
|
401
|
+
else ownerFixedWidths.push(...widths.filter((finding) => finding.rule === "layout-fixed-width"));
|
|
161
402
|
}
|
|
162
403
|
// Linaria templates are checked once per resolved interpolation variant.
|
|
163
|
-
if (!foundation)
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
404
|
+
if (!foundation)
|
|
405
|
+
for (const finding of controlPaddingAdvisories(css, { tokens: declaredTokens, file: path.relative(root, file).replaceAll("\\", "/"), offset })) {
|
|
406
|
+
const key = JSON.stringify([finding.file, finding.line, finding.column, finding.message]);
|
|
407
|
+
if (!controlPaddingSeen.has(key)) {
|
|
408
|
+
controlPaddingSeen.add(key);
|
|
409
|
+
advisories.push(finding);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (
|
|
413
|
+
!foundation &&
|
|
414
|
+
!isReviewFile(file, options) &&
|
|
415
|
+
(isDevelopmentFile(file, options) ||
|
|
416
|
+
(!isInside(path.join(dsRoot, "components"), file) && !isInside(path.join(dsRoot, "patterns"), file) && file !== foundationEntry))
|
|
417
|
+
)
|
|
418
|
+
report(file, "style-ownership", "Visual CSS belongs to the local ADS's runtime components/patterns or development review implementations.");
|
|
419
|
+
if (
|
|
420
|
+
isDevelopmentFile(file, options) &&
|
|
421
|
+
!isReviewFile(file, options) &&
|
|
422
|
+
css.nodes.some((node) => node.type !== "comment" && !(node.type === "atrule" && node.name === "import"))
|
|
423
|
+
)
|
|
424
|
+
report(file, "showcase-style", `Scenarios and fixtures define no styles. ${scenarioLayoutGuidance}`, offset.line);
|
|
425
|
+
await walkAsync(css, "walkAtRules", "import", async (rule) => {
|
|
426
|
+
if (foundation)
|
|
427
|
+
report(
|
|
428
|
+
file,
|
|
429
|
+
"foundation-import",
|
|
430
|
+
"Import foundation sheets through the configured styles entry. Token sheets cannot import an unchecked styling layer.",
|
|
431
|
+
rule.source.start.line,
|
|
432
|
+
);
|
|
171
433
|
const first = valueParser(rule.params).nodes.find((node) => node.type !== "space" && node.type !== "comment");
|
|
172
434
|
const specifier = first?.type === "string" ? first.value : first?.type === "function" && first.value === "url" ? first.nodes[0]?.value : null;
|
|
173
435
|
if (!specifier || /^(?:[a-z]+:|\/\/)/i.test(specifier)) return;
|
|
174
436
|
const line = offset.line + rule.source.start.line - 1;
|
|
175
|
-
if (importViolation(specifier, file, options, resolveImport))
|
|
176
|
-
|
|
437
|
+
if (await importViolation(specifier, file, options, resolveImport))
|
|
438
|
+
report(file, "public-import", `Import through ${config.publicAlias}, not ADS implementation paths.`, line);
|
|
439
|
+
if (await showcaseImportViolation(specifier, file, options, resolveImport))
|
|
440
|
+
report(file, "showcase-import", "Showcase code and styles are development fixtures; runtime code must not import them.", line);
|
|
177
441
|
});
|
|
178
442
|
css.walkRules((rule) => {
|
|
179
443
|
if (foundation) {
|
|
180
|
-
if (rule.parent.type === "rule")
|
|
181
|
-
|
|
444
|
+
if (rule.parent.type === "rule")
|
|
445
|
+
report(
|
|
446
|
+
file,
|
|
447
|
+
"foundation-role",
|
|
448
|
+
"Foundation rules cannot nest owner/context selectors. Use root theme conditions or Linaria owners.",
|
|
449
|
+
rule.source.start.line,
|
|
450
|
+
);
|
|
451
|
+
const violation = foundationSelector(rule.selector, { definitions: rule.nodes.some((node) => node.type === "decl" && node.prop.startsWith("--")) });
|
|
182
452
|
if (violation) report(file, "foundation-selector", violation, rule.source.start.line, rule.source.start.column);
|
|
183
453
|
}
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
454
|
+
if (
|
|
455
|
+
isInside(path.join(dsRoot, "showcase"), file) &&
|
|
456
|
+
/:(?:hover|active|focus(?:-visible|-within)?|checked|disabled|enabled)\b|\[(?:aria-(?:selected|pressed|checked|disabled|expanded)|data-state)\b/.test(
|
|
457
|
+
rule.selector,
|
|
458
|
+
)
|
|
459
|
+
)
|
|
460
|
+
report(
|
|
461
|
+
file,
|
|
462
|
+
"showcase-state",
|
|
463
|
+
"Interactive state styling belongs to the real ADS component or pattern, not showcase or mock styles.",
|
|
464
|
+
offset.line + rule.source.start.line - 1,
|
|
465
|
+
);
|
|
466
|
+
if (
|
|
467
|
+
!foundation &&
|
|
468
|
+
(isReviewFile(file, options) || ["components", "patterns"].some((layer) => isInside(path.join(dsRoot, layer), file))) &&
|
|
469
|
+
themeAncestorSelector(rule.selector)
|
|
470
|
+
)
|
|
471
|
+
report(
|
|
472
|
+
file,
|
|
473
|
+
"theme-selector",
|
|
474
|
+
"Theme and brand selectors don't follow the nearest section; show theme- or brand-specific content with display: var(--display-<theme>, <display>), and give theme- or brand-specific values as token halves.",
|
|
475
|
+
offset.line + rule.source.start.line - 1,
|
|
476
|
+
rule.source.start.column,
|
|
477
|
+
{ severity: findingSeverity("theme-selector") },
|
|
478
|
+
);
|
|
479
|
+
if (/\.ads-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "components"), file))
|
|
480
|
+
report(file, "style-ownership", "ADS component internals are owned by components, not app or showcase CSS.", offset.line + rule.source.start.line - 1);
|
|
481
|
+
if (/\.ux-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "patterns"), file) && !isReviewFile(file, options))
|
|
482
|
+
report(file, "style-ownership", "Pattern internals are owned by patterns, not app or scenario CSS.", offset.line + rule.source.start.line - 1);
|
|
483
|
+
if (/\.showcase-[\w-]+/.test(rule.selector) && !isInside(path.join(dsRoot, "showcase"), file))
|
|
484
|
+
report(file, "style-ownership", "Showcase internals are owned by showcase scaffolding.", offset.line + rule.source.start.line - 1);
|
|
193
485
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
486
|
+
if (foundation)
|
|
487
|
+
css.walkAtRules((rule) => {
|
|
488
|
+
if (/(?:^|-)keyframes$|^(?:scope|custom-selector|starting-style)$/i.test(rule.name))
|
|
489
|
+
report(
|
|
490
|
+
file,
|
|
491
|
+
"foundation-role",
|
|
492
|
+
"Animations and scoped UI styles belong in their component/pattern's Linaria source, not the token foundation.",
|
|
493
|
+
rule.source.start.line,
|
|
494
|
+
);
|
|
495
|
+
if (rule.name === "font-face" && path.basename(file) !== "fonts.css")
|
|
496
|
+
report(file, "foundation-role", "Font faces belong in the canonical fonts.css foundation sheet.", rule.source.start.line);
|
|
497
|
+
});
|
|
498
|
+
await walkAsync(css, "walkDecls", async (decl) => {
|
|
499
|
+
const propertyDescriptor = decl.parent.type === "atrule" && decl.parent.name.toLowerCase() === "property";
|
|
500
|
+
if ((foundation || ["components", "patterns"].some((layer) => isInside(path.join(dsRoot, layer), file))) && /\blight-dark\(/i.test(decl.value))
|
|
501
|
+
report(
|
|
502
|
+
file,
|
|
503
|
+
"theme-light-dark",
|
|
504
|
+
"Give per-theme values as token halves (--x-light, --x-dark); light-dark() is limited to two schemes.",
|
|
505
|
+
offset.line + decl.source.start.line - 1,
|
|
506
|
+
decl.source.start.column,
|
|
507
|
+
{ severity: findingSeverity("theme-light-dark") },
|
|
508
|
+
);
|
|
197
509
|
if (foundation && decl.prop.startsWith("--")) {
|
|
198
|
-
if (path.basename(file) === "base.css")
|
|
510
|
+
if (path.basename(file) === "base.css")
|
|
511
|
+
report(file, "foundation-role", "Shared token definitions belong in value sheets, not base.css.", decl.source.start.line, decl.source.start.column);
|
|
199
512
|
return; // Definition names, values and aliases are validated by inspectTokens.
|
|
200
513
|
}
|
|
201
514
|
const fontDescriptor = foundation && path.basename(file) === "fonts.css" && decl.parent.type === "atrule" && decl.parent.name === "font-face";
|
|
202
|
-
if (foundation && !fontDescriptor && !propertyDescriptor && (path.basename(file) !== "base.css" || decl.parent.type !== "rule"))
|
|
515
|
+
if (foundation && !fontDescriptor && !propertyDescriptor && (path.basename(file) !== "base.css" || decl.parent.type !== "rule"))
|
|
516
|
+
report(
|
|
517
|
+
file,
|
|
518
|
+
"foundation-role",
|
|
519
|
+
"Token sheets contain shared definitions; native defaults belong in base.css, font descriptors in fonts.css, and UI styling in Linaria owners.",
|
|
520
|
+
decl.source.start.line,
|
|
521
|
+
decl.source.start.column,
|
|
522
|
+
);
|
|
203
523
|
if (foundation && path.basename(file) === "base.css" && decl.parent.type === "rule") {
|
|
204
524
|
const violation = foundationDeclaration(decl.parent, decl);
|
|
205
525
|
if (violation) report(file, "foundation-role", violation, decl.source.start.line, decl.source.start.column);
|
|
206
526
|
}
|
|
207
|
-
const variable = checkComponentVariable(decl.prop, file, options);
|
|
527
|
+
const variable = await checkComponentVariable(decl.prop, file, options);
|
|
208
528
|
if (variable) report(file, variable.rule, variable.message, offset.line + decl.source.start.line - 1, decl.source.start.column);
|
|
209
529
|
for (const ref of references(decl.value)) {
|
|
210
|
-
const binding = runtimeBindingOwner(options, ref.name);
|
|
530
|
+
const binding = await runtimeBindingOwner(options, ref.name);
|
|
211
531
|
if (binding) {
|
|
212
|
-
if (units.owner(units.relative(path.relative(root, file))) !== binding.unit)
|
|
532
|
+
if (units.owner(units.relative(path.relative(root, file))) !== binding.unit)
|
|
533
|
+
report(
|
|
534
|
+
file,
|
|
535
|
+
"binding-ownership",
|
|
536
|
+
`${ref.name} is an instance binding owned by ${binding.unit}, not a shared design token.`,
|
|
537
|
+
offset.line + decl.source.start.line - 1,
|
|
538
|
+
decl.source.start.column,
|
|
539
|
+
);
|
|
213
540
|
continue;
|
|
214
541
|
}
|
|
215
542
|
if (generatedSwitches.has(ref.name)) continue;
|
|
216
|
-
if (ref.name.startsWith("--display-")) {
|
|
543
|
+
if (ref.name.startsWith("--display-")) {
|
|
544
|
+
report(
|
|
545
|
+
file,
|
|
546
|
+
"token-reference",
|
|
547
|
+
`${ref.name} is not a display switch; themes.generated.css defines ${[...generatedSwitches].join(", ")} from ds.config.json themes and brands.`,
|
|
548
|
+
offset.line + decl.source.start.line - 1,
|
|
549
|
+
decl.source.start.column,
|
|
550
|
+
);
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
217
553
|
const local = /^(?:--ds-|--ux-|--showcase-)/.test(ref.name);
|
|
218
|
-
if (foundation && local)
|
|
219
|
-
|
|
220
|
-
|
|
554
|
+
if (foundation && local)
|
|
555
|
+
report(
|
|
556
|
+
file,
|
|
557
|
+
"foundation-role",
|
|
558
|
+
"Foundation defaults consume shared tokens, not component, pattern or scenario-local variables.",
|
|
559
|
+
offset.line + decl.source.start.line - 1,
|
|
560
|
+
decl.source.start.column,
|
|
561
|
+
);
|
|
562
|
+
if (!local && !isSharedToken(ref.name))
|
|
563
|
+
report(
|
|
564
|
+
file,
|
|
565
|
+
"token-name",
|
|
566
|
+
tokenNameGuidance(ref.name, variableLayer(file, options)),
|
|
567
|
+
offset.line + decl.source.start.line - 1,
|
|
568
|
+
decl.source.start.column,
|
|
569
|
+
);
|
|
570
|
+
else if (!local && !declaredTokens.has(ref.name) && !ref.fallback)
|
|
571
|
+
report(file, "token-reference", `Undefined shared token ${ref.name}.`, offset.line + decl.source.start.line - 1, decl.source.start.column);
|
|
221
572
|
}
|
|
222
573
|
if (fontDescriptor || propertyDescriptor) return; // Font metadata defines source assets, not token-backed UI styles.
|
|
223
574
|
const violations = new Set();
|
|
224
|
-
if(decl.value.includes("__ds_expression__"))
|
|
575
|
+
if (decl.value.includes("__ds_expression__"))
|
|
576
|
+
violations.add(
|
|
577
|
+
"Cannot establish this interpolated design value from source. Use a source-resolvable shared token/mapping; unknown interpolation does not grant permission for private design values.",
|
|
578
|
+
);
|
|
225
579
|
valueParser(decl.value).walk((node) => {
|
|
226
580
|
if (node.type === "function" && node.value === "url") return false;
|
|
227
|
-
if (node.type === "word" && decl.prop.startsWith("--") && isColorKeyword(node.value))
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
|
|
581
|
+
if (node.type === "word" && decl.prop.startsWith("--") && isColorKeyword(node.value))
|
|
582
|
+
violations.add("Component variables map shared Data; named colors also require shared tokens.");
|
|
583
|
+
if (
|
|
584
|
+
node.type === "word" &&
|
|
585
|
+
(/^#[\da-f]{3,8}$/i.test(node.value) ||
|
|
586
|
+
(tokenLengthLiteral(node.value) &&
|
|
587
|
+
!(
|
|
588
|
+
isReviewFile(file, options) &&
|
|
589
|
+
/^(?:(?:min-|max-)?(?:width|height|inline-size|block-size)|flex-basis|grid-template-columns|grid-template-rows)$/.test(decl.prop)
|
|
590
|
+
)) ||
|
|
591
|
+
["s", "ms"].includes(numericCssUnit(node.value)))
|
|
592
|
+
)
|
|
593
|
+
violations.add(
|
|
594
|
+
"Use a token for colors, absolute/font-relative lengths (including ch), and durations. Unitless geometry and structural angle/viewport/container relationships remain valid.",
|
|
595
|
+
);
|
|
596
|
+
if (node.type === "function" && /^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|cubic-bezier)$/.test(node.value))
|
|
597
|
+
violations.add("Define color formulas and easing in tokens.");
|
|
598
|
+
if (node.type === "function" && /^(?:blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia)$/.test(node.value))
|
|
599
|
+
violations.add("Define visual filter effects in tokens.");
|
|
231
600
|
if (node.type === "word" && /^ease(?:-in|-out|-in-out)?$/.test(node.value)) violations.add("Use a motion token for easing.");
|
|
232
|
-
if (
|
|
601
|
+
if (
|
|
602
|
+
node.type === "word" &&
|
|
603
|
+
/^(?:color|background-color|(?:border|outline|caret|text-decoration|column-rule)(?:-[a-z]+)?-color|fill|stroke)$/.test(decl.prop) &&
|
|
604
|
+
/^[a-z]+$/i.test(node.value) &&
|
|
605
|
+
!/^(?:inherit|initial|unset|revert|currentcolor|transparent|none)$/i.test(node.value)
|
|
606
|
+
)
|
|
607
|
+
violations.add("Use a semantic color token.");
|
|
233
608
|
});
|
|
234
|
-
if (
|
|
609
|
+
if (
|
|
610
|
+
/^(?:font-family|font-weight|z-index)$/.test(decl.prop) &&
|
|
611
|
+
!/^(?:var\(|inherit$|initial$|unset$|revert(?:-layer)?$|auto$)/.test(decl.value) &&
|
|
612
|
+
!(foundation && decl.prop === "font-weight" && /^(?:bolder|lighter)$/.test(decl.value))
|
|
613
|
+
)
|
|
614
|
+
violations.add("Use a semantic typography or layering token.");
|
|
235
615
|
for (const message of violations) report(file, "style-token", message, offset.line + decl.source.start.line - 1, decl.source.start.column);
|
|
236
616
|
});
|
|
237
617
|
}
|
|
238
618
|
for (const file of files) {
|
|
239
619
|
const role = adsFileRole(file);
|
|
240
|
-
|
|
241
|
-
|
|
620
|
+
if (
|
|
621
|
+
["review", "showcase", "composition", "brand"].some((directory) => isInside(path.join(dsRoot, directory), file)) &&
|
|
622
|
+
!role &&
|
|
623
|
+
!isTestFile(file) &&
|
|
624
|
+
!/\.d\.[cm]?ts$/.test(file)
|
|
625
|
+
)
|
|
626
|
+
report(
|
|
627
|
+
file,
|
|
628
|
+
"development-role",
|
|
629
|
+
"Project ADS development sources must use a .ads.* role: .ads.scenario.*, .ads.fixture.*, .ads.helpers.*, .ads.review.* or .ads.mount.*. A folder name does not replace the development-only filename marker.",
|
|
630
|
+
);
|
|
631
|
+
const roleExtension = ["contract", "exports"].includes(role)
|
|
632
|
+
? /\.[cm]?ts$/.test(file)
|
|
633
|
+
: role === "review"
|
|
634
|
+
? /\.(?:[cm]?[jt]sx?|css)$/.test(file)
|
|
635
|
+
: role === "mount"
|
|
636
|
+
? /\.(?:[cm]?[jt]sx?|html)$/.test(file)
|
|
637
|
+
: role === "fixture"
|
|
638
|
+
? /\.(?:[cm]?[jt]sx?|json)$/.test(file)
|
|
639
|
+
: /\.[cm]?[jt]sx?$/.test(file);
|
|
640
|
+
if (
|
|
641
|
+
role &&
|
|
642
|
+
!configurationScripts.has(file) &&
|
|
643
|
+
(!["contract", "exports", "scenario", "fixture", "helpers", "review", "mount", "test", "spec", "behavior.spec"].includes(role) || !roleExtension)
|
|
644
|
+
)
|
|
645
|
+
report(
|
|
646
|
+
file,
|
|
647
|
+
"development-role",
|
|
648
|
+
`Unknown .ads. role or unsupported extension: ${role}. Use a TypeScript contract, a script scenario/fixture/helpers/test/behavior.spec, JSON fixture, .ads.review.* helper/style or .ads.mount.* adapter; marking development code does not grant styling or mutation permissions.`,
|
|
649
|
+
);
|
|
242
650
|
// The generated theme sheet and palette are checked for freshness with the tokens, not authored.
|
|
243
|
-
if (generatedThemeFiles.some(generated => file === path.join(dsRoot, config.tokenDir, generated))) continue;
|
|
244
|
-
if (file.endsWith(".css") && isInside(path.join(dsRoot, config.tokenDir), file) && !isDevelopmentFile(file, options)) {
|
|
245
|
-
|
|
651
|
+
if (generatedThemeFiles.some((generated) => file === path.join(dsRoot, config.tokenDir, generated))) continue;
|
|
652
|
+
if (file.endsWith(".css") && isInside(path.join(dsRoot, config.tokenDir), file) && !isDevelopmentFile(file, options)) {
|
|
653
|
+
await checkCss(file, readFileSync(file, "utf8"), undefined, true);
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
if (file.endsWith(".html")) {
|
|
657
|
+
inspectHtml(readFileSync(file, "utf8"), (rule, message, line) => report(file, rule, message, line));
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
246
660
|
if (file.endsWith(".css")) {
|
|
247
661
|
const text = readFileSync(file, "utf8");
|
|
248
662
|
if (file === path.join(sourceRoot, "app-mount.css") && isMountCss(text)) continue;
|
|
249
|
-
checkCss(file, text);
|
|
663
|
+
await checkCss(file, text);
|
|
664
|
+
continue;
|
|
250
665
|
}
|
|
251
|
-
const source = program.getSourceFile(file);
|
|
666
|
+
const source = await program.getSourceFile(file);
|
|
252
667
|
if (!source) continue;
|
|
253
|
-
advisories.push(...pointerCaptureAdvisories(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
|
|
254
|
-
advisories.push(...atomicCompositionReview(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
|
|
255
|
-
if (["components", "patterns"].some(section => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options))
|
|
256
|
-
|
|
668
|
+
advisories.push(...pointerCaptureAdvisories(source).map((entry) => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
|
|
669
|
+
advisories.push(...(await atomicCompositionReview(source)).map((entry) => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
|
|
670
|
+
if (["components", "patterns"].some((section) => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options))
|
|
671
|
+
advisories.push(...(await renderColorProbe(source)).map((entry) => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
|
|
672
|
+
for (const diagnostic of await program.getSyntacticDiagnostics(source)) {
|
|
257
673
|
const position = source.getLineAndCharacterOfPosition(diagnostic.start ?? 0);
|
|
258
674
|
report(file, "source-syntax", ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"), position.line + 1, position.character + 1);
|
|
259
675
|
}
|
|
260
|
-
const inlineAllowed =
|
|
676
|
+
const inlineAllowed = stylePolicy.inlineStyleFiles.some((allowed) => path.resolve(root, allowed) === file);
|
|
261
677
|
const showcase = isDevelopmentFile(file, options) && !isTestFile(file) && !isReviewFile(file, options);
|
|
262
678
|
function nodeReport(node, rule, message, detail) {
|
|
263
679
|
const position = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
264
680
|
report(file, rule, message, position.line + 1, position.character + 1);
|
|
265
681
|
if (detail) Object.assign(diagnostics.at(-1), detail);
|
|
266
682
|
}
|
|
267
|
-
function scenarioClass(node, expression, property = false) {
|
|
268
|
-
|
|
269
|
-
|
|
683
|
+
async function scenarioClass(node, expression, property = false) {
|
|
684
|
+
if (expression && ts.isCallExpression(expression) && ts.isIdentifier(expression.expression) && expression.arguments.every(ts.isStringLiteralLike)) {
|
|
685
|
+
const symbol = await checker.getSymbolAtLocation(expression.expression);
|
|
686
|
+
if (
|
|
687
|
+
symbol?.declarations?.some(
|
|
688
|
+
(decl) =>
|
|
689
|
+
ts.isImportSpecifier(decl) &&
|
|
690
|
+
(decl.propertyName ?? decl.name).text === "previewFrameClasses" &&
|
|
691
|
+
decl.parent.parent.parent.moduleSpecifier.text === "@reqvire-org/ads/preview",
|
|
692
|
+
)
|
|
693
|
+
)
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
const proof = await scenarioTrace.classValue(expression, property);
|
|
697
|
+
if (proof.present && !proof.ok)
|
|
698
|
+
nodeReport(
|
|
699
|
+
node,
|
|
700
|
+
"showcase-class",
|
|
701
|
+
`Scenarios define no custom class names. A public class helper must return runtime-owned Linaria styles; stable hooks authored in that owner may accompany real styles. Arbitrary strings, private styles and forwarded consumer classes do not qualify.${proof.reasons.length ? ` ${proof.reasons.join(" ")}` : ""} ${scenarioLayoutGuidance} See ads://guides/scenarios.`,
|
|
702
|
+
);
|
|
270
703
|
}
|
|
271
|
-
function scenarioControl(node, native) {
|
|
272
|
-
const proof = (scenarioSlot ??= createScenarioSlots(program, options))(node);
|
|
704
|
+
async function scenarioControl(node, native) {
|
|
705
|
+
const proof = await (scenarioSlot ??= await createScenarioSlots(program, options))(node);
|
|
273
706
|
if (proof.ok) return;
|
|
274
|
-
const selector = native
|
|
275
|
-
|
|
707
|
+
const selector = native
|
|
708
|
+
? await (scenarioSelector ??= await createScenarioSelectors(program, options))(node)
|
|
709
|
+
: { ok: false, reasons: ["A selector cannot establish custom widget behavior or keyboard semantics."] };
|
|
710
|
+
if (!selector.ok)
|
|
711
|
+
nodeReport(
|
|
712
|
+
node,
|
|
713
|
+
"showcase-control",
|
|
714
|
+
`Scenario controls must compose public ADS runtime UI. Native semantics require source evidence of owned cloning props or an attached runtime Linaria selector addressing that native tag or a verified runtime-owned part in that position. A prop name, broad selector or scenario-authored marker grants no permission. ${selector.reasons.join(" ")} Preserve valid APIs when tracing is inconclusive; report the limitation instead of changing the API to satisfy coverage. ${scenarioLayoutGuidance} See ads://guides/scenarios.`,
|
|
715
|
+
{ failure: failure("architecture", "source-ownership", "ownership-not-proven", { certainty: "inconclusive" }) },
|
|
716
|
+
);
|
|
276
717
|
}
|
|
277
|
-
if (!showcase && (isInside(path.join(dsRoot, "components"), file) || isInside(path.join(dsRoot, "patterns"), file)))
|
|
278
|
-
|
|
718
|
+
if (!showcase && (isInside(path.join(dsRoot, "components"), file) || isInside(path.join(dsRoot, "patterns"), file)))
|
|
719
|
+
await inspectPublicProps(source, checker, nodeReport, paintContracts.allowedProperties);
|
|
720
|
+
async function isLinariaTag(tag) {
|
|
279
721
|
if (ts.isCallExpression(tag)) tag = tag.expression;
|
|
280
722
|
let symbolNode = tag;
|
|
281
723
|
while (ts.isPropertyAccessExpression(symbolNode)) symbolNode = symbolNode.expression;
|
|
282
|
-
const symbol = checker.getSymbolAtLocation(symbolNode);
|
|
724
|
+
const symbol = await checker.getSymbolAtLocation(symbolNode);
|
|
283
725
|
return symbol?.declarations?.some((decl) => {
|
|
284
726
|
if (ts.isImportSpecifier(decl)) {
|
|
285
727
|
const module = decl.parent.parent.parent.moduleSpecifier;
|
|
286
728
|
return ["css", "styled"].includes((decl.propertyName ?? decl.name).text) && ts.isStringLiteral(module) && module.text.startsWith("@linaria/");
|
|
287
729
|
}
|
|
288
|
-
if (
|
|
730
|
+
if (
|
|
731
|
+
ts.isNamespaceImport(decl) &&
|
|
732
|
+
ts.isPropertyAccessExpression(tag) &&
|
|
733
|
+
/^(?:css|styled)(?:\.|$)/.test(tag.getText(source).slice(symbolNode.getText(source).length + 1))
|
|
734
|
+
) {
|
|
289
735
|
const module = decl.parent.parent.moduleSpecifier;
|
|
290
736
|
return ts.isStringLiteral(module) && module.text.startsWith("@linaria/");
|
|
291
737
|
}
|
|
292
738
|
return false;
|
|
293
739
|
});
|
|
294
740
|
}
|
|
295
|
-
function inspectProperty(value) {
|
|
741
|
+
async function inspectProperty(value) {
|
|
296
742
|
if (ts.isPropertyAssignment(value) && (ts.isStringLiteralLike(value.name) || ts.isIdentifier(value.name))) {
|
|
297
|
-
const variable = checkComponentVariable(value.name.text, file, options);
|
|
743
|
+
const variable = await checkComponentVariable(value.name.text, file, options);
|
|
298
744
|
if (variable) nodeReport(value.name, variable.rule, variable.message);
|
|
299
745
|
}
|
|
300
|
-
|
|
746
|
+
await eachChild(value, inspectProperty);
|
|
301
747
|
}
|
|
302
748
|
function inspectClass(value) {
|
|
303
749
|
if (ts.isStringLiteralLike(value)) {
|
|
304
|
-
if (/(?:^|\s)ads-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "components"), file))
|
|
305
|
-
|
|
306
|
-
if (/(?:^|\s)
|
|
750
|
+
if (/(?:^|\s)ads-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "components"), file))
|
|
751
|
+
nodeReport(value, "style-ownership", "Primitive ads-* classes must be emitted by components, not consumers.");
|
|
752
|
+
if (/(?:^|\s)ux-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "patterns"), file) && !isReviewFile(file, options))
|
|
753
|
+
nodeReport(value, "style-ownership", "Pattern ux-* classes must be emitted by patterns, not consumers.");
|
|
754
|
+
if (/(?:^|\s)showcase-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "showcase"), file) && !isReviewFile(file, options))
|
|
755
|
+
nodeReport(value, "style-ownership", "Showcase hooks must be emitted by development review code, not runtime implementations.");
|
|
307
756
|
}
|
|
308
757
|
ts.forEachChild(value, inspectClass);
|
|
309
758
|
}
|
|
310
|
-
const nativePreact = (source
|
|
759
|
+
const nativePreact = jsxImportSource(source, compiler) === "preact";
|
|
311
760
|
function checkSvgAttribute(node, name) {
|
|
312
|
-
if (svgPresentation.has(name))
|
|
761
|
+
if (svgPresentation.has(name))
|
|
762
|
+
nodeReport(
|
|
763
|
+
node,
|
|
764
|
+
"svg-attribute",
|
|
765
|
+
`Native Preact SVG needs ${name.replace(/[A-Z]/g, (letter) => "-" + letter.toLowerCase())}; React-style ${name} is not normalized by its native renderer.`,
|
|
766
|
+
);
|
|
313
767
|
}
|
|
314
|
-
const lightDarkLiterals = ["components", "patterns"].some(section => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options);
|
|
315
|
-
|
|
768
|
+
const lightDarkLiterals = ["components", "patterns"].some((section) => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options);
|
|
769
|
+
// Per-file facts, computed once rather than at every syntax node.
|
|
770
|
+
const fileInDs = isInside(dsRoot, file),
|
|
771
|
+
testFile = isTestFile(file);
|
|
772
|
+
async function inLinariaTemplate(node) {
|
|
316
773
|
const template = ts.isTemplateMiddle(node) || ts.isTemplateTail(node) ? node.parent.parent : node.parent;
|
|
317
774
|
const tagged = ts.isTemplateExpression(template) ? template.parent : template;
|
|
318
|
-
return ts.isTaggedTemplateExpression(tagged) && isLinariaTag(tagged.tag);
|
|
775
|
+
return ts.isTaggedTemplateExpression(tagged) && (await isLinariaTag(tagged.tag));
|
|
319
776
|
}
|
|
320
|
-
function visit(node) {
|
|
777
|
+
async function visit(node) {
|
|
321
778
|
if (nativePreact && ts.isJsxAttribute(node) && ts.isIdentifier(node.name)) {
|
|
322
779
|
const parent = node.parent.parent;
|
|
323
|
-
if ((ts.isJsxOpeningElement(parent) || ts.isJsxSelfClosingElement(parent)) && ts.isIdentifier(parent.tagName) && svgTags.has(parent.tagName.text))
|
|
780
|
+
if ((ts.isJsxOpeningElement(parent) || ts.isJsxSelfClosingElement(parent)) && ts.isIdentifier(parent.tagName) && svgTags.has(parent.tagName.text))
|
|
781
|
+
checkSvgAttribute(node, node.name.text);
|
|
324
782
|
}
|
|
325
|
-
if (ts.isCallExpression(node) && uiOperation(node.expression, checker) === "createElement") {
|
|
783
|
+
if (ts.isCallExpression(node) && (await uiOperation(node.expression, checker)) === "createElement") {
|
|
326
784
|
const [tag, props] = node.arguments;
|
|
327
785
|
const properties = props && ts.isObjectLiteralExpression(props) ? props.properties : [];
|
|
328
786
|
for (const property of properties) {
|
|
329
787
|
if (!ts.isPropertyAssignment(property) || !(ts.isIdentifier(property.name) || ts.isStringLiteralLike(property.name))) continue;
|
|
330
|
-
if (tag && ts.isStringLiteralLike(tag) && svgTags.has(tag.text) && importedUiApi(node.expression, checker)?.module === "preact")
|
|
331
|
-
|
|
332
|
-
if (property.name.text === "style"
|
|
788
|
+
if (tag && ts.isStringLiteralLike(tag) && svgTags.has(tag.text) && (await importedUiApi(node.expression, checker))?.module === "preact")
|
|
789
|
+
checkSvgAttribute(property, property.name.text);
|
|
790
|
+
if (property.name.text === "style" && (!inlineAllowed || showcase))
|
|
791
|
+
nodeReport(property, "no-inline-style", showcase ? `Scenarios define no inline styles. ${scenarioLayoutGuidance}` : inlineStyleGuidance);
|
|
792
|
+
if (property.name.text === "style") await inspectProperty(property.initializer);
|
|
333
793
|
if (property.name.text === "className") inspectClass(property.initializer);
|
|
334
|
-
if (showcase && property.name.text === "className") scenarioClass(property, property.initializer);
|
|
794
|
+
if (showcase && property.name.text === "className") await scenarioClass(property, property.initializer);
|
|
335
795
|
}
|
|
336
|
-
if (showcase && props && !ts.isObjectLiteralExpression(props)) scenarioClass(props, props, true);
|
|
337
|
-
if (showcase) for (const property of properties) if (ts.isSpreadAssignment(property)) scenarioClass(property, property.expression, true);
|
|
796
|
+
if (showcase && props && !ts.isObjectLiteralExpression(props)) await scenarioClass(props, props, true);
|
|
797
|
+
if (showcase) for (const property of properties) if (ts.isSpreadAssignment(property)) await scenarioClass(property, property.expression, true);
|
|
338
798
|
if (showcase && tag && ts.isStringLiteralLike(tag)) {
|
|
339
|
-
const role = properties.find(
|
|
340
|
-
|
|
799
|
+
const role = properties.find(
|
|
800
|
+
(property) =>
|
|
801
|
+
ts.isPropertyAssignment(property) && (ts.isIdentifier(property.name) || ts.isStringLiteralLike(property.name)) && property.name.text === "role",
|
|
802
|
+
)?.initializer;
|
|
803
|
+
if (showcaseControls.has(tag.text) || (role && ts.isStringLiteralLike(role) && widgetRoles.has(role.text)))
|
|
804
|
+
await scenarioControl(node, showcaseControls.has(tag.text));
|
|
341
805
|
}
|
|
342
806
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
807
|
+
// Tests may stub or observe the network (a behavior spec injecting transport failures);
|
|
808
|
+
// the rule keeps business data out of UI and scenarios.
|
|
809
|
+
if (
|
|
810
|
+
fileInDs &&
|
|
811
|
+
!testFile &&
|
|
812
|
+
ts.isIdentifier(node) && ["fetch", "XMLHttpRequest", "WebSocket", "EventSource"].includes(node.text) &&
|
|
813
|
+
!(ts.isPropertyAccessExpression(node.parent) && node.parent.name === node)
|
|
814
|
+
) {
|
|
815
|
+
const declarations = (await checker.getSymbolAtLocation(node))?.declarations ?? [];
|
|
816
|
+
if (!declarations.some((declaration) => !declaration.getSourceFile().isDeclarationFile))
|
|
817
|
+
nodeReport(
|
|
818
|
+
node,
|
|
819
|
+
"data-access",
|
|
820
|
+
"ADS UI and scenarios receive business data through typed inputs or injected services. Direct network access belongs in an application adapter; fixture services remain local.",
|
|
821
|
+
);
|
|
346
822
|
}
|
|
347
|
-
if (
|
|
823
|
+
if (
|
|
824
|
+
fileInDs &&
|
|
825
|
+
!testFile &&
|
|
826
|
+
ts.isPropertyAccessExpression(node) &&
|
|
827
|
+
["window", "globalThis", "self"].includes(node.expression.getText(source)) &&
|
|
828
|
+
["fetch", "XMLHttpRequest", "WebSocket", "EventSource"].includes(node.name.text)
|
|
829
|
+
)
|
|
830
|
+
nodeReport(node, "data-access", "Inject the data service instead of using a global network API in ADS UI or scenarios.");
|
|
348
831
|
if (showcase && (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && ts.isIdentifier(node.tagName) && /^[a-z]/.test(node.tagName.text)) {
|
|
349
832
|
const role = node.attributes.properties.find((attr) => ts.isJsxAttribute(attr) && attr.name.text === "role")?.initializer;
|
|
350
|
-
const roleValue =
|
|
351
|
-
|
|
833
|
+
const roleValue =
|
|
834
|
+
role && ts.isStringLiteralLike(role)
|
|
835
|
+
? role.text
|
|
836
|
+
: role && ts.isJsxExpression(role) && role.expression && ts.isStringLiteralLike(role.expression)
|
|
837
|
+
? role.expression.text
|
|
838
|
+
: null;
|
|
839
|
+
if (showcaseControls.has(node.tagName.text) || widgetRoles.has(roleValue)) await scenarioControl(node, showcaseControls.has(node.tagName.text));
|
|
352
840
|
}
|
|
353
|
-
if (showcase && ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className")
|
|
354
|
-
|
|
841
|
+
if (showcase && ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className")
|
|
842
|
+
await scenarioClass(node, node.initializer && ts.isJsxExpression(node.initializer) ? node.initializer.expression : node.initializer);
|
|
843
|
+
if (showcase && ts.isJsxSpreadAttribute(node)) await scenarioClass(node, node.expression, true);
|
|
355
844
|
let specifier;
|
|
356
|
-
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier))
|
|
357
|
-
|
|
358
|
-
if (
|
|
359
|
-
|
|
360
|
-
if (
|
|
361
|
-
|
|
845
|
+
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier))
|
|
846
|
+
specifier = node.moduleSpecifier.text;
|
|
847
|
+
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword && node.arguments[0] && ts.isStringLiteral(node.arguments[0]))
|
|
848
|
+
specifier = node.arguments[0].text;
|
|
849
|
+
if (
|
|
850
|
+
specifier &&
|
|
851
|
+
!(configurationScripts.has(file) && (await resolveImport(specifier, file)).every((target) => configurationScripts.has(target))) &&
|
|
852
|
+
(await importViolation(specifier, file, options, resolveImport))
|
|
853
|
+
)
|
|
854
|
+
nodeReport(node, "public-import", `Import through ${config.publicAlias}, not ADS implementation paths.`);
|
|
855
|
+
if (
|
|
856
|
+
specifier &&
|
|
857
|
+
(await resolveImport(specifier, file)).some(
|
|
858
|
+
(target) =>
|
|
859
|
+
(specifier.startsWith(".") || existsSync(target)) &&
|
|
860
|
+
target.endsWith(".css") &&
|
|
861
|
+
isInside(root, target) &&
|
|
862
|
+
!isInside(dsRoot, target) &&
|
|
863
|
+
target !== path.join(sourceRoot, "app-mount.css") &&
|
|
864
|
+
!isInside(path.join(root, "node_modules"), target),
|
|
865
|
+
)
|
|
866
|
+
)
|
|
867
|
+
nodeReport(
|
|
868
|
+
node,
|
|
869
|
+
"style-ownership",
|
|
870
|
+
"Imported project CSS belongs to ADS components, patterns, or the foundation. Only structural app-mount.css is allowed outside the ADS.",
|
|
871
|
+
);
|
|
872
|
+
if (specifier && (await appImportViolation(specifier, file, options, resolveImport)))
|
|
873
|
+
nodeReport(
|
|
874
|
+
node,
|
|
875
|
+
"no-app-import",
|
|
876
|
+
"ADS implementations and showcase fixtures must not import app code. Use public ADS APIs with local fixture data; keep application integration harnesses in application tests.",
|
|
877
|
+
);
|
|
878
|
+
if (specifier && (await showcaseImportViolation(specifier, file, options, resolveImport)))
|
|
879
|
+
nodeReport(node, "showcase-import", "Showcase code and styles are development fixtures; runtime code must not import them.");
|
|
362
880
|
const boundStyle = runtimeContracts.allowedStyles.has(`${file}:${node.pos}`);
|
|
363
|
-
if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "style" && (!inlineAllowed || showcase) && !boundStyle)
|
|
881
|
+
if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "style" && (!inlineAllowed || showcase) && !boundStyle)
|
|
882
|
+
nodeReport(node, "no-inline-style", showcase ? `Scenarios define no inline styles. ${scenarioLayoutGuidance}` : inlineStyleGuidance);
|
|
364
883
|
if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "style" && node.initializer) {
|
|
365
|
-
inspectProperty(node.initializer);
|
|
884
|
+
await inspectProperty(node.initializer);
|
|
366
885
|
}
|
|
367
|
-
const mutation = styleWriteViolation(node, file, options);
|
|
886
|
+
const mutation = await styleWriteViolation(node, file, options);
|
|
368
887
|
if (mutation) nodeReport(node, "style-mutation", mutation);
|
|
369
|
-
if (!inlineAllowed && isUiCssProperties(node, checker) && !runtimeContracts.allowedStyleTypes.has(`${file}:${node.pos}`))
|
|
888
|
+
if (!inlineAllowed && (await isUiCssProperties(node, checker)) && !runtimeContracts.allowedStyleTypes.has(`${file}:${node.pos}`))
|
|
889
|
+
nodeReport(
|
|
890
|
+
node,
|
|
891
|
+
"css-properties",
|
|
892
|
+
"Keep CSSProperties out of the public API. Use deliberate component contracts or a documented measured-geometry renderer boundary; demo layout belongs in a development-only review/ helper.",
|
|
893
|
+
);
|
|
370
894
|
if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className" && node.initializer) {
|
|
371
895
|
inspectClass(node.initializer);
|
|
372
896
|
}
|
|
373
897
|
// Runtime inline values (style objects, inline custom properties, <style> text) give
|
|
374
898
|
// per-theme values with the generated themed(), not light-dark(); Linaria templates are
|
|
375
899
|
// checked as CSS above.
|
|
376
|
-
if (
|
|
377
|
-
|
|
900
|
+
if (
|
|
901
|
+
lightDarkLiterals &&
|
|
902
|
+
(ts.isStringLiteral(node) ||
|
|
903
|
+
ts.isNoSubstitutionTemplateLiteral(node) ||
|
|
904
|
+
ts.isTemplateHead(node) ||
|
|
905
|
+
ts.isTemplateMiddle(node) ||
|
|
906
|
+
ts.isTemplateTail(node)) &&
|
|
907
|
+
/\blight-dark\(/i.test(node.text) &&
|
|
908
|
+
!(await inLinariaTemplate(node))
|
|
909
|
+
)
|
|
910
|
+
nodeReport(
|
|
911
|
+
node,
|
|
912
|
+
"theme-light-dark",
|
|
913
|
+
`Give per-theme values as token halves (--x-light, --x-dark); light-dark() is limited to two schemes; for runtime values use themed() from ${config.tokenDir}/${generatedPaletteFile}.`,
|
|
914
|
+
{ severity: findingSeverity("theme-light-dark") },
|
|
915
|
+
);
|
|
916
|
+
if (ts.isTaggedTemplateExpression(node) && (await isLinariaTag(node.tag))) {
|
|
378
917
|
const template = node.template;
|
|
379
|
-
const
|
|
918
|
+
const variants = await designTemplateVariants(template, designValues);
|
|
919
|
+
if (variants.reason) nodeReport(variants.node, "design-value-source", `Cannot establish every interpolated style alternative from source. ${variants.reason}`);
|
|
380
920
|
const position = source.getLineAndCharacterOfPosition(template.getStart(source) + 1);
|
|
381
|
-
for(const text of texts)checkCss(file, text, { line: position.line + 1, column: position.character + 1 });
|
|
921
|
+
for (const text of variants.texts) await checkCss(file, text, { line: position.line + 1, column: position.character + 1 }, false, node);
|
|
382
922
|
}
|
|
383
|
-
|
|
923
|
+
await eachChild(node, visit);
|
|
384
924
|
}
|
|
385
|
-
visit(source);
|
|
925
|
+
await visit(source);
|
|
386
926
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
927
|
+
diagnostics.push(...await spatialComposition.check());
|
|
928
|
+
inspectDesignAliases(layerStyles, options, report);
|
|
929
|
+
for (const { file, css, offset } of layerStyles) await layers.inspectStyles(file, css, offset);
|
|
930
|
+
advisories.push(
|
|
931
|
+
...(tokenInventory.advisories ?? []),
|
|
932
|
+
...assetAdvisories,
|
|
933
|
+
...(await a11ySourceAdvisories(options)),
|
|
934
|
+
...(await imageAttributeFindings(options)),
|
|
935
|
+
...componentContrast.findings(),
|
|
936
|
+
...layoutWidths.declaredWidths(ownerFixedWidths),
|
|
937
|
+
...fontRules.findings(),
|
|
938
|
+
);
|
|
390
939
|
// Errors block by class; bounded clients see review items before informational limits.
|
|
391
|
-
const routed=routeFindings(diagnostics,advisories);
|
|
392
|
-
const uniqueDiagnostics=
|
|
393
|
-
|
|
940
|
+
const routed = routeFindings(diagnostics, advisories);
|
|
941
|
+
const uniqueDiagnostics = [
|
|
942
|
+
...new Map(
|
|
943
|
+
routed.diagnostics.map((diagnostic) => [
|
|
944
|
+
JSON.stringify([diagnostic.file, diagnostic.rule, diagnostic.line, diagnostic.column, diagnostic.message]),
|
|
945
|
+
diagnostic,
|
|
946
|
+
]),
|
|
947
|
+
).values(),
|
|
948
|
+
];
|
|
949
|
+
return architectureEvidence({
|
|
950
|
+
ok: uniqueDiagnostics.length === 0,
|
|
951
|
+
diagnostics: uniqueDiagnostics,
|
|
952
|
+
...(routed.advisories.length ? { advisories: routed.advisories } : {}),
|
|
953
|
+
});
|
|
394
954
|
}
|