From 95f2c9aa4961bef308bce5010557133cdd3830ee Mon Sep 17 00:00:00 2001 From: Andrew Csontos Date: Fri, 17 Apr 2020 18:00:29 -0400 Subject: [PATCH 1/4] Run tsc on staged files when TypeScript is enabled --- src/config/lintstagedrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config/lintstagedrc.js b/src/config/lintstagedrc.js index b367b89d..8a756ca9 100644 --- a/src/config/lintstagedrc.js +++ b/src/config/lintstagedrc.js @@ -10,4 +10,5 @@ module.exports = { `${kcdScripts} lint`, `${kcdScripts} test --findRelatedTests`, ], + '*.+(ts|tsx)': ifTypescript ? [`tsc --noEmit`] : undefined } From 77298ad2f700c23f38569744523bfba7e3c4ef22 Mon Sep 17 00:00:00 2001 From: Andrew Csontos Date: Fri, 17 Apr 2020 18:12:38 -0400 Subject: [PATCH 2/4] extract ifTypeScript from utils --- src/config/lintstagedrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/lintstagedrc.js b/src/config/lintstagedrc.js index 8a756ca9..10bdd031 100644 --- a/src/config/lintstagedrc.js +++ b/src/config/lintstagedrc.js @@ -1,4 +1,4 @@ -const {resolveKcdScripts, resolveBin} = require('../utils') +const {resolveKcdScripts, resolveBin, ifTypescript} = require('../utils') const kcdScripts = resolveKcdScripts() const doctoc = resolveBin('doctoc') From 98e7b5ec262ad58c302bda881ef304bf35a00574 Mon Sep 17 00:00:00 2001 From: Andrew Csontos Date: Fri, 17 Apr 2020 18:14:12 -0400 Subject: [PATCH 3/4] format --- src/config/lintstagedrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/lintstagedrc.js b/src/config/lintstagedrc.js index 10bdd031..f447b8cf 100644 --- a/src/config/lintstagedrc.js +++ b/src/config/lintstagedrc.js @@ -10,5 +10,5 @@ module.exports = { `${kcdScripts} lint`, `${kcdScripts} test --findRelatedTests`, ], - '*.+(ts|tsx)': ifTypescript ? [`tsc --noEmit`] : undefined + '*.+(ts|tsx)': ifTypescript ? [`tsc --noEmit`] : undefined, } From 5a1093187cba5ef83ba7e520b67c5e4221e91f0e Mon Sep 17 00:00:00 2001 From: Andrew Csontos Date: Sat, 18 Apr 2020 01:00:53 -0400 Subject: [PATCH 4/4] =?UTF-8?q?fixed=20typo,=20add=20line=20about=20tsc=20?= =?UTF-8?q?=20=E2=80=94noemit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cba88d93..a9f3e570 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ add `@babel/preset-flow` to the `presets`-section. ### TypeScript Support -If the `tsconfig.json`-file is present in the project root directory and the +If the `tsconfig.json`-file is present in the project root directory and `typescript` is a dependency the `@babel/preset-typescript` will automatically get loaded when you use the default babel config that comes with `kcd-scripts`. If you customised your `.babelrc`-file you might need to manually add @@ -134,6 +134,8 @@ If you customised your `.babelrc`-file you might need to manually add `kcd-scripts` will automatically load any `.ts` and `.tsx` files, including the default entry point, so you don't have to worry about any rollup configuration. +`tsc --noemit` will run during lint-staged to verify that files will compile. + ## Inspiration This is inspired by `react-scripts`.