Skip to content

Commit

Permalink
fix(valid-describe): add check for empty arguments (#94)
Browse files Browse the repository at this point in the history
Fixes #93
  • Loading branch information
with-heart authored and SimenB committed Mar 13, 2018
1 parent fb54759 commit 80c9b33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rules/__tests__/valid-describe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ ruleTester.run('valid-describe', rule, {
},
],
},
{
code: 'describe()',
errors: [
{
message: 'Describe requires name and callback arguments',
line: 1,
column: 1,
},
],
},
{
code: 'describe("foo", async () => {})',
errors: [{ message: 'No async describe callback', line: 1, column: 17 }],
Expand Down
7 changes: 7 additions & 0 deletions rules/valid-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ module.exports = {
return {
CallExpression(node) {
if (isDescribe(node)) {
if (node.arguments.length === 0) {
return context.report({
message: 'Describe requires name and callback arguments',
loc: node.loc,
});
}

const name = node.arguments[0];
const callbackFunction = node.arguments[1];
if (!isString(name)) {
Expand Down

0 comments on commit 80c9b33

Please sign in to comment.