Code conformance
When to use this skill
- Reviewing or auditing 2nd-gen component TypeScript, CSS, test, or Storybook story files for style-guide conformance
- As part of the
migration-conformance sub-task, after Phase 6 (testing) and before Phase 7 (documentation) of a component migration
- Before a consistency pass (see
consistency-pass), which delegates its code-conformance check to this skill
How to invoke
- Say "check code conformance", "audit this component's style", "review this against the style guide", or "run conformance checks for [component]"
Use this skill when auditing 2nd-gen component files for alignment with project style guides. It covers four domains: TypeScript, CSS, test files, and Storybook stories. Always run automated linters first, then perform the manual review for each domain.
Linting commands
# ESLint — TypeScript and test files
yarn lint
# Stylelint — CSS files
yarn lint:css
# Prettier — check and fix formatting
yarn prettier --check "path/to/files"
yarn prettier --write "path/to/files"
Resolve every linting error before beginning the manual review. If a lint rule must be disabled, add an inline comment with a clear reason and flag it for reviewer awareness.
Reference: Linting tools
TypeScript
Style guide:
What to check:
- File organization matches the documented section order
- Class structure follows the prescribed ordering: decorators, properties, lifecycle, render
- Properties use the correct decorator patterns and reflect values
- Methods follow visibility and naming conventions
- JSDoc is present and well-formed on public API members
- No patterns listed as anti-patterns or discouraged in the guide
- Dev-warning validation (enum values, required/conditionally required properties, mutually exclusive combinations, required slots, allowed children) uses the shared helpers in
@spectrum-web-components/core/utils (validateEnum, warnIf, validateRequiredSlot, validateAllowedChildren), not hand-rolled includes() + window.__swc.warn() checks. See Debug and validation.
CSS
Style guide:
What to check:
- Every item in the Component CSS PR checklist passes — work through it explicitly, do not skim
- CSS property ordering matches the documented order
- Custom property naming follows the convention
- No patterns from the anti-patterns guide are present
- Forced-colors media query is present and correct (if applicable)
- High-contrast and other media queries are sorted to the bottom of the file
- No hard-coded values where design tokens are available
- For files in
swc/stylesheets/: placement, index registration, generated file conventions, and _lit-styles/ import patterns match Non-component stylesheets
Test files
Vitest reference: see .ai/references/vitest.md for the canonical AI-friendly Vitest docs (index + per-page fetch pattern) and project-specific config notes.
Style guide:
What to check:
- Describe/it block naming follows the documented naming conventions
- Assertions use the prescribed utilities and matchers, not raw DOM assertions where a helper exists
- No patterns from the flaky-tests guide are present
- Test isolation is correct: no shared mutable state between tests
- Coverage is meaningful — each test would catch a real regression if the behavior changed
Storybook stories
Authoring guidelines:
- Stories format:
.ai/rules/stories-format.md — file structure, meta, tags, layout, visual separators
- Stories documentation:
.ai/rules/stories-documentation.md — per-unit MDX authoring (section content, anatomy, options, states, behaviors, accessibility)
What to check (<unit>.stories.ts):
- File has the correct section order and visual separators
- Meta has all required fields:
title, component, args, argTypes, render, parameters.docs.subtitle, tags: ['migrated'] (or 'controller')
- All stories have correct section tags:
anatomy, options, states, behaviors, a11y, etc.
- Playground uses
tags: ['dev'] when the unit has a per-unit MDX file (no 'autodocs' to avoid a duplicate Docs entry)
- No story-level JSDoc comments above any
export const — only the meta-level JSDoc remains
- No
section-order parameter; no description-only tag
flexLayout: 'row-wrap' is used for multi-item stories
- Internal DOM attributes the component writes itself via
setAttribute (not declared @property, e.g. Tooltip's actual-placement) are declared in argTypes with { table: { disable: true }, control: false }; otherwise the Storybook helper's attribute observer round-trips them through args and re-applies stale values via its spread directive, clobbering the component's own state
- All examples use accessible, meaningful content: no placeholder text, no missing labels
- Image assets use
picsum.photos with static IDs
What to check (<unit>.mdx):
- Per-unit MDX file exists at the unit root with the correct relative import path for
DocsHeader / DocsFooter
<Meta of={Stories} /> declared exactly once
<DocsHeader /> at the top, <DocsFooter /> at the bottom
- Sections appear in canonical order (Anatomy → Usage → Options → States → Behaviors → Accessibility → Full pattern → Upcoming features → API → Appendix → Feedback)
- Every section-tagged story is referenced via
<Canvas of={Stories.StoryName} />
- Per-story
### Title headings match Storybook's rendered story names
- No
<Canvas> references to untagged stories
- Controllers: hand-authored
## API section is present and meta.tags includes 'controller' so <ApiTable /> is omitted by <DocsFooter />
- MDX heading levels start at
### inside section prose (top-level sections use ##)
Guideline gaps
If the code is already correct and appropriate but the relevant style guide does not cover the pattern, do not change the guideline and do not block the review on it. Instead, surface it to the user with:
- The file and line where the uncovered pattern appears
- The uncovered pattern itself
- A clear rationale for why it should be added to the guide
Example PR comment format:
## Potential guideline improvements
- `Component.base.ts:42` — The TypeScript guide does not cover the pattern for Lit reactive
controllers that hold both state and refs. A note clarifying the preferred approach would
prevent inconsistency across future migrations.
1---2name: code-conformance3description: Review 2nd-gen component files against project style guides, run linters, and surface guideline gaps. Apply whenever reviewing or auditing 2nd-gen component code for style conformance.4---56# Code conformance78## When to use this skill910- Reviewing or auditing 2nd-gen component TypeScript, CSS, test, or Storybook story files for style-guide conformance11- As part of the `migration-conformance` sub-task, after Phase 6 (testing) and before Phase 7 (documentation) of a component migration12- Before a consistency pass (see `consistency-pass`), which delegates its code-conformance check to this skill1314## How to invoke1516- Say "check code conformance", "audit this component's style", "review this against the style guide", or "run conformance checks for [component]"1718Use this skill when auditing 2nd-gen component files for alignment with project style guides. It covers four domains: TypeScript, CSS, test files, and Storybook stories. Always run automated linters first, then perform the manual review for each domain.1920## Linting commands2122```bash23# ESLint — TypeScript and test files24yarn lint2526# Stylelint — CSS files27yarn lint:css2829# Prettier — check and fix formatting30yarn prettier --check "path/to/files"31yarn prettier --write "path/to/files"32```3334Resolve every linting error before beginning the manual review. If a lint rule must be disabled, add an inline comment with a clear reason and flag it for reviewer awareness.3536Reference: [Linting tools](../../../CONTRIBUTOR-DOCS/02_style-guide/03_linting-tools.md)3738## TypeScript3940**Style guide:**4142- [File organization](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/01_file-organization.md)43- [Class structure](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/02_class-structure.md)44- [TypeScript modifiers](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/03_typescript-modifiers.md)45- [Lit decorators](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/04_lit-decorators.md)46- [Property patterns](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/05_property-patterns.md)47- [Method patterns](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/06_method-patterns.md)48- [JSDoc standards](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/07_jsdoc-standards.md)49- [Component types](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/08_component-types.md)50- [Rendering patterns](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/09_rendering-patterns.md)51- [Naming conventions](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/10_naming-conventions.md)52- [Base class vs concrete class](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/11_base-vs-concrete.md)53- [Composition patterns](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/12_composition-patterns.md) and related composition docs5455**What to check:**5657- File organization matches the documented section order58- Class structure follows the prescribed ordering: decorators, properties, lifecycle, render59- Properties use the correct decorator patterns and reflect values60- Methods follow visibility and naming conventions61- JSDoc is present and well-formed on public API members62- No patterns listed as anti-patterns or discouraged in the guide63- Dev-warning validation (enum values, required/conditionally required properties, mutually exclusive combinations, required slots, allowed children) uses the shared helpers in `@spectrum-web-components/core/utils` (`validateEnum`, `warnIf`, `validateRequiredSlot`, `validateAllowedChildren`), not hand-rolled `includes()` + `window.__swc.warn()` checks. See [Debug and validation](../../../CONTRIBUTOR-DOCS/02_style-guide/02_typescript/17_debug-validation.md#reusable-validation-helpers).6465## CSS6667**Style guide:**6869- [Component CSS](../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/01_component-css.md)70- [Custom properties](../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/02_custom-properties.md)71- [Component CSS PR checklist](../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/03_component-css-pr-checklist.md)72- [Spectrum CSS to SWC migration](../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/04_spectrum-swc-migration.md)73- [Styling anti-patterns](../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/05_anti-patterns.md)74- [Property order quick reference](../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/06_property-order-quick-reference.md)75- [Non-component stylesheets](../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/07_stylesheets.md) — applies when the changed file is in `swc/stylesheets/` rather than a component package7677**What to check:**7879- Every item in the Component CSS PR checklist passes — work through it explicitly, do not skim80- CSS property ordering matches the documented order81- Custom property naming follows the convention82- No patterns from the anti-patterns guide are present83- Forced-colors media query is present and correct (if applicable)84- High-contrast and other media queries are sorted to the bottom of the file85- No hard-coded values where design tokens are available86- For files in `swc/stylesheets/`: placement, index registration, generated file conventions, and `_lit-styles/` import patterns match [Non-component stylesheets](../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/07_stylesheets.md)8788## Test files8990**Vitest reference:** see [.ai/references/vitest.md](../../references/vitest.md) for the canonical AI-friendly Vitest docs (index + per-page fetch pattern) and project-specific config notes.9192**Style guide:**9394- [Testing overview](../../../CONTRIBUTOR-DOCS/02_style-guide/04_testing/01_testing-overview.md)95- [Storybook testing](../../../CONTRIBUTOR-DOCS/02_style-guide/04_testing/02_storybook-testing.md)96- [Playwright accessibility testing](../../../CONTRIBUTOR-DOCS/02_style-guide/04_testing/03_playwright-accessbility-testing.md)97- [Testing utilities](../../../CONTRIBUTOR-DOCS/02_style-guide/04_testing/05_testing-utilities.md)98- [Avoiding flaky tests](../../../CONTRIBUTOR-DOCS/02_style-guide/04_testing/07_avoiding-flaky-tests.md)99- [PR review checklist](../../../CONTRIBUTOR-DOCS/02_style-guide/04_testing/09_pr_review-checklist.md)100101**What to check:**102103- Describe/it block naming follows the documented naming conventions104- Assertions use the prescribed utilities and matchers, not raw DOM assertions where a helper exists105- No patterns from the flaky-tests guide are present106- Test isolation is correct: no shared mutable state between tests107- Coverage is meaningful — each test would catch a real regression if the behavior changed108109## Storybook stories110111**Authoring guidelines:**112113- Stories format: `.ai/rules/stories-format.md` — file structure, meta, tags, layout, visual separators114- Stories documentation: `.ai/rules/stories-documentation.md` — per-unit MDX authoring (section content, anatomy, options, states, behaviors, accessibility)115116**What to check (`<unit>.stories.ts`):**117118- File has the correct section order and visual separators119- Meta has all required fields: `title`, `component`, `args`, `argTypes`, `render`, `parameters.docs.subtitle`, `tags: ['migrated']` (or `'controller'`)120- All stories have correct section tags: `anatomy`, `options`, `states`, `behaviors`, `a11y`, etc.121- Playground uses `tags: ['dev']` when the unit has a per-unit MDX file (no `'autodocs'` to avoid a duplicate Docs entry)122- No story-level JSDoc comments above any `export const` — only the meta-level JSDoc remains123- No `section-order` parameter; no `description-only` tag124- `flexLayout: 'row-wrap'` is used for multi-item stories125- Internal DOM attributes the component writes itself via `setAttribute` (not declared `@property`, e.g. Tooltip's `actual-placement`) are declared in `argTypes` with `{ table: { disable: true }, control: false }`; otherwise the Storybook helper's attribute observer round-trips them through `args` and re-applies stale values via its `spread` directive, clobbering the component's own state126- All examples use accessible, meaningful content: no placeholder text, no missing labels127- Image assets use `picsum.photos` with static IDs128129**What to check (`<unit>.mdx`):**130131- Per-unit MDX file exists at the unit root with the correct relative import path for `DocsHeader` / `DocsFooter`132- `<Meta of={Stories} />` declared exactly once133- `<DocsHeader />` at the top, `<DocsFooter />` at the bottom134- Sections appear in canonical order (Anatomy → Usage → Options → States → Behaviors → Accessibility → Full pattern → Upcoming features → API → Appendix → Feedback)135- Every section-tagged story is referenced via `<Canvas of={Stories.StoryName} />`136- Per-story `### Title` headings match Storybook's rendered story names137- No `<Canvas>` references to untagged stories138- Controllers: hand-authored `## API` section is present and `meta.tags` includes `'controller'` so `<ApiTable />` is omitted by `<DocsFooter />`139- MDX heading levels start at `###` inside section prose (top-level sections use `##`)140141## Guideline gaps142143If the code is already correct and appropriate but the relevant style guide does not cover the pattern, do not change the guideline and do not block the review on it. Instead, surface it to the user with:144145- The file and line where the uncovered pattern appears146- The uncovered pattern itself147- A clear rationale for why it should be added to the guide148149**Example PR comment format:**150151```152## Potential guideline improvements153154- `Component.base.ts:42` — The TypeScript guide does not cover the pattern for Lit reactive155 controllers that hold both state and refs. A note clarifying the preferred approach would156 prevent inconsistency across future migrations.157```