Skip to content

Commit 4ce3c11

Browse files
committed
lint
1 parent b5f6b76 commit 4ce3c11

2 files changed

Lines changed: 24 additions & 31 deletions

File tree

packages/core/src/attributes.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ export function isAttributeObject(maybeObj: unknown): maybeObj is AttributeObjec
6363
/**
6464
* Converts an attribute value to a typed attribute value.
6565
*
66-
* For now, we support primitive values, homogeneous arrays of primitives, and attribute objects
67-
* with primitive or primitive-array values. If @param useFallback is true, we stringify other
68-
* non-primitive values to a string attribute value. Otherwise we return `undefined` for unsupported
69-
* values.
66+
* For now, we support primitive values and homogeneous arrays of primitives, either raw or
67+
* inside attribute objects. If @param useFallback is true, we stringify other non-primitive values
68+
* to a string attribute value. Otherwise we return `undefined` for unsupported values.
7069
*
7170
* @param value - The value of the passed attribute.
7271
* @param useFallback - If true, unsupported values will be stringified to a string attribute value.

packages/core/test/lib/attributes.test.ts

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,13 @@ describe('attributeValueToTypedAttributeValue', () => {
7777
});
7878

7979
describe('homogeneous primitive arrays', () => {
80-
it.each([
81-
[['foo', 'bar']],
82-
[[1, 2, 3]],
83-
[[true, false, true]],
84-
[[] as unknown[]],
85-
])('emits a typed array attribute for raw value %j', value => {
86-
const result = attributeValueToTypedAttributeValue(value);
87-
expect(result).toStrictEqual({ value, type: 'array' });
88-
});
80+
it.each([[['foo', 'bar']], [[1, 2, 3]], [[true, false, true]], [[] as unknown[]]])(
81+
'emits a typed array attribute for raw value %j',
82+
value => {
83+
const result = attributeValueToTypedAttributeValue(value);
84+
expect(result).toStrictEqual({ value, type: 'array' });
85+
},
86+
);
8987

9088
it('emits a typed array attribute for attribute object values', () => {
9189
const result = attributeValueToTypedAttributeValue({ value: ['foo', 'bar'] });
@@ -94,25 +92,21 @@ describe('attributeValueToTypedAttributeValue', () => {
9492
});
9593

9694
describe('invalid values (non-primitives)', () => {
97-
it.each([
98-
[[1, 'foo', true]],
99-
[{ foo: 'bar' }],
100-
[() => 'test'],
101-
[Symbol('test')],
102-
])('returns undefined for non-primitive raw values (%s)', value => {
103-
const result = attributeValueToTypedAttributeValue(value);
104-
expect(result).toBeUndefined();
105-
});
95+
it.each([[[1, 'foo', true]], [{ foo: 'bar' }], [() => 'test'], [Symbol('test')]])(
96+
'returns undefined for non-primitive raw values (%s)',
97+
value => {
98+
const result = attributeValueToTypedAttributeValue(value);
99+
expect(result).toBeUndefined();
100+
},
101+
);
106102

107-
it.each([
108-
[[1, 'foo', true]],
109-
[{ foo: 'bar' }],
110-
[() => 'test'],
111-
[Symbol('test')],
112-
])('returns undefined for non-primitive attribute object values (%s)', value => {
113-
const result = attributeValueToTypedAttributeValue({ value });
114-
expect(result).toBeUndefined();
115-
});
103+
it.each([[[1, 'foo', true]], [{ foo: 'bar' }], [() => 'test'], [Symbol('test')]])(
104+
'returns undefined for non-primitive attribute object values (%s)',
105+
value => {
106+
const result = attributeValueToTypedAttributeValue({ value });
107+
expect(result).toBeUndefined();
108+
},
109+
);
116110
});
117111
});
118112

0 commit comments

Comments
 (0)