tslint-to-eslint-config
Version:
Converts your TSLint configuration to the closest reasonable ESLint equivalent.
50 lines • 2.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertCommentFormat = exports.CapitalizedIgnoreMessage = void 0;
exports.CapitalizedIgnoreMessage = "Only accepts a single string pattern to be ignored.";
const convertCommentFormat = (tslintRule) => {
var _a;
const capitalizedRuleArguments = [];
const capitalizedNotices = [];
const checkSpace = tslintRule.ruleArguments.includes("check-space");
if (tslintRule.ruleArguments.includes("check-uppercase")) {
capitalizedRuleArguments.push("always");
}
else if (tslintRule.ruleArguments.includes("check-lowercase")) {
capitalizedRuleArguments.push("never");
}
if (typeof tslintRule.ruleArguments[tslintRule.ruleArguments.length - 1] === "object") {
const objectArgument = tslintRule.ruleArguments[tslintRule.ruleArguments.length - 1];
if (((_a = objectArgument["ignore-words"]) === null || _a === void 0 ? void 0 : _a.length) || objectArgument["ignore-pattern"]) {
capitalizedNotices.push(exports.CapitalizedIgnoreMessage);
}
}
return {
rules: [
...(capitalizedRuleArguments.length === 0
? []
: [
{
ruleName: "capitalized-comments",
ruleArguments: capitalizedRuleArguments,
...(capitalizedNotices.length !== 0 && { notices: capitalizedNotices }),
},
]),
...(checkSpace
? [
{
ruleName: "spaced-comment",
ruleArguments: [
"always",
{
markers: ["/"],
},
],
},
]
: []),
],
};
};
exports.convertCommentFormat = convertCommentFormat;
//# sourceMappingURL=comment-format.js.map