1 | "use strict";
|
2 |
|
3 | var _path = _interopRequireDefault(require("path"));
|
4 |
|
5 | var _crossSpawn = _interopRequireDefault(require("cross-spawn"));
|
6 |
|
7 | var _yargsParser = _interopRequireDefault(require("yargs-parser"));
|
8 |
|
9 | var _utils = require("../utils");
|
10 |
|
11 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12 |
|
13 | const unnecessaryArgumentsCount = 2;
|
14 | let args = process.argv.slice(unnecessaryArgumentsCount);
|
15 |
|
16 | const here = p => _path.default.join(__dirname, p);
|
17 |
|
18 | const hereRelative = p => here(p).replace(process.cwd(), ".");
|
19 |
|
20 | const parsedArgs = (0, _yargsParser.default)(args);
|
21 | const useBuiltinConfig = !args.includes("--config") && !(0, _utils.hasFile)(".eslintrc") && !(0, _utils.hasFile)(".eslintrc.js") && !(0, _utils.hasPkgProp)("eslintConfig");
|
22 | const config = useBuiltinConfig ? ["--config", hereRelative("../config/eslintrc.js")] : [];
|
23 | const cache = args.includes("--no-cache") ? [] : ["--cache"];
|
24 | const filesGiven = parsedArgs._.length > 0;
|
25 | const filesToApply = filesGiven ? [] : ["."];
|
26 | const extensions = ["--ext", ".js,.ts"];
|
27 | const cacheLocation = ["--cache-location", "node_modules/.cache/.eslintcache"];
|
28 |
|
29 | const isLintable = file => file.endsWith(".js") || file.endsWith(".ts");
|
30 |
|
31 | if (filesGiven) {
|
32 |
|
33 |
|
34 |
|
35 | args = args.filter(a => !parsedArgs._.includes(a) || isLintable(a));
|
36 | }
|
37 |
|
38 | const lintArguments = [...config, ...extensions, ...cacheLocation, ...cache, ...args, ...filesToApply];
|
39 | (0, _utils.logScriptMessage)("LINT");
|
40 |
|
41 | const result = _crossSpawn.default.sync((0, _utils.resolveBin)("eslint"), lintArguments, {
|
42 | stdio: "inherit"
|
43 | });
|
44 |
|
45 | process.exit(result.status);
|
46 |
|
\ | No newline at end of file |