UNPKG

tslint-to-eslint-config

Version:

Converts your TSLint configuration to the closest reasonable ESLint equivalent.

50 lines 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertComments = void 0; const types_1 = require("../../types"); const utils_1 = require("../../utils"); /** * Root-level driver to convert a tslint:disable comments to eslint-disables. * @see `/docs/Architecture/Comments.md` for documentation. */ const convertComments = async (dependencies, { comments }, { typescript }, ruleEquivalents) => { // 1. If no comments are requested to be converted, immediately report it out and mark this as passed. if (comments === undefined) { dependencies.reportCommentResults(); return { data: undefined, status: types_1.ResultStatus.Succeeded, }; } // 2. Create the list of include and possibly exclude globs to search on. const commentFileNames = await dependencies.collectCommentFileNames(comments, typescript); if (commentFileNames instanceof Error) { return { errors: [commentFileNames], status: types_1.ResultStatus.Failed, }; } // 3. Search for files matching those globs to have their comments converted. const globbedFilePaths = await dependencies.extractGlobPaths(commentFileNames); if (globbedFilePaths.status !== types_1.ResultStatus.Succeeded) { return globbedFilePaths; } // 4. Convert comments in the contents of each file, storing equivalents in a cache. const uniqueGlobbedFilePaths = globbedFilePaths.data; const ruleCommentsCache = new Map(); const fileFailures = (await Promise.all(globbedFilePaths.data.map(async (filePath) => dependencies.convertFileComments(filePath, ruleCommentsCache, ruleEquivalents)))).filter(utils_1.isError); if (fileFailures.length !== 0) { return { errors: fileFailures, status: types_1.ResultStatus.Failed, }; } // 5. Report out the results of converting the unique globbed file paths. dependencies.reportCommentResults(uniqueGlobbedFilePaths); return { data: uniqueGlobbedFilePaths, status: types_1.ResultStatus.Succeeded, }; }; exports.convertComments = convertComments; //# sourceMappingURL=convertComments.js.map