UNPKG

tslint-to-eslint-config

Version:

Converts your TSLint configuration to the closest reasonable ESLint equivalent.

36 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertSpaceBeforeFunctionParen = void 0; const SUPPORTED_OPTIONS = ["anonymous", "asyncArrow", "named"]; const isObjectArgument = (argument) => typeof argument === "object" && argument !== null; const convertSpaceBeforeFunctionParen = (tslintRule) => { const argument = tslintRule.ruleArguments[0]; const ruleName = "space-before-function-paren"; if (argument === "always" || argument === "never") { return { rules: [{ ruleArguments: [argument], ruleName }] }; } if (isObjectArgument(argument)) { const notices = Object.keys(argument) .filter((option) => !SUPPORTED_OPTIONS.includes(option)) .map((option) => `Option "${option}" is not supported by ESLint.`); const filtered = Object.keys(argument) .filter((option) => SUPPORTED_OPTIONS.includes(option)) .reduce((obj, option) => { return { ...obj, [option]: argument[option] }; }, {}); return { rules: [ { ...(notices.length !== 0 && { notices }), ...(Object.keys(filtered).length !== 0 && { ruleArguments: [filtered], }), ruleName, }, ], }; } return { rules: [{ ruleName }] }; }; exports.convertSpaceBeforeFunctionParen = convertSpaceBeforeFunctionParen; //# sourceMappingURL=space-before-function-paren.js.map