Fix <this.x /> (#1886)

Would be nice to get it properly handled in https://github.com/eslint/typescript-eslint-parser/issues/307

Fixes #1877
master
Christopher Chedeau 2017-06-02 14:27:27 -07:00 committed by GitHub
parent 74f7f96fe4
commit 0e35d3758a
3 changed files with 11 additions and 6 deletions

View File

@ -1510,12 +1510,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":

View File

@ -37,3 +37,10 @@ const MyCoolList = ({ things }) =>
const MyCoolThing = ({ thingo }) => <li>{thingo}</li>;
`;
exports[`this.tsx 1`] = `
<this.state.Component />;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<this.state.Component />;
`;

View File

@ -0,0 +1 @@
<this.state.Component />;