Skip to content

Commit

Permalink
Fix: consistent-docs-url crashes if meta.docs is empty (fixes #10722) (
Browse files Browse the repository at this point in the history
  • Loading branch information
s4san authored and platinumazure committed Aug 11, 2018
1 parent 6492233 commit 562a03f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/tools/internal-rules/consistent-docs-url.js
Expand Up @@ -43,6 +43,23 @@ ruleTester.run("consistent-docs-url", rule, {
].join("\n")
],
invalid: [
{
code: [
"module.exports = {",
" meta: {",
" },",

" create: function(context) {",
" return {};",
" }",
"};"
].join("\n"),
errors: [{
message: "Rule is missing a meta.docs property",
line: 2,
column: 5
}]
},
{
code: [
"module.exports = {",
Expand Down
8 changes: 8 additions & 0 deletions tools/internal-rules/consistent-docs-url.js
Expand Up @@ -48,6 +48,14 @@ function checkMetaDocsUrl(context, exportsNode) {
const metaDocs = metaProperty && getPropertyFromObject("docs", metaProperty.value);
const metaDocsUrl = metaDocs && getPropertyFromObject("url", metaDocs.value);

if (!metaDocs) {
context.report({
node: metaProperty,
message: "Rule is missing a meta.docs property"
});
return;
}

if (!metaDocsUrl) {
context.report({
node: metaDocs,
Expand Down

0 comments on commit 562a03f

Please sign in to comment.