Skip to content

Commit

Permalink
Fix <this.x />
Browse files Browse the repository at this point in the history
Would be nice to get it properly handled in eslint/typescript-eslint-parser#307

Fixes prettier#1877
  • Loading branch information
vjeux committed Jun 2, 2017
1 parent 7fd71fa commit 05a9e77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1507,12 +1507,9 @@ function genericPrintNoParens(path, options, print, args) {
return concat(parts);
case "JSXIdentifier":
// Can be removed when this is fixed:
// https://github.com/eslint/typescript-eslint-parser/issues/257
if (n.object && n.property) {
return join(".", [
path.call(print, "object"),
path.call(print, "property")
]);
// https://github.com/eslint/typescript-eslint-parser/issues/307
if (!n.name) {
return "this";
}
return "" + n.name;
case "JSXNamespacedName":
Expand Down
7 changes: 7 additions & 0 deletions tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ const MyCoolList = ({ things }) =>
const MyCoolThing = ({ thingo }) => <li>{thingo}</li>;
`;
exports[`this.tsx 1`] = `
<this.state.Component />;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<this.state.Component />;
`;
1 change: 1 addition & 0 deletions tests/typescript_tsx/this.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<this.state.Component />;

0 comments on commit 05a9e77

Please sign in to comment.