UNPKG

1.75 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11Object.defineProperty(exports, "__esModule", { value: true });
12const eslint_1 = require("eslint");
13const glob = require("glob");
14const path = require("path");
15function default_1({ projectConfig }) {
16 return __awaiter(this, void 0, void 0, function* () {
17 const appPath = process.cwd();
18 const globPattern = glob.sync(path.join(appPath, '.eslintrc*'));
19 const eslintCli = new eslint_1.ESLint({
20 cwd: process.cwd(),
21 useEslintrc: Boolean(globPattern.length),
22 baseConfig: {
23 extends: [`taro/${projectConfig.framework}`]
24 }
25 });
26 const sourceFiles = path.join(process.cwd(), projectConfig.sourceRoot, '**/*.{js,ts,jsx,tsx}');
27 const report = yield eslintCli.lintFiles([sourceFiles]);
28 const formatter = yield eslintCli.loadFormatter();
29 return {
30 desc: '检查 ESLint (以下为 ESLint 的输出)',
31 raw: formatter.format(report)
32 };
33 });
34}
35exports.default = default_1;
36//# sourceMappingURL=eslintValidator.js.map
\No newline at end of file