Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(valid-describe): add check for empty arguments #94

Merged
merged 2 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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