From 6c38d3df3f8005ec64434a229bec6f5245f1910c Mon Sep 17 00:00:00 2001 From: Steven Zeck Date: Tue, 6 Feb 2018 13:52:25 -0600 Subject: [PATCH 1/2] Fix typescript-formatter issues for TSX --- examples/simple-jsbeautifyrc/tsx/original/test.tsx | 12 ++++++------ src/beautifiers/typescript-formatter.coffee | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/simple-jsbeautifyrc/tsx/original/test.tsx b/examples/simple-jsbeautifyrc/tsx/original/test.tsx index a974f18..5d2797f 100644 --- a/examples/simple-jsbeautifyrc/tsx/original/test.tsx +++ b/examples/simple-jsbeautifyrc/tsx/original/test.tsx @@ -1,12 +1,12 @@ class Test extends React.Component { - render() { +render() { return (
-

+

{this.foo.bar}

- {this.foo.bar.children} -
- ); - } +{this.foo.bar.children} + + ); +} } \ No newline at end of file diff --git a/src/beautifiers/typescript-formatter.coffee b/src/beautifiers/typescript-formatter.coffee index a5081ea..7ca7fd7 100644 --- a/src/beautifiers/typescript-formatter.coffee +++ b/src/beautifiers/typescript-formatter.coffee @@ -26,8 +26,13 @@ module.exports = class TypeScriptFormatter extends Beautifier opts.indentSize = options.indent_size opts.indentStyle = 'space' + if language is "TSX" + fileName = 'test.tsx' + else + fileName = '' + @verbose('typescript', text, opts) - result = format('', text, opts) + result = format(fileName, text, opts) @verbose(result) resolve result catch e From ea3361812433ddbbb2b35fa15e46f2c3b19c0e46 Mon Sep 17 00:00:00 2001 From: Steven Zeck Date: Tue, 6 Feb 2018 13:54:44 -0600 Subject: [PATCH 2/2] Fix expected output for TSX --- examples/simple-jsbeautifyrc/tsx/expected/test.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/simple-jsbeautifyrc/tsx/expected/test.tsx b/examples/simple-jsbeautifyrc/tsx/expected/test.tsx index ced5af2..2619759 100644 --- a/examples/simple-jsbeautifyrc/tsx/expected/test.tsx +++ b/examples/simple-jsbeautifyrc/tsx/expected/test.tsx @@ -1,12 +1,12 @@ class Test extends React.Component { render() { return ( -
-

- { this.foo.bar } - < /h2> - { this.foo.bar.children } -

+
+

+ {this.foo.bar} +

+ {this.foo.bar.children} +
); } -} +} \ No newline at end of file