Skip to content

Commit

Permalink
feat: run tsc -noemit on TS files during lint-staged (#135)
Browse files Browse the repository at this point in the history
* Run tsc on staged files when TypeScript is enabled
  • Loading branch information
AndrewCsontos committed Apr 18, 2020
1 parent 225cbdb commit 03172ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`.
Expand Down
3 changes: 2 additions & 1 deletion src/config/lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {resolveKcdScripts, resolveBin} = require('../utils')
const {resolveKcdScripts, resolveBin, ifTypescript} = require('../utils')

const kcdScripts = resolveKcdScripts()
const doctoc = resolveBin('doctoc')
Expand All @@ -10,4 +10,5 @@ module.exports = {
`${kcdScripts} lint`,
`${kcdScripts} test --findRelatedTests`,
],
'*.+(ts|tsx)': ifTypescript ? [`tsc --noEmit`] : undefined,
}

0 comments on commit 03172ac

Please sign in to comment.