Do not throw for unprinted comments inside of JSX (#2036)

Fixes #1990
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-06-07 12:57:03 -07:00
1 parent ccda4c7115
commit 09f147decd
3 files changed
+37

No files matched your search

+7
View File
@@ -369,6 +369,13 @@ function addCommentHelper(node, comment) {
const comments = node.comments || (node.comments = []);
comments.push(comment);
comment.printed = false;
// For some reason, TypeScript parses `// x` inside of JSXText as a comment
// We already "print" it via the raw text, we don't need to re-print it as a
// comment
if (node.type === "JSXText") {
comment.printed = true;
}
}
function addLeadingComment(node, comment) {
@@ -21,6 +21,29 @@ abstract class AbstractRule {
`;
exports[`jsx.ts 1`] = `
var example1 = <div>
https://test
</div>;
var example2 = <div>
/*test*/
</div>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var example1 = (
<div>
https://test
</div>
);
var example2 = (
<div>
/*test*/
</div>
);
`;
exports[`types.ts 1`] = `
(() => {
// swallow error and fallback to using directory as path
+7
View File
@@ -0,0 +1,7 @@
var example1 = <div>
https://test
</div>;
var example2 = <div>
/*test*/
</div>;