1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | 'use strict';
|
7 |
|
8 | const shell = require('shelljs');
|
9 | const yargs = require('yargs');
|
10 |
|
11 |
|
12 | if (!shell.which('yarn')) {
|
13 | shell.echo('yarn not installed');
|
14 | shell.exit(1);
|
15 | }
|
16 |
|
17 |
|
18 | const args = yargs.boolean('fix').default('fix', false).argv;
|
19 |
|
20 |
|
21 | const extArg = `--ext json,js,jsx,ts,d.ts,tsx`;
|
22 | const fixArg = args.fix ? '--fix' : '';
|
23 | const pathArg = '.';
|
24 |
|
25 | const lintResult = shell.exec(`yarn eslint ${extArg} ${fixArg} ${pathArg}`);
|
26 | if (lintResult.code !== 0) {
|
27 | throw new Error('eslint found errors. See above output for details.');
|
28 | }
|