GoScrobble/web/node_modules/fork-ts-checker-webpack-plugin/lib/createEslinter.js

39 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-04-25 02:47:15 +00:00
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var path = __importStar(require("path"));
var FsHelper_1 = require("./FsHelper");
function createEslinter(eslintOptions) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
var CLIEngine = require('eslint').CLIEngine;
// See https://eslint.org/docs/developer-guide/nodejs-api#cliengine
var eslinter = new CLIEngine(eslintOptions);
function getReport(filepath) {
try {
if (eslinter.isPathIgnored(filepath) ||
path.extname(filepath).localeCompare('.json', undefined, {
sensitivity: 'accent'
}) === 0) {
return undefined;
}
var lintReport = eslinter.executeOnFiles([filepath]);
if (eslintOptions && eslintOptions.fix) {
CLIEngine.outputFixes(lintReport);
}
return lintReport;
}
catch (e) {
FsHelper_1.throwIfIsInvalidSourceFileError(filepath, e);
}
return undefined;
}
return { getReport: getReport };
}
exports.createEslinter = createEslinter;
//# sourceMappingURL=createEslinter.js.map