Skip to content

Commit 310aa7a

Browse files
committed
feat: add typescript support
1 parent 5d80b02 commit 310aa7a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bin/lint.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
const fs = require('fs')
34
const yargs = require('yargs')
45
const execSync = require('child_process').execSync
56

@@ -8,6 +9,11 @@ const argv = yargs.usage('Usage: $0 [options]').option('fix', {
89
type: 'boolean',
910
}).argv
1011

12+
const IS_TYPESCRIPT =
13+
fs.existsSync('tsconfig.json') ||
14+
fs.existsSync('../tsconfig.json') ||
15+
fs.existsSync('../../tsconfig.json')
16+
1117
function exec(command) {
1218
try {
1319
execSync(command, {stdio: 'inherit'})
@@ -18,8 +24,11 @@ function exec(command) {
1824
}
1925
}
2026

27+
const directories = `?(packages/*/){src/**/,lib/**/,bin/**/,test/**/,./}`
28+
2129
const lintFixArg = argv.fix ? '--fix' : ''
22-
const lintPassed = exec(`eslint ${lintFixArg} .`)
30+
const lintCommand = IS_TYPESCRIPT ? `tslint --project .` : `eslint ${directories}*.js`
31+
const lintPassed = exec(`${lintCommand} ${lintFixArg}`)
2332
const prettierFixArg = argv.fix ? '--write' : '--list-different'
24-
const prettierPassed = exec(`prettier ${prettierFixArg} '**/*.{ts,css,scss,md}'`)
33+
const prettierPassed = exec(`prettier ${prettierFixArg} '${directories}*.{ts,css,scss,md}'`)
2534
process.exit(lintPassed && prettierPassed ? 0 : 1)

0 commit comments

Comments
 (0)