Skip to content

Commit 7f99077

Browse files
fix(require-meta-schema-description): handle non-iterable schema properties (#493)
1 parent c047d73 commit 7f99077

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

Diff for: lib/rules/require-meta-schema-description.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ module.exports = {
8787
case 'properties': {
8888
hadChildren = true;
8989

90-
for (const property of value.properties) {
91-
if (property.value?.type === 'ObjectExpression') {
92-
checkSchemaElement(property.value);
90+
if (Array.isArray(value.properties)) {
91+
for (const property of value.properties) {
92+
if (property.value?.type === 'ObjectExpression') {
93+
checkSchemaElement(property.value);
94+
}
9395
}
9496
}
9597

Diff for: tests/lib/rules/require-meta-schema-description.js

+35
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,41 @@ module.exports = {
145145
create() {}
146146
};
147147
`,
148+
`
149+
module.exports = {
150+
meta: {
151+
schema: [
152+
{
153+
type: 'object',
154+
properties: null,
155+
additionalProperties: false
156+
}
157+
],
158+
},
159+
create() {}
160+
}
161+
`,
162+
`
163+
const DEFAULT_OPTIONS = Object.freeze({});
164+
165+
module.exports = {
166+
meta: {
167+
schema: [
168+
{
169+
type: 'object',
170+
properties: Object.fromEntries(
171+
Object.keys(DEFAULT_OPTIONS).map((code) => [
172+
code,
173+
{ type: 'boolean' }
174+
])
175+
),
176+
additionalProperties: false
177+
}
178+
],
179+
},
180+
create() {}
181+
}
182+
`,
148183
],
149184

150185
invalid: [

0 commit comments

Comments
 (0)