@reqvire-org/ads 0.4.0 → 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 +105 -86
- 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 +5 -5
- 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 +219 -77
- package/dist/boundaries.mjs +135 -38
- package/dist/brand-assets.mjs +219 -47
- package/dist/brands.mjs +86 -27
- package/dist/bun-compiler.mjs +28 -14
- 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 +40 -57
- package/dist/check.mjs +749 -188
- package/dist/cli.mjs +200 -99
- package/dist/color-values.mjs +21 -21
- package/dist/component-contrast.mjs +2 -2
- package/dist/config.mjs +303 -135
- package/dist/construction-styles.cjs +10 -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 +2 -2
- package/dist/foundation-views.mjs +238 -0
- package/dist/foundation.mjs +63 -39
- package/dist/generated-entries.mjs +101 -34
- package/dist/icons.mjs +79 -32
- package/dist/image-attributes.mjs +109 -36
- package/dist/image-size.mjs +1 -1
- package/dist/index.mjs +0 -2
- package/dist/init.mjs +122 -41
- package/dist/investigations.mjs +2 -2
- package/dist/layers.mjs +298 -129
- 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 +90 -26
- package/dist/mcp/context.mjs +17 -18
- package/dist/mcp/draft-discovery.mjs +44 -21
- package/dist/mcp/drafts.mjs +901 -281
- package/dist/mcp/execution-coordinator.mjs +417 -167
- package/dist/mcp/execution-results.mjs +7 -7
- package/dist/mcp/mutations.mjs +670 -234
- package/dist/mcp/preview-watch.mjs +448 -170
- package/dist/mcp/preview-widget.bundle.js +44 -50
- package/dist/mcp/prompts.mjs +5 -5
- package/dist/mcp/result-pages.mjs +1 -1
- package/dist/mcp/sandbox-host.mjs +1 -1
- package/dist/mcp/server.mjs +2402 -577
- package/dist/mcp/showcase-host.mjs +165 -41
- 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 +8 -34
- package/dist/project-documents.mjs +1 -1
- package/dist/public-api.mjs +69 -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 +719 -378
- package/dist/scenarios-vite.d.mts +1 -3
- package/dist/scenarios-vite.mjs +2 -81
- package/dist/scenarios.mjs +421 -157
- 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 +130 -119
- package/dist/skills/ads-designer/references/accessibility.md +12 -13
- package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
- package/dist/skills/ads-designer/references/behaviors.md +30 -27
- package/dist/skills/ads-designer/references/branding.md +98 -10
- package/dist/skills/ads-designer/references/captures.md +25 -0
- package/dist/skills/ads-designer/references/cli.md +21 -24
- package/dist/skills/ads-designer/references/contracts.md +7 -6
- package/dist/skills/ads-designer/references/design-data.md +49 -52
- package/dist/skills/ads-designer/references/drafts.md +20 -17
- package/dist/skills/ads-designer/references/evidence.md +1 -5
- package/dist/skills/ads-designer/references/guarded-editing.md +14 -18
- 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/review.md +37 -34
- package/dist/skills/ads-designer/references/runtimes.md +33 -30
- package/dist/skills/ads-designer/references/scenarios.md +16 -18
- 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 -75
- package/dist/skills/ads-designer/references/workflows.md +8 -33
- package/dist/skills/ads-import/SKILL.md +43 -325
- package/dist/skills/ads-import/references/atomic-styles.md +4 -4
- package/dist/skills/ads-import/references/behaviors.md +30 -27
- package/dist/skills/ads-import/references/branding.md +5 -5
- package/dist/skills/ads-import/references/captures.md +25 -0
- package/dist/skills/ads-import/references/cli.md +21 -24
- package/dist/skills/ads-import/references/compatibility.md +1 -1
- package/dist/skills/ads-import/references/contracts.md +7 -6
- package/dist/skills/ads-import/references/design-data.md +49 -52
- package/dist/skills/ads-import/references/drafts.md +20 -17
- package/dist/skills/ads-import/references/evidence.md +1 -5
- package/dist/skills/ads-import/references/guarded-editing.md +14 -18
- 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 +37 -34
- package/dist/skills/ads-import/references/runtimes.md +33 -30
- package/dist/skills/ads-import/references/scenarios.md +16 -18
- package/dist/skills/ads-import/references/tokens.md +3 -3
- package/dist/skills/ads-import/references/validation.md +83 -75
- package/dist/skills/ads-import/references/workflows.md +8 -33
- 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 -343
- package/dist/skills/ads-port/references/atomic-styles.md +4 -4
- package/dist/skills/ads-port/references/behaviors.md +30 -27
- package/dist/skills/ads-port/references/captures.md +25 -0
- package/dist/skills/ads-port/references/cli.md +21 -24
- package/dist/skills/ads-port/references/contracts.md +7 -6
- package/dist/skills/ads-port/references/design-data.md +49 -52
- package/dist/skills/ads-port/references/drafts.md +20 -17
- package/dist/skills/ads-port/references/evidence.md +1 -5
- package/dist/skills/ads-port/references/guarded-editing.md +14 -18
- 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 +2 -1
- package/dist/skills/ads-port/references/review.md +37 -34
- package/dist/skills/ads-port/references/runtimes.md +33 -30
- package/dist/skills/ads-port/references/scenarios.md +16 -18
- package/dist/skills/ads-port/references/validation.md +83 -75
- package/dist/skills/ads-port/references/workflows.md +8 -33
- 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 +25 -6
- 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 +47 -49
- 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/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/index.ts +2 -1
- 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/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 -1
- 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 -1
- 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/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 +25 -6
- 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 +70 -25
- package/dist/task-cache.mjs +173 -72
- package/dist/task-worker.mjs +22 -11
- package/dist/test-boundaries.mjs +132 -59
- package/dist/themes-generated.mjs +1 -1
- package/dist/themes-watch.mjs +57 -22
- 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 +251 -104
- package/dist/units.mjs +208 -98
- package/dist/usage.mjs +138 -38
- package/dist/validation-checks.mjs +115 -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 +90 -79
- package/docs/ARCHITECTURE.md +294 -136
- package/docs/BEHAVIORS.md +29 -25
- package/docs/CACHING.md +52 -17
- package/docs/CHANGELOG.md +309 -17
- package/docs/CONTRACTS.md +12 -4
- package/docs/DESIGN-REFERENCES.md +40 -0
- package/docs/GUIDE.md +270 -258
- package/docs/MCP.md +181 -324
- 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 -429
- package/dist/create.mjs +0 -48
- package/dist/lint-config.mjs +0 -50
- 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 -89
- 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 -412
- 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 -412
- package/dist/skills/ads-break-ui/references/captures.md +0 -135
- package/dist/skills/ads-break-ui/references/contracts.md +0 -317
- package/dist/skills/ads-break-ui/references/design-data.md +0 -354
- package/dist/skills/ads-break-ui/references/drafts.md +0 -194
- package/dist/skills/ads-break-ui/references/evidence.md +0 -128
- package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -165
- 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 -97
- 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 -166
- package/dist/skills/ads-break-ui/references/verification.md +0 -58
- package/dist/skills/ads-break-ui/references/workflows.md +0 -90
- 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 -385
- 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 -412
- package/dist/skills/ads-motion/references/captures.md +0 -135
- package/dist/skills/ads-motion/references/contracts.md +0 -317
- package/dist/skills/ads-motion/references/design-data.md +0 -354
- package/dist/skills/ads-motion/references/drafts.md +0 -194
- package/dist/skills/ads-motion/references/evidence.md +0 -128
- package/dist/skills/ads-motion/references/guarded-editing.md +0 -165
- 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 -97
- 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 -166
- package/dist/skills/ads-motion/references/verification.md +0 -39
- package/dist/skills/ads-motion/references/workflows.md +0 -90
- package/dist/skills/ads-port/references/reporting.md +0 -101
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
- 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.ads.contract.ts +0 -6
- 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.contract.ts +0 -6
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +0 -1
- 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.ads.exports.ts +0 -1
- 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.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
- package/dist/starters/react/design-system/review/index.ts +0 -6
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +0 -1
- 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";
|
|
@@ -11,14 +15,23 @@ import { themeAncestorSelector } from "./themes.mjs";
|
|
|
11
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
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";
|
|
@@ -36,7 +49,7 @@ import { createScenarioSelectors } from "./scenario-selectors.mjs";
|
|
|
36
49
|
import { architectureEvidence, failure } from "./evidence.mjs";
|
|
37
50
|
import { propertyRegistration } from "./property-registrations.mjs";
|
|
38
51
|
import { createLayerBoundaries, layerSourceFiles } from "./layers.mjs";
|
|
39
|
-
import { createDesignValues, inspectDesignAliases, isColorKeyword } from "./design-values.mjs";
|
|
52
|
+
import { createDesignValues, designTemplateVariants, inspectDesignAliases, isColorKeyword } from "./design-values.mjs";
|
|
40
53
|
import { inspectTestBoundaries } from "./test-boundaries.mjs";
|
|
41
54
|
import { inspectBehaviorLibraries } from "./behavior-libraries.mjs";
|
|
42
55
|
import { inspectUsage } from "./usage.mjs";
|
|
@@ -46,211 +59,617 @@ import { createFontRules } from "./font-rules.mjs";
|
|
|
46
59
|
import { createLayoutWidths, globMatcher } from "./layout-widths.mjs";
|
|
47
60
|
import { imageAttributeFindings } from "./image-attributes.mjs";
|
|
48
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";
|
|
49
67
|
|
|
50
|
-
const scenarioLayoutGuidance =
|
|
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.";
|
|
51
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.`;
|
|
52
71
|
|
|
53
|
-
const showcaseControls = new Set([
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
]);
|
|
57
175
|
|
|
58
|
-
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 }) {
|
|
59
187
|
const options = { ...loadConfig(directory), ...(trackingRoot ? { trackingRoot: path.resolve(trackingRoot) } : {}) };
|
|
60
188
|
const { root, config, dsRoot, sourceRoot } = options;
|
|
61
|
-
const diagnostics = [],
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
});
|
|
64
204
|
}
|
|
65
205
|
if (diagnostics.length) return architectureEvidence({ ok: false, diagnostics });
|
|
66
|
-
diagnostics.push(...generatedEntryDiagnostics(options, inspectUnits(options)));
|
|
67
|
-
const tokenInventory = inspectTokens(root, options);
|
|
206
|
+
diagnostics.push(...(await generatedEntryDiagnostics(options, await inspectUnits(options))));
|
|
207
|
+
const tokenInventory = await inspectTokens(root, options);
|
|
68
208
|
const declaredTokens = new Set(tokenInventory.tokens.map((token) => token.name));
|
|
69
209
|
// Display switches are defined by the generated themes.generated.css, not a token sheet.
|
|
70
210
|
const generatedSwitches = new Set(displaySwitches(config));
|
|
71
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
|
+
}
|
|
72
218
|
const assetFindings = inspectAssets(options);
|
|
73
|
-
diagnostics.push(...assetFindings.filter(finding => !finding.severity || finding.severity === "error"));
|
|
74
|
-
const assetAdvisories = assetFindings.filter(finding => finding.severity && finding.severity !== "error");
|
|
75
|
-
const resolveImport = importResolver(options);
|
|
76
|
-
const units = inspectUnits(options);
|
|
77
|
-
options.testOwner = file => units.owner(units.relative(path.relative(root,file)));
|
|
78
|
-
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
|
+
);
|
|
79
230
|
const rootHtml = path.join(root, "index.html");
|
|
80
231
|
const files = [...new Set([...sourceFiles(sourceRoot), ...sourceFiles(dsRoot), ...configurationScripts, ...(existsSync(rootHtml) ? [rootHtml] : [])])];
|
|
81
|
-
const stylePolicy = ownerStylePolicy(options);
|
|
82
|
-
const boundaryFiles = [...stylePolicy.inlineStyleFiles, ...stylePolicy.styleWrites.map(entry => entry.file)]
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
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
|
+
});
|
|
86
257
|
const checker = program.getTypeChecker();
|
|
87
|
-
diagnostics.push(...inspectBehaviorLibraries(options, program).diagnostics);
|
|
88
|
-
const designValues = createDesignValues(program,options);
|
|
89
|
-
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);
|
|
90
262
|
diagnostics.push(...paintContracts.diagnostics);
|
|
91
|
-
const runtimeContracts = inspectRuntimeContracts(options, program);
|
|
263
|
+
const runtimeContracts = await inspectRuntimeContracts(options, program);
|
|
92
264
|
diagnostics.push(...runtimeContracts.diagnostics);
|
|
93
265
|
const atomicCompositionReview = createAtomicCompositionReview(program, options);
|
|
94
266
|
const renderColorProbe = createRenderColorProbe(program);
|
|
95
|
-
const scenarioTrace = createScenarioTrace(program, options);
|
|
267
|
+
const scenarioTrace = await createScenarioTrace(program, options);
|
|
96
268
|
let scenarioSlot, scenarioSelector;
|
|
97
269
|
function report(file, rule, message, line = 1, column = 1, detail = {}) {
|
|
98
270
|
diagnostics.push({ file: path.relative(root, file).replaceAll("\\", "/"), rule, message, line, column, ...detail });
|
|
99
271
|
}
|
|
100
|
-
const layers = createLayerBoundaries(program, options, report),
|
|
101
|
-
|
|
272
|
+
const layers = await createLayerBoundaries(program, options, report),
|
|
273
|
+
layerStyles = [];
|
|
274
|
+
await inspectUsage(options, program, report);
|
|
102
275
|
layers.inspectDependencies();
|
|
103
|
-
inspectTokenValueFlows(program, options, tokenInventory, units, report);
|
|
104
|
-
for (const file of layers.runtimeHelpers()) if (!files.includes(file)) files.push(file);
|
|
105
|
-
inspectStyleBoundaries(options, program, report);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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);
|
|
110
288
|
diagnostics.push(...behaviors.diagnostics);
|
|
111
|
-
diagnostics.push(...inspectTestBoundaries(options,units,behaviors.contracts,program));
|
|
112
|
-
inspectControllers(options, program, report, behaviors.contracts);
|
|
289
|
+
diagnostics.push(...(await inspectTestBoundaries(options, units, behaviors.contracts, program)));
|
|
290
|
+
await inspectControllers(options, program, report, behaviors.contracts);
|
|
113
291
|
// The foundation remains a fixed import-only entry, not an extra styling layer.
|
|
114
292
|
const foundationEntry = path.join(dsRoot, config.stylesEntry);
|
|
115
|
-
const registeredProperties=new Map(),
|
|
293
|
+
const registeredProperties = new Map(),
|
|
294
|
+
controlPaddingSeen = new Set();
|
|
116
295
|
const componentContrast = createComponentContrast(tokenInventory.tokens, config.themes, config.brands);
|
|
117
|
-
const layoutWidths = createLayoutWidths(tokenInventory.tokens, config
|
|
118
|
-
|
|
119
|
-
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
|
+
});
|
|
120
316
|
const ownerFixedWidths = [];
|
|
121
317
|
const fontRules = createFontRules(options, tokenInventory.tokens);
|
|
122
|
-
function checkRegistrations(file,css,offset={line:1}){
|
|
123
|
-
css
|
|
124
|
-
const line=offset.line+(rule.source?.start.line??1)-1;
|
|
125
|
-
try{
|
|
126
|
-
const registration=propertyRegistration(rule),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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);
|
|
137
345
|
}
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
+
}
|
|
142
362
|
});
|
|
143
363
|
}
|
|
144
|
-
function checkCss(file, text, offset
|
|
364
|
+
async function checkCss(file, text, offset, foundation = false, template) {
|
|
365
|
+
if (offset === undefined) offset = { line: 1, column: 1 };
|
|
145
366
|
let css;
|
|
146
|
-
try {
|
|
147
|
-
|
|
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
|
+
}
|
|
148
386
|
layers.collectComponentStyles(file, css);
|
|
149
387
|
layerStyles.push({ file, css, offset });
|
|
150
388
|
if (foundation || !isDevelopmentFile(file, options)) fontRules.collect(css, file, offset);
|
|
151
|
-
checkRegistrations(file,css,offset);
|
|
152
|
-
if (!foundation && !isDevelopmentFile(file, options) && ["components", "patterns"].some(layer => isInside(path.join(dsRoot, layer), file)))
|
|
153
|
-
|
|
154
|
-
|
|
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)));
|
|
155
399
|
const widths = layoutWidths.inspect(css, relative, offset);
|
|
156
400
|
if (!fixedWidthOwner(relative) && !(owner && fixedWidthOwner(owner))) advisories.push(...widths);
|
|
157
|
-
else ownerFixedWidths.push(...widths.filter(finding => finding.rule === "layout-fixed-width"));
|
|
401
|
+
else ownerFixedWidths.push(...widths.filter((finding) => finding.rule === "layout-fixed-width"));
|
|
158
402
|
}
|
|
159
403
|
// Linaria templates are checked once per resolved interpolation variant.
|
|
160
|
-
if (!foundation)
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
+
);
|
|
168
433
|
const first = valueParser(rule.params).nodes.find((node) => node.type !== "space" && node.type !== "comment");
|
|
169
434
|
const specifier = first?.type === "string" ? first.value : first?.type === "function" && first.value === "url" ? first.nodes[0]?.value : null;
|
|
170
435
|
if (!specifier || /^(?:[a-z]+:|\/\/)/i.test(specifier)) return;
|
|
171
436
|
const line = offset.line + rule.source.start.line - 1;
|
|
172
|
-
if (importViolation(specifier, file, options, resolveImport))
|
|
173
|
-
|
|
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);
|
|
174
441
|
});
|
|
175
442
|
css.walkRules((rule) => {
|
|
176
443
|
if (foundation) {
|
|
177
|
-
if (rule.parent.type === "rule")
|
|
178
|
-
|
|
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("--")) });
|
|
179
452
|
if (violation) report(file, "foundation-selector", violation, rule.source.start.line, rule.source.start.column);
|
|
180
453
|
}
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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);
|
|
186
485
|
});
|
|
187
|
-
if (foundation)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
+
);
|
|
194
509
|
if (foundation && decl.prop.startsWith("--")) {
|
|
195
|
-
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);
|
|
196
512
|
return; // Definition names, values and aliases are validated by inspectTokens.
|
|
197
513
|
}
|
|
198
514
|
const fontDescriptor = foundation && path.basename(file) === "fonts.css" && decl.parent.type === "atrule" && decl.parent.name === "font-face";
|
|
199
|
-
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
|
+
);
|
|
200
523
|
if (foundation && path.basename(file) === "base.css" && decl.parent.type === "rule") {
|
|
201
524
|
const violation = foundationDeclaration(decl.parent, decl);
|
|
202
525
|
if (violation) report(file, "foundation-role", violation, decl.source.start.line, decl.source.start.column);
|
|
203
526
|
}
|
|
204
|
-
const variable = checkComponentVariable(decl.prop, file, options);
|
|
527
|
+
const variable = await checkComponentVariable(decl.prop, file, options);
|
|
205
528
|
if (variable) report(file, variable.rule, variable.message, offset.line + decl.source.start.line - 1, decl.source.start.column);
|
|
206
529
|
for (const ref of references(decl.value)) {
|
|
207
|
-
const binding = runtimeBindingOwner(options, ref.name);
|
|
530
|
+
const binding = await runtimeBindingOwner(options, ref.name);
|
|
208
531
|
if (binding) {
|
|
209
|
-
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
|
+
);
|
|
210
540
|
continue;
|
|
211
541
|
}
|
|
212
542
|
if (generatedSwitches.has(ref.name)) continue;
|
|
213
|
-
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
|
+
}
|
|
214
553
|
const local = /^(?:--ds-|--ux-|--showcase-)/.test(ref.name);
|
|
215
|
-
if (foundation && local)
|
|
216
|
-
|
|
217
|
-
|
|
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);
|
|
218
572
|
}
|
|
219
573
|
if (fontDescriptor || propertyDescriptor) return; // Font metadata defines source assets, not token-backed UI styles.
|
|
220
574
|
const violations = new Set();
|
|
221
|
-
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
|
+
);
|
|
222
579
|
valueParser(decl.value).walk((node) => {
|
|
223
580
|
if (node.type === "function" && node.value === "url") return false;
|
|
224
|
-
if (node.type === "word" && decl.prop.startsWith("--") && isColorKeyword(node.value))
|
|
225
|
-
|
|
226
|
-
if (
|
|
227
|
-
|
|
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.");
|
|
228
600
|
if (node.type === "word" && /^ease(?:-in|-out|-in-out)?$/.test(node.value)) violations.add("Use a motion token for easing.");
|
|
229
|
-
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.");
|
|
230
608
|
});
|
|
231
|
-
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.");
|
|
232
615
|
for (const message of violations) report(file, "style-token", message, offset.line + decl.source.start.line - 1, decl.source.start.column);
|
|
233
616
|
});
|
|
234
617
|
}
|
|
235
618
|
for (const file of files) {
|
|
236
619
|
const role = adsFileRole(file);
|
|
237
|
-
|
|
238
|
-
|
|
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
|
+
);
|
|
239
650
|
// The generated theme sheet and palette are checked for freshness with the tokens, not authored.
|
|
240
|
-
if (generatedThemeFiles.some(generated => file === path.join(dsRoot, config.tokenDir, generated))) continue;
|
|
241
|
-
if (file.endsWith(".css") && isInside(path.join(dsRoot, config.tokenDir), file) && !isDevelopmentFile(file, options)) {
|
|
242
|
-
|
|
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
|
+
}
|
|
243
660
|
if (file.endsWith(".css")) {
|
|
244
661
|
const text = readFileSync(file, "utf8");
|
|
245
662
|
if (file === path.join(sourceRoot, "app-mount.css") && isMountCss(text)) continue;
|
|
246
|
-
checkCss(file, text);
|
|
663
|
+
await checkCss(file, text);
|
|
664
|
+
continue;
|
|
247
665
|
}
|
|
248
|
-
const source = program.getSourceFile(file);
|
|
666
|
+
const source = await program.getSourceFile(file);
|
|
249
667
|
if (!source) continue;
|
|
250
|
-
advisories.push(...pointerCaptureAdvisories(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
|
|
251
|
-
advisories.push(...atomicCompositionReview(source).map(entry => ({ file: path.relative(root, file).replaceAll("\\", "/"), ...entry })));
|
|
252
|
-
if (["components", "patterns"].some(section => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options))
|
|
253
|
-
|
|
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)) {
|
|
254
673
|
const position = source.getLineAndCharacterOfPosition(diagnostic.start ?? 0);
|
|
255
674
|
report(file, "source-syntax", ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"), position.line + 1, position.character + 1);
|
|
256
675
|
}
|
|
@@ -261,133 +680,275 @@ export function checkProject(directory, { trackingRoot } = {}) {
|
|
|
261
680
|
report(file, rule, message, position.line + 1, position.character + 1);
|
|
262
681
|
if (detail) Object.assign(diagnostics.at(-1), detail);
|
|
263
682
|
}
|
|
264
|
-
function scenarioClass(node, expression, property = false) {
|
|
265
|
-
|
|
266
|
-
|
|
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
|
+
);
|
|
267
703
|
}
|
|
268
|
-
function scenarioControl(node, native) {
|
|
269
|
-
const proof = (scenarioSlot ??= createScenarioSlots(program, options))(node);
|
|
704
|
+
async function scenarioControl(node, native) {
|
|
705
|
+
const proof = await (scenarioSlot ??= await createScenarioSlots(program, options))(node);
|
|
270
706
|
if (proof.ok) return;
|
|
271
|
-
const selector = native
|
|
272
|
-
|
|
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
|
+
);
|
|
273
717
|
}
|
|
274
|
-
if (!showcase && (isInside(path.join(dsRoot, "components"), file) || isInside(path.join(dsRoot, "patterns"), file)))
|
|
275
|
-
|
|
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) {
|
|
276
721
|
if (ts.isCallExpression(tag)) tag = tag.expression;
|
|
277
722
|
let symbolNode = tag;
|
|
278
723
|
while (ts.isPropertyAccessExpression(symbolNode)) symbolNode = symbolNode.expression;
|
|
279
|
-
const symbol = checker.getSymbolAtLocation(symbolNode);
|
|
724
|
+
const symbol = await checker.getSymbolAtLocation(symbolNode);
|
|
280
725
|
return symbol?.declarations?.some((decl) => {
|
|
281
726
|
if (ts.isImportSpecifier(decl)) {
|
|
282
727
|
const module = decl.parent.parent.parent.moduleSpecifier;
|
|
283
728
|
return ["css", "styled"].includes((decl.propertyName ?? decl.name).text) && ts.isStringLiteral(module) && module.text.startsWith("@linaria/");
|
|
284
729
|
}
|
|
285
|
-
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
|
+
) {
|
|
286
735
|
const module = decl.parent.parent.moduleSpecifier;
|
|
287
736
|
return ts.isStringLiteral(module) && module.text.startsWith("@linaria/");
|
|
288
737
|
}
|
|
289
738
|
return false;
|
|
290
739
|
});
|
|
291
740
|
}
|
|
292
|
-
function inspectProperty(value) {
|
|
741
|
+
async function inspectProperty(value) {
|
|
293
742
|
if (ts.isPropertyAssignment(value) && (ts.isStringLiteralLike(value.name) || ts.isIdentifier(value.name))) {
|
|
294
|
-
const variable = checkComponentVariable(value.name.text, file, options);
|
|
743
|
+
const variable = await checkComponentVariable(value.name.text, file, options);
|
|
295
744
|
if (variable) nodeReport(value.name, variable.rule, variable.message);
|
|
296
745
|
}
|
|
297
|
-
|
|
746
|
+
await eachChild(value, inspectProperty);
|
|
298
747
|
}
|
|
299
748
|
function inspectClass(value) {
|
|
300
749
|
if (ts.isStringLiteralLike(value)) {
|
|
301
|
-
if (/(?:^|\s)ads-[\w-]+/.test(value.text) && !isInside(path.join(dsRoot, "components"), file))
|
|
302
|
-
|
|
303
|
-
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.");
|
|
304
756
|
}
|
|
305
757
|
ts.forEachChild(value, inspectClass);
|
|
306
758
|
}
|
|
307
|
-
const nativePreact = (source
|
|
759
|
+
const nativePreact = jsxImportSource(source, compiler) === "preact";
|
|
308
760
|
function checkSvgAttribute(node, name) {
|
|
309
|
-
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
|
+
);
|
|
310
767
|
}
|
|
311
|
-
const lightDarkLiterals = ["components", "patterns"].some(section => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options);
|
|
768
|
+
const lightDarkLiterals = ["components", "patterns"].some((section) => isInside(path.join(dsRoot, section), file)) && !isDevelopmentFile(file, options);
|
|
312
769
|
// Per-file facts, computed once rather than at every syntax node.
|
|
313
|
-
const fileInDs = isInside(dsRoot, file)
|
|
314
|
-
|
|
770
|
+
const fileInDs = isInside(dsRoot, file),
|
|
771
|
+
testFile = isTestFile(file);
|
|
772
|
+
async function inLinariaTemplate(node) {
|
|
315
773
|
const template = ts.isTemplateMiddle(node) || ts.isTemplateTail(node) ? node.parent.parent : node.parent;
|
|
316
774
|
const tagged = ts.isTemplateExpression(template) ? template.parent : template;
|
|
317
|
-
return ts.isTaggedTemplateExpression(tagged) && isLinariaTag(tagged.tag);
|
|
775
|
+
return ts.isTaggedTemplateExpression(tagged) && (await isLinariaTag(tagged.tag));
|
|
318
776
|
}
|
|
319
|
-
function visit(node) {
|
|
777
|
+
async function visit(node) {
|
|
320
778
|
if (nativePreact && ts.isJsxAttribute(node) && ts.isIdentifier(node.name)) {
|
|
321
779
|
const parent = node.parent.parent;
|
|
322
|
-
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);
|
|
323
782
|
}
|
|
324
|
-
if (ts.isCallExpression(node) && uiOperation(node.expression, checker) === "createElement") {
|
|
783
|
+
if (ts.isCallExpression(node) && (await uiOperation(node.expression, checker)) === "createElement") {
|
|
325
784
|
const [tag, props] = node.arguments;
|
|
326
785
|
const properties = props && ts.isObjectLiteralExpression(props) ? props.properties : [];
|
|
327
786
|
for (const property of properties) {
|
|
328
787
|
if (!ts.isPropertyAssignment(property) || !(ts.isIdentifier(property.name) || ts.isStringLiteralLike(property.name))) continue;
|
|
329
|
-
if (tag && ts.isStringLiteralLike(tag) && svgTags.has(tag.text) && importedUiApi(node.expression, checker)?.module === "preact")
|
|
330
|
-
|
|
331
|
-
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);
|
|
332
793
|
if (property.name.text === "className") inspectClass(property.initializer);
|
|
333
|
-
if (showcase && property.name.text === "className") scenarioClass(property, property.initializer);
|
|
794
|
+
if (showcase && property.name.text === "className") await scenarioClass(property, property.initializer);
|
|
334
795
|
}
|
|
335
|
-
if (showcase && props && !ts.isObjectLiteralExpression(props)) scenarioClass(props, props, true);
|
|
336
|
-
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);
|
|
337
798
|
if (showcase && tag && ts.isStringLiteralLike(tag)) {
|
|
338
|
-
const role = properties.find(
|
|
339
|
-
|
|
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));
|
|
340
805
|
}
|
|
341
806
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
+
);
|
|
345
822
|
}
|
|
346
|
-
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.");
|
|
347
831
|
if (showcase && (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && ts.isIdentifier(node.tagName) && /^[a-z]/.test(node.tagName.text)) {
|
|
348
832
|
const role = node.attributes.properties.find((attr) => ts.isJsxAttribute(attr) && attr.name.text === "role")?.initializer;
|
|
349
|
-
const roleValue =
|
|
350
|
-
|
|
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));
|
|
351
840
|
}
|
|
352
|
-
if (showcase && ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className")
|
|
353
|
-
|
|
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);
|
|
354
844
|
let specifier;
|
|
355
|
-
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier))
|
|
356
|
-
|
|
357
|
-
if (
|
|
358
|
-
|
|
359
|
-
if (
|
|
360
|
-
|
|
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.");
|
|
361
880
|
const boundStyle = runtimeContracts.allowedStyles.has(`${file}:${node.pos}`);
|
|
362
|
-
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);
|
|
363
883
|
if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "style" && node.initializer) {
|
|
364
|
-
inspectProperty(node.initializer);
|
|
884
|
+
await inspectProperty(node.initializer);
|
|
365
885
|
}
|
|
366
|
-
const mutation = styleWriteViolation(node, file, options);
|
|
886
|
+
const mutation = await styleWriteViolation(node, file, options);
|
|
367
887
|
if (mutation) nodeReport(node, "style-mutation", mutation);
|
|
368
|
-
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
|
+
);
|
|
369
894
|
if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === "className" && node.initializer) {
|
|
370
895
|
inspectClass(node.initializer);
|
|
371
896
|
}
|
|
372
897
|
// Runtime inline values (style objects, inline custom properties, <style> text) give
|
|
373
898
|
// per-theme values with the generated themed(), not light-dark(); Linaria templates are
|
|
374
899
|
// checked as CSS above.
|
|
375
|
-
if (
|
|
376
|
-
|
|
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))) {
|
|
377
917
|
const template = node.template;
|
|
378
|
-
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}`);
|
|
379
920
|
const position = source.getLineAndCharacterOfPosition(template.getStart(source) + 1);
|
|
380
|
-
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);
|
|
381
922
|
}
|
|
382
|
-
|
|
923
|
+
await eachChild(node, visit);
|
|
383
924
|
}
|
|
384
|
-
visit(source);
|
|
925
|
+
await visit(source);
|
|
385
926
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
+
);
|
|
389
939
|
// Errors block by class; bounded clients see review items before informational limits.
|
|
390
|
-
const routed=routeFindings(diagnostics,advisories);
|
|
391
|
-
const uniqueDiagnostics=
|
|
392
|
-
|
|
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
|
+
});
|
|
393
954
|
}
|