svelte-spec-maintenance
Perform maintenance tasks for @markuplint/svelte-spec: add global attributes,
add element-specific attribute overrides for Svelte components.
Input
$ARGUMENTS specifies the task. Supported tasks:
| Task | Description |
|---|---|
add-global-attribute | Add a new global attribute for Svelte |
add-element-override | Add an element-specific attribute override |
If omitted, defaults to add-element-override.
Reference
Before executing any task, read docs/maintenance.md (or docs/maintenance.ja.md)
for the full guide. The recipes there are the source of truth for procedures.
Also read:
- •
ARCHITECTURE.md-- Package overview, ExtendedSpec content, and integration points - •
src/index.ts-- The single source file (source of truth for the spec object)
Task: add-global-attribute
Add a new global attribute that applies to all Svelte elements. Follow recipe #1 in docs/maintenance.md.
Step 1: Read the current spec
- •Read
src/index.tsto understand the currentExtendedSpecstructure - •Check if a
defproperty with#globalAttrsalready exists
Step 2: Add the global attribute
- •If
defdoes not exist, add it to the spec object:tsdef: { '#globalAttrs': { '#extends': { 'attribute-name': { type: 'Any', }, }, }, }, - •If
def['#globalAttrs']['#extends']already exists, add the new attribute to it
Step 3: Verify
- •Build:
yarn build --scope @markuplint/svelte-spec - •Test:
yarn test --scope @markuplint/svelte-spec
Task: add-element-override
Add an element-specific attribute override. Follow recipe #2 in docs/maintenance.md.
Step 1: Read the current spec
- •Read
src/index.tsto understand the currentspecsarray - •Check if the target element already has an entry
Step 2: Add the override
- •If the element already exists in
specs, add the new attribute to itsattributesobject - •If the element does not exist, add a new entry to the
specsarray:ts{ name: 'element-name', attributes: { 'attribute-name': { type: 'Any', }, }, },
Step 3: Verify
- •Build:
yarn build --scope @markuplint/svelte-spec - •Test:
yarn test --scope @markuplint/svelte-spec
Rules
- •Only export an
ExtendedSpecobject -- this package must not contain any parsing logic. - •Global attributes go under
def['#globalAttrs']['#extends']-- not in thespecsarray. - •Element overrides go under the
specs[]array -- each entry needs anameandattributesobject. - •Each attribute needs at minimum a
typefield -- common values areAny,String,Boolean, or an enum object. - •Add JSDoc comments to any new attribute definitions explaining why the override is needed.