Skip to content

Commit

Permalink
Fix: no-invalid-meta crashes for non Object values (fixes #10750) (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
s4san authored and platinumazure committed Aug 18, 2018
1 parent 11a462d commit 034690f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/tools/internal-rules/no-invalid-meta.js
Expand Up @@ -126,6 +126,24 @@ ruleTester.run("no-invalid-meta", rule, {
column: 18
}]
},
{
code: [
"module.exports = {",
" meta: [],",

" create: function(context) {",
" return {",
" Program: function(node) {}",
" };",
" }",
"};"
].join("\n"),
errors: [{
message: "Rule is missing a meta.docs property.",
line: 2,
column: 5
}]
},
{
code: [
"module.exports = {",
Expand Down
6 changes: 6 additions & 0 deletions tools/internal-rules/consistent-docs-description.js
Expand Up @@ -25,6 +25,12 @@ const ALLOWED_FIRST_WORDS = [
function getPropertyFromObject(property, node) {
const properties = node.properties;

if (!Array.isArray(properties)) {

// if properties is not an array, "internal-no-invalid-meta" will already report this.
return null;
}

for (let i = 0; i < properties.length; i++) {
if (properties[i].key.name === property) {
return properties[i];
Expand Down
6 changes: 6 additions & 0 deletions tools/internal-rules/consistent-docs-url.js
Expand Up @@ -21,6 +21,12 @@ const path = require("path");
function getPropertyFromObject(property, node) {
const properties = node.properties;

if (!Array.isArray(properties)) {

// if properties is not an array, "internal-no-invalid-meta" will already report this.
return null;
}

for (let i = 0; i < properties.length; i++) {
if (properties[i].key.name === property) {
return properties[i];
Expand Down
5 changes: 5 additions & 0 deletions tools/internal-rules/no-invalid-meta.js
Expand Up @@ -19,6 +19,11 @@
function getPropertyFromObject(property, node) {
const properties = node.properties;

if (!Array.isArray(properties)) {

return null;
}

for (let i = 0; i < properties.length; i++) {
if (properties[i].key.name === property) {
return properties[i];
Expand Down

0 comments on commit 034690f

Please sign in to comment.