diff --git a/lib/rules/no-commented-tests.js b/lib/rules/no-commented-tests.js index 842b6719..db2786a6 100644 --- a/lib/rules/no-commented-tests.js +++ b/lib/rules/no-commented-tests.js @@ -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 = []; diff --git a/tests/lib/rules/no-commented-tests.js b/tests/lib/rules/no-commented-tests.js index 8324fbad..14853835 100644 --- a/tests/lib/rules/no-commented-tests.js +++ b/tests/lib/rules/no-commented-tests.js @@ -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: [ @@ -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 + } + ] } ]