mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-28 03:15:16 +00:00
39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
"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
|