UNPKG

tslint-to-eslint-config

Version:

Converts your TSLint configuration to the closest reasonable ESLint equivalent.

46 lines 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertNoUnusedExpression = void 0; const convertNoUnusedExpression = (tslintRule) => { return { rules: [ { ruleName: "no-unused-expressions", ruleSeverity: "off", }, { ruleName: "@typescript-eslint/no-unused-expressions", ...collectNoticesAndArguments(tslintRule.ruleArguments), }, ], }; }; exports.convertNoUnusedExpression = convertNoUnusedExpression; const noAllowNewNotice = `The TSLint optional config "allow-new" is the default ESLint behavior and will no longer be ignored.`; const collectNoticesAndArguments = (tsLintRuleArguments) => { if (tsLintRuleArguments.length === 0) { return { notices: [noAllowNewNotice], }; } const notices = []; const ruleArguments = []; if (tsLintRuleArguments.includes("allow-tagged-template")) { ruleArguments.push({ allowTaggedTemplates: true }); } if (tsLintRuleArguments.includes("allow-fast-null-checks")) { ruleArguments.push({ allowShortCircuit: true }); } if (!tsLintRuleArguments.includes("allow-new")) { notices.push(noAllowNewNotice); } return { ...(notices.length !== 0 && { notices }), ...(ruleArguments.length !== 0 && { ruleArguments: [ ruleArguments.reduce((value, current) => Object.assign(value, current), {}), ], }), }; }; //# sourceMappingURL=no-unused-expression.js.map