filter comment tokens - fixes babel/babel-eslint#153
This commit is contained in:
parent
8baea68c6c
commit
c551545f29
@ -70,7 +70,9 @@ exports.toTokens = function (tokens) {
|
|||||||
// transform tokens to type "Template"
|
// transform tokens to type "Template"
|
||||||
convertTemplateType(tokens);
|
convertTemplateType(tokens);
|
||||||
|
|
||||||
return tokens.map(exports.toToken);
|
return tokens.filter(function (token) {
|
||||||
|
return token.type !== "CommentLine" && token.type !== "CommentBlock";
|
||||||
|
}).map(exports.toToken);
|
||||||
};
|
};
|
||||||
|
|
||||||
function convertTemplateType(tokens) {
|
function convertTemplateType(tokens) {
|
||||||
|
|||||||
@ -1193,4 +1193,29 @@ describe("verify", function () {
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("excludes comment tokens #153", function () {
|
||||||
|
verifyAndAssertMessages(
|
||||||
|
[
|
||||||
|
"var a = [",
|
||||||
|
"1,",
|
||||||
|
"2, // a trailing comment makes this line fail comma-dangle (always-multiline)",
|
||||||
|
"];",
|
||||||
|
].join("\n"),
|
||||||
|
{ "comma-dangle": [2, "always-multiline"] },
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyAndAssertMessages(
|
||||||
|
[
|
||||||
|
"switch (a) {",
|
||||||
|
"// A comment here makes the above line fail brace-style",
|
||||||
|
"case 1:",
|
||||||
|
"console.log(a);",
|
||||||
|
"}"
|
||||||
|
].join("\n"),
|
||||||
|
{ "brace-style": 2 },
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user