tslint-to-eslint-config
Version:
Converts your TSLint configuration to the closest reasonable ESLint equivalent.
42 lines • 1.31 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertMaxFuncBodyLength = void 0;
const isNumber_1 = __importDefault(require("lodash/isNumber"));
const parseExtras = (ruleArguments) => {
if (ruleArguments.length === 0) {
return {};
}
const [max] = ruleArguments;
if (typeof max === "number") {
return {
ruleArguments: [max],
};
}
const notices = [
"ESLint's max-statements rule only supports a single maximum function length.",
];
if (max["ignore-comments"]) {
notices.push("ESLint's max-statements rule does not have an option to ignore comments.");
}
return {
notices,
ruleArguments: [
Math.max(...Object.values(max).filter(isNumber_1.default)),
],
};
};
const convertMaxFuncBodyLength = (tslintRule) => {
return {
rules: [
{
...parseExtras(tslintRule.ruleArguments),
ruleName: "max-statements",
},
],
};
};
exports.convertMaxFuncBodyLength = convertMaxFuncBodyLength;
//# sourceMappingURL=max-func-body-length.js.map