Skip to content

Commit

Permalink
fix: fix require-meta-schema-description rule crash
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io authored and aladdin-add committed Nov 18, 2024
1 parent 6fa563e commit 8630901
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/rules/require-meta-schema-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ module.exports = {
let hadDescription = false;

for (const { key, value } of node.properties) {
if (!key) {
continue;
}
const staticKey =
key.type === 'Identifier' ? { value: key.name } : getStaticValue(key);
if (!staticKey?.value) {
Expand Down
17 changes: 16 additions & 1 deletion tests/lib/rules/require-meta-schema-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ module.exports = {
`
const DEFAULT_OPTIONS = Object.freeze({});
module.exports = {
meta: {
schema: [
{
type: 'object',
properties: {
...schemaProperties,
},
}
],
},
create() {}
}
`,
`
module.exports = {
meta: {
schema: [
Expand All @@ -179,7 +194,7 @@ module.exports = {
},
create() {}
}
`,
`,
],

invalid: [
Expand Down

0 comments on commit 8630901

Please sign in to comment.