Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Fix false positives in no-triple-slash-reference #226

Merged
merged 1 commit into from
Dec 14, 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
7 changes: 5 additions & 2 deletions lib/rules/no-triple-slash-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ module.exports = {
url: util.metaDocsUrl("no-triple-slash-reference"),
},
schema: [],
messages: {
tripleSlashReference: "Do not use a triple slash reference.",
},
},

create(context) {
const referenceRegExp = /^\/\s*<reference/;
const referenceRegExp = /^\/\s*<reference\s*path=/;
const sourceCode = context.getSourceCode();

//----------------------------------------------------------------------
Expand All @@ -45,7 +48,7 @@ module.exports = {
if (referenceRegExp.test(comment.value)) {
context.report({
node: comment,
message: "Do not use a triple slash reference.",
messageId: "tripleSlashReference",
});
}
});
Expand Down
11 changes: 9 additions & 2 deletions tests/lib/rules/no-triple-slash-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ const ruleTester = new RuleTester({

ruleTester.run("no-triple-slash-reference", rule, {
valid: [
`/// <reference types="foo" />`,
`/// <reference lib="es2017.string" />`,
`/// <reference no-default-lib="true"/>`,
"/// Non-reference triple-slash comment",
"// <reference path='Animal' />",
`/*
/// <reference path="Animal" />
let a
*/`,
],
invalid: [
{
code: '/// <reference path="Animal" />',
errors: [
{
message: "Do not use a triple slash reference.",
messageId: "tripleSlashReference",
line: 1,
column: 1,
},
Expand All @@ -43,7 +50,7 @@ let a
parser: "typescript-eslint-parser",
errors: [
{
message: "Do not use a triple slash reference.",
messageId: "tripleSlashReference",
line: 2,
column: 1,
},
Expand Down