Skip to content

Commit 0b550d3

Browse files
author
Peter Stenger
committed
chore: format boolean attribute changes
1 parent 7cdc10e commit 0b550d3

4 files changed

Lines changed: 31 additions & 40 deletions

File tree

docs/superpowers/plans/2026-05-15-boolean-custom-tag-attributes.md

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
### Task 1: Config Types And Zod Schema
3030

3131
**Files:**
32+
3233
- Modify: `js/shared/customCodeTags.ts`
3334
- Modify: `js/shared/configSchema.ts`
3435
- Modify: `js/shared/configSchemaJson.test.ts`
@@ -173,9 +174,7 @@ Add `allowBooleanAttributes: z.boolean().optional()` to both `childTagSchema` an
173174
Update lenient parsing:
174175

175176
```ts
176-
const allowBooleanAttributes = z
177-
.boolean()
178-
.safeParse(e.allowBooleanAttributes);
177+
const allowBooleanAttributes = z.boolean().safeParse(e.allowBooleanAttributes);
179178
if (allowBooleanAttributes.success) {
180179
tag.allowBooleanAttributes = allowBooleanAttributes.data;
181180
}
@@ -228,6 +227,7 @@ git commit -m "feat: add boolean attribute config"
228227
### Task 2: Registry Metadata And Callers
229228

230229
**Files:**
230+
231231
- Modify: `js/shared/customTagSchemaLoader.ts`
232232
- Modify: `js/linter/index.ts`
233233
- Modify: `js/cli/check.ts`
@@ -426,6 +426,7 @@ git commit -m "feat: propagate custom tag boolean attribute defaults"
426426
### Task 3: Boolean Attribute Diagnostics
427427

428428
**Files:**
429+
429430
- Modify: `js/linter/customTagSchemaChecker.ts`
430431
- Modify: `js/linter/linter.test.ts`
431432

@@ -629,12 +630,7 @@ Update top-level schema validation:
629630
const compiled = tag ? schemas.get(tag) : undefined;
630631
if (compiled) {
631632
errors.push(
632-
...validateElement(
633-
compiled,
634-
node,
635-
undefined,
636-
booleanCheck.names,
637-
),
633+
...validateElement(compiled, node, undefined, booleanCheck.names),
638634
);
639635
}
640636
```
@@ -649,12 +645,7 @@ if (childEntry.schema) {
649645
tag,
650646
);
651647
errors.push(
652-
...validateElement(
653-
childEntry.schema,
654-
child,
655-
tag,
656-
childBooleanCheck.names,
657-
),
648+
...validateElement(childEntry.schema, child, tag, childBooleanCheck.names),
658649
);
659650
}
660651
```
@@ -685,6 +676,7 @@ git commit -m "feat: reject custom tag boolean attributes"
685676
### Task 4: Validator Type Narrowing
686677
687678
**Files:**
679+
688680
- Modify: `js/shared/tagValidators.ts`
689681
- Create: `js/shared/tagValidators.type.test.ts`
690682
@@ -741,17 +733,14 @@ In `js/shared/tagValidators.ts`, add:
741733
742734
```ts
743735
export type AttributeValue = string | true;
744-
export type AttributeValueFor<
745-
TAllowBooleanAttributes extends boolean,
746-
> = TAllowBooleanAttributes extends false ? string : AttributeValue;
736+
export type AttributeValueFor<TAllowBooleanAttributes extends boolean> =
737+
TAllowBooleanAttributes extends false ? string : AttributeValue;
747738
```
748739
749740
Update `TagElement`:
750741
751742
```ts
752-
export interface TagElement<
753-
TAllowBooleanAttributes extends boolean = true,
754-
> {
743+
export interface TagElement<TAllowBooleanAttributes extends boolean = true> {
755744
readonly tag: string;
756745
readonly attributes: Readonly<
757746
Record<string, AttributeValueFor<TAllowBooleanAttributes>>
@@ -798,6 +787,7 @@ git commit -m "feat: narrow tag validator attribute values"
798787
### Task 5: Documentation And Full Verification
799788
800789
**Files:**
790+
801791
- Modify: `README.md`
802792
- Modify: `docs/superpowers/specs/2026-05-15-valueless-custom-tag-attributes-design.md`
803793
@@ -817,14 +807,14 @@ For projects whose custom elements require explicit values, disable boolean attr
817807
```jsonc
818808
{
819809
"customTagDefaults": {
820-
"allowBooleanAttributes": false
810+
"allowBooleanAttributes": false,
821811
},
822812
"customTags": [
823813
{
824814
"name": "pl-answer",
825-
"allowBooleanAttributes": true
826-
}
827-
]
815+
"allowBooleanAttributes": true,
816+
},
817+
],
828818
}
829819
```
830820

docs/superpowers/specs/2026-05-15-boolean-custom-tag-attributes-design.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Example with boolean attributes disabled by default for custom tags, but allowed
7575
```jsonc
7676
{
7777
"customTagDefaults": { "allowBooleanAttributes": false },
78-
"customTags": [{ "name": "pl-answer", "allowBooleanAttributes": true }]
78+
"customTags": [{ "name": "pl-answer", "allowBooleanAttributes": true }],
7979
}
8080
```
8181

@@ -94,9 +94,9 @@ with:
9494
```jsonc
9595
{
9696
"customTagDefaults": {
97-
"allowBooleanAttributes": false
97+
"allowBooleanAttributes": false,
9898
},
99-
"customTags": [{ "name": "pl-answer" }]
99+
"customTags": [{ "name": "pl-answer" }],
100100
}
101101
```
102102

@@ -125,18 +125,23 @@ Keep the existing default ergonomic API:
125125
```ts
126126
type AttributeValue = string | true;
127127

128-
interface TagElement<
129-
TAllowBooleanAttributes extends boolean = true,
130-
> {
128+
interface TagElement<TAllowBooleanAttributes extends boolean = true> {
131129
readonly attributes: Readonly<
132-
Record<string, TAllowBooleanAttributes extends false ? string : AttributeValue>
130+
Record<
131+
string,
132+
TAllowBooleanAttributes extends false ? string : AttributeValue
133+
>
133134
>;
134135
getAttribute(
135136
name: string,
136-
): TAllowBooleanAttributes extends false ? string | undefined : AttributeValue | undefined;
137+
): TAllowBooleanAttributes extends false
138+
? string | undefined
139+
: AttributeValue | undefined;
137140
getLiteralAttribute(
138141
name: string,
139-
): TAllowBooleanAttributes extends false ? string | undefined : AttributeValue | undefined;
142+
): TAllowBooleanAttributes extends false
143+
? string | undefined
144+
: AttributeValue | undefined;
140145
}
141146
```
142147

js/linter/linter.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,7 @@ describe('draft-06 flat custom tag schemas', () => {
318318
customTags: [
319319
{
320320
name: 'pl-multiple-choice',
321-
children: [
322-
{ name: 'pl-answer', allowBooleanAttributes: false },
323-
],
321+
children: [{ name: 'pl-answer', allowBooleanAttributes: false }],
324322
},
325323
{
326324
name: 'pl-question',

js/shared/configSchema.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,7 @@ function parseStringRecord(value: unknown): Record<string, string> | undefined {
295295
return parsed.success ? parsed.data : undefined;
296296
}
297297

298-
function parseCustomTagDefaults(
299-
value: unknown,
300-
): CustomTagDefaults | undefined {
298+
function parseCustomTagDefaults(value: unknown): CustomTagDefaults | undefined {
301299
if (!value || typeof value !== 'object' || Array.isArray(value)) {
302300
return undefined;
303301
}

0 commit comments

Comments
 (0)