From 2fa37cce6990500c259d65d460c69353c068c919 Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Sat, 18 Jan 2020 11:40:55 -0500 Subject: [PATCH 1/3] Configure ts-node to transpile JSX for React This allows oclif to parse jsx found in .tsx files. --- src/ts-node.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ts-node.ts b/src/ts-node.ts index ca59cc5f..34d71d7f 100644 --- a/src/ts-node.ts +++ b/src/ts-node.ts @@ -75,6 +75,7 @@ function registerTSNode(root: string) { sourceMap: true, rootDirs, typeRoots, + jsx: "react", }, }) } finally { From 2390a47855d08d787490c84c6813f5b2dfd3036d Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Sat, 18 Jan 2020 11:42:33 -0500 Subject: [PATCH 2/3] Allow oclif to discover .tsx files Notably does _not_ add support for .jsx files yet since this will require a separate tool chain to work with something like Babel as a transpiler for JSX in Javascript files. Also ensures that test files that are .tsx are still ignored. --- src/plugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index 58126d8f..4aef4eed 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -224,8 +224,8 @@ export class Plugin implements IPlugin { } this._debug(`loading IDs from ${this.commandsDir}`) const patterns = [ - '**/*.+(js|ts)', - '!**/*.+(d.ts|test.ts|test.js|spec.ts|spec.js)', + '**/*.+(js|ts|tsx)', + '!**/*.+(d.ts|test.ts|test.js|spec.ts|spec.js)?(x)', ] const ids = globby.sync(patterns, {cwd: this.commandsDir}) .map(file => { From cdb48768e3166767adaeedccea1335ee151e8537 Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Sat, 18 Jan 2020 11:57:11 -0500 Subject: [PATCH 3/3] lint: use single quotes --- src/ts-node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts-node.ts b/src/ts-node.ts index 34d71d7f..5af5c394 100644 --- a/src/ts-node.ts +++ b/src/ts-node.ts @@ -75,7 +75,7 @@ function registerTSNode(root: string) { sourceMap: true, rootDirs, typeRoots, - jsx: "react", + jsx: 'react', }, }) } finally {