Skip to content

Commit

Permalink
fix(require-meta-schema-description): handle non-iterable schema prop…
Browse files Browse the repository at this point in the history
…erties (#493)
  • Loading branch information
JoshuaKGoldberg authored Oct 25, 2024
1 parent c047d73 commit 7f99077
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/rules/require-meta-schema-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ module.exports = {
case 'properties': {
hadChildren = true;

for (const property of value.properties) {
if (property.value?.type === 'ObjectExpression') {
checkSchemaElement(property.value);
if (Array.isArray(value.properties)) {
for (const property of value.properties) {
if (property.value?.type === 'ObjectExpression') {
checkSchemaElement(property.value);
}
}
}

Expand Down
35 changes: 35 additions & 0 deletions tests/lib/rules/require-meta-schema-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,41 @@ module.exports = {
create() {}
};
`,
`
module.exports = {
meta: {
schema: [
{
type: 'object',
properties: null,
additionalProperties: false
}
],
},
create() {}
}
`,
`
const DEFAULT_OPTIONS = Object.freeze({});
module.exports = {
meta: {
schema: [
{
type: 'object',
properties: Object.fromEntries(
Object.keys(DEFAULT_OPTIONS).map((code) => [
code,
{ type: 'boolean' }
])
),
additionalProperties: false
}
],
},
create() {}
}
`,
],

invalid: [
Expand Down

0 comments on commit 7f99077

Please sign in to comment.