UNPKG

tslint-to-eslint-config

Version:

Converts your TSLint configuration to the closest reasonable ESLint equivalent.

38 lines 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findESLintConfiguration = void 0; const utils_1 = require("../utils"); const findRawConfiguration_1 = require("./findRawConfiguration"); const findReportedConfiguration_1 = require("./findReportedConfiguration"); const defaultESLintConfiguration = { env: {}, extends: [], rules: {}, }; const findESLintConfiguration = async (dependencies, config) => { var _a; const filePath = (_a = config.eslint) !== null && _a !== void 0 ? _a : config.config; const [rawConfiguration, reportedConfiguration] = await Promise.all([ (0, findRawConfiguration_1.findRawConfiguration)(dependencies.importer, filePath, { extends: [], }), (0, findReportedConfiguration_1.findReportedConfiguration)(dependencies.exec, "eslint --print-config", filePath), ]); if (rawConfiguration instanceof Error) { return rawConfiguration; } if (reportedConfiguration instanceof Error) { return reportedConfiguration; } const extensions = (0, utils_1.uniqueFromSources)(rawConfiguration.extends, reportedConfiguration.extends); return { full: { ...defaultESLintConfiguration, ...reportedConfiguration, extends: extensions, }, raw: rawConfiguration, }; }; exports.findESLintConfiguration = findESLintConfiguration; //# sourceMappingURL=findESLintConfiguration.js.map