UNPKG

736 BJavaScriptView Raw
1#!/usr/bin/env node
2/**
3 * @fileoverview This simply delegates to eslint
4 * @author bigpopakap
5 */
6'use strict';
7
8const shell = require('shelljs');
9const yargs = require('yargs');
10
11// Exit if there is no yarn installed
12if (!shell.which('yarn')) {
13 shell.echo('yarn not installed');
14 shell.exit(1);
15}
16
17// Parse the command line arguments
18const args = yargs.boolean('fix').default('fix', false).argv;
19
20// Prepare the arguments to pass to eslint
21const extArg = `--ext json,js,jsx,ts,d.ts,tsx`;
22const fixArg = args.fix ? '--fix' : '';
23const pathArg = '.';
24
25const lintResult = shell.exec(`yarn eslint ${extArg} ${fixArg} ${pathArg}`);
26if (lintResult.code !== 0) {
27 throw new Error('eslint found errors. See above output for details.');
28}