Skip to content

Commit

Permalink
Fix: Avoid some obvious no-commented-tests false positives (fixes #61)
Browse files Browse the repository at this point in the history
  • Loading branch information
platinumazure committed Jul 12, 2017
1 parent fa70868 commit 24df441
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-commented-tests.js
Expand Up @@ -21,7 +21,7 @@ module.exports = {
const sourceCode = context.getSourceCode(),
ERROR_MESSAGE = "Unexpected \"{{callee}}\" in comment. Use QUnit.skip outside of a comment.",
newlineRegExp = /\r\n|\r|\n/g,
warningRegExp = /\b(QUnit\.test|QUnit\.asyncTest|QUnit\.skip|test|asyncTest)\s*\(/g;
warningRegExp = /\b(QUnit\.test|QUnit\.asyncTest|QUnit\.skip|test|asyncTest)\s*\((?=`[^`]*`|'[^']*'|"[^"]*"|[^,)\s]+\s*,\s*[^)]*\))/g;

function getNewlineIndexes(text) {
const indexes = [];
Expand Down
51 changes: 50 additions & 1 deletion tests/lib/rules/no-commented-tests.js
Expand Up @@ -23,7 +23,14 @@ ruleTester.run("no-commented-tests", rule, {
"QUnit.skip('Name', function () { ok(true); });",

// shebang comments
"#!/some-test()"
"#!/some-test()",

// Not actually a commented test
"// TODO: Add test (ASAP)",
"// TODO: Add test (foo bar)",
"// TODO: Add test (unterminated-paren",
"// TODO: Add test ('unterminated quote)",
"// TODO: refactor with a Component test (instead of an Acceptance test)"
],

invalid: [
Expand Down Expand Up @@ -285,6 +292,48 @@ ruleTester.run("no-commented-tests", rule, {
column: 2
}
]
},

// Not actually tests, but look too suspicious
{
code: "// Using backticks: test (`test`)",
errors: [
{
message: "Unexpected \"test\" in comment. Use QUnit.skip outside of a comment.",
line: 1,
column: 21
}
]
},
{
code: "// Using single quotes: test ('test')",
errors: [
{
message: "Unexpected \"test\" in comment. Use QUnit.skip outside of a comment.",
line: 1,
column: 25
}
]
},
{
code: "// Using double quotes: test (\"test\")",
errors: [
{
message: "Unexpected \"test\" in comment. Use QUnit.skip outside of a comment.",
line: 1,
column: 25
}
]
},
{
code: "// Possible multiple args?: test (foo, bar)",
errors: [
{
message: "Unexpected \"test\" in comment. Use QUnit.skip outside of a comment.",
line: 1,
column: 29
}
]
}
]

Expand Down

0 comments on commit 24df441

Please sign in to comment.