-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
cli.js
executable file
·73 lines (59 loc) · 1.9 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env node
import { cli } from 'standard-engine'
import minimist from 'minimist'
import options from './options.js'
import { CURRENT_WORKING_DIRECTORY } from './constants.js'
import { _getTSConfigPath } from './resolve-tsconfig.js'
const tsStandardCli = () => {
const cliOptions = { ...options }
const argv = minimist(process.argv.slice(2), {
alias: {
project: 'p',
help: 'h'
},
boolean: ['help'],
string: ['project']
})
if (argv.help) {
console.log(
'%s - %s (%s)',
cliOptions.cmd,
cliOptions.tagline,
cliOptions.homepage
)
console.log(`
Usage:
${cliOptions.cmd} <flags> [FILES...]
If FILES is omitted, all JavaScript/TypeScript source files (*.js, *.jsx, *.mjs, *.cjs, *.ts, *.tsx)
in the current working directory are checked, recursively.
Certain paths (node_modules/, coverage/, vendor/, *.min.js, and
files/folders that begin with '.' like .git/) are automatically ignored.
Paths in a project's root .gitignore file are also automatically ignored.
Flags:
--fix Automatically fix problems
-p, --project Specify ts-config location (default: ./tsconfig.eslint.json or ./tsconfig.json)
--version Show current version
-h, --help Show usage information
Flags (advanced):
--stdin Read file text from stdin
--ext Specify JavaScript/TypeScript file extensions
--global Declare global variable
--plugin Use custom eslint plugin
--env Use custom eslint environment
--parser Use custom ts/js parser (default: @typescript-eslint/parser)
`)
process.exitCode = 0
return
}
if (argv.version) {
console.log(cliOptions.version)
process.exitCode = 0
return
}
cliOptions.eslintConfig.overrideConfig.parserOptions.project = _getTSConfigPath(
CURRENT_WORKING_DIRECTORY,
argv.project
)
cli(cliOptions)
}
tsStandardCli()