Remove JSXText spacial case in comment attaching (#9759)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-11-24 17:37:29 +08:00
1 parent 3513f26d39
commit d02a367e64
4 files changed
+73 -8

No files matched your search

-8
View File
@@ -565,14 +565,6 @@ 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
/* istanbul ignore next */
if (node.type === "JSXText") {
comment.printed = true;
}
}
function addLeadingComment(node, comment) {
@@ -222,3 +222,58 @@ printWidth: 80
================================================================================
`;
exports[`jsx-tag-comment-after-prop.js - {"jsxBracketSameLine":true} format 1`] = `
====================================options=====================================
jsxBracketSameLine: true
parsers: ["flow", "babel", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
// https://github.com/typescript-eslint/typescript-eslint/pull/703
const pure = () => {
return (
<Foo
// one
foo={123}
// two
bar="woof"
/>
);
}
=====================================output=====================================
// https://github.com/typescript-eslint/typescript-eslint/pull/703
const pure = () => {
return (
<Foo
// one
foo={123}
// two
bar="woof"
/>
);
};
================================================================================
`;
exports[`like-a-comment-in-jsx-text.js - {"jsxBracketSameLine":true} format 1`] = `
====================================options=====================================
jsxBracketSameLine: true
parsers: ["flow", "babel", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
<Foo
>
text
// comment
text
</Foo>
=====================================output=====================================
<Foo>text // comment text</Foo>;
================================================================================
`;
@@ -0,0 +1,12 @@
// https://github.com/typescript-eslint/typescript-eslint/pull/703
const pure = () => {
return (
<Foo
// one
foo={123}
// two
bar="woof"
/>
);
}
@@ -0,0 +1,6 @@
<Foo
>
text
// comment
text
</Foo>