Repository: typescript-eslint/tslint-to-eslint-config (ts)

Issue:
Missing converter: max-line-length
### 💥 Missing Converter

-   `tslint-to-eslint-config` version: 1.2.0
-   `typescript-eslint` version: 2.3.2

#### TSLint Rule Name

`max-line-length`


Pull request:
Added converter for max-line-length rule
<!--
👋 Hi, thanks for sending a PR to tslint-to-eslint-config! 💖
Please fill out all fields below to ensure your PR is reviewed quickly.
-->

## PR Checklist

-   [X] Addresses an existing issue: fixes #163 
-   [X] That issue was marked as [`status: accepting prs`](https://github.com/typescript-eslint/tslint-to-eslint-config/labels/status%3A%20accepting%20prs)

## Overview

<!-- Brief description of what is changed and how the code change does that. -->
Added converter for the max-line-length rule and unit tests.


Patch:
diff --git a/src/rules/converters.ts b/src/rules/converters.ts
index 782e17f..8aa11d7 100644
--- a/src/rules/converters.ts
+++ b/src/rules/converters.ts
@@ -23,6 +23,7 @@ import { convertLabelPosition } from "./converters/label-position";
 import { convertLinebreakStyle } from "./converters/linebreak-style";
 import { convertMaxClassesPerFile } from "./converters/max-classes-per-file";
 import { convertMaxFileLineCount } from "./converters/max-file-line-count";
+import { convertMaxLineLength } from "./converters/max-line-length";
 import { convertMemberOrdering } from "./converters/member-ordering";
 import { convertNewlinePerChainedCall } from "./converters/newline-per-chained-call";
 import { convertNewParens } from "./converters/new-parens";
@@ -100,6 +101,7 @@ import { convertUnifiedSignatures } from "./converters/unified-signatures";
 import { convertUnnecessaryBind } from "./converters/unnecessary-bind";
 import { convertUnnecessaryConstructor } from "./converters/unnecessary-constructor";
 import { convertUseIsnan } from "./converters/use-isnan";
+import { convertTripleEquals } from "./converters/triple-equals";
 
 /**
  * Keys TSLint rule names to their ESLint rule converters.
@@ -184,6 +186,7 @@ export const converters = new Map([
     ["linebreak-style", convertLinebreakStyle],
     ["max-classes-per-file", convertMaxClassesPerFile],
     ["max-file-line-count", convertMaxFileLineCount],
+    ["max-line-length", convertMaxLineLength],
     ["no-consecutive-blank-lines", convertNoConsecutiveBlankLines],
     ["no-console", convertNoConsole],
     ["no-empty", convertNoEmpty],
@@ -207,7 +210,7 @@ export const converters = new Map([
     ["no-octal-literal", convertNoOctalLiteral],
     ["no-regex-spaces", convertNoRegexSpaces],
     ["no-unnecessary-semicolons", convertNoUnnecessarySemicolons],
-
+    ["triple-equals", convertTripleEquals],
     // These converters are all for rules that need more complex option conversions.
     // Some of them will likely need to have notices about changed lint behaviors...
     // If you're willing to take on that work, that'd be great! Please send PRs! 💖
@@ -216,7 +219,6 @@ export const converters = new Map([
     // TSLint core rules:
     // ["ban", convertBan], // no-restricted-properties
     // ["import-blacklist", convertImportBlacklist], // no-restricted-imports
-    // ["max-line-length", convertMaxLineLength], // max-len
     // ["newline-before-return", convertNewlineBeforeReturn],
     // ["no-duplicate-variable", convertNoDuplicateVariable], // no-redeclare
     // ["no-shadowed-variable", convertNoShadowedVariable], // no-shadow
@@ -225,7 +227,6 @@ export const converters = new Map([
     // ["no-void-expression", convertNoVoidExpression], // (no exact equivalent)
     // ["quotemark", convertQuotemark], // quotes
     // ["space-within-parens", convertSpaceWithinParens], // space-in-parens
-    // ["triple-equals", convertTripleEquals], // eqeqeq
     // ["variable-name", convertVariableName], // a bunch of rules...
 
     // tslint-microsoft-contrib rules:
diff --git a/src/rules/converters/max-line-length.ts b/src/rules/converters/max-line-length.ts
new file mode 100644
index 0000000..24ad4b1
--- /dev/null
+++ b/src/rules/converters/max-line-length.ts
@@ -0,0 +1,43 @@
+import { RuleConverter } from "../converter";
+
+export const convertMaxLineLength: RuleConverter = tslintRule => {
+    return {
+        rules: [
+            {
+                ...collectArguments(tslintRule.ruleArguments),
+                ruleName: "max-len",
+            },
+        ],
+    };
+};
+
+const collectArguments = (ruleArguments: any[]) => {
+    if (ruleArguments.length === 0 || ruleArguments[0] === false || ruleArguments.length < 2) {
+        return undefined;
+    }
+
+    if (ruleArguments.length === 2 && typeof ruleArguments[1] === "number") {
+        return {
+            ruleArguments: [
+                {
+                    code: ruleArguments[1],
+                },
+            ],
+        };
+    }
+
+    const argument = ruleArguments[1];
+
+    return {
+        ruleArguments: [
+            {
+                ...("limit" in argument && { code: argument.limit }),
+                ...("ignore-pattern" in argument && { ignorePattern: argument["ignore-pattern"] }),
+                ...("check-strings" in argument && { ignoreStrings: !argument["check-strings"] }),
+                ...("check-regex" in argument && {
+                    ignoreRegExpLiterals: !argument["check-regex"],
+                }),
+            },
+        ],
+    };
+};
diff --git a/src/rules/converters/triple-equals.ts b/src/rules/converters/triple-equals.ts
new file mode 100644
index 0000000..26c6975
--- /dev/null
+++ b/src/rules/converters/triple-equals.ts
@@ -0,0 +1,48 @@
+import { RuleConverter } from "../converter";
+
+export const convertTripleEquals: RuleConverter = tslintRule => {
+    const getRuleOptions = () => {
+        const smartOptionNotice =
+            'Option "smart" allows for comparing two literal values, evaluating the value of typeof and null comparisons.';
+
+        if (
+            tslintRule.ruleArguments.length !== 0 &&
+            tslintRule.ruleArguments[0] === "allow-null-check"
+        ) {
+            return {
+                arguments: ["smart"],
+                notices: [smartOptionNotice],
+            };
+        }
+
+        if (
+            tslintRule.ruleArguments.length !== 0 &&
+            tslintRule.ruleArguments[0] === "allow-undefined-check"
+        ) {
+            return {
+                arguments: ["smart"],
+                notices: [
+                    'Option "allow-undefined-check" is not supported by ESLint. Option "smart" is the closest.',
+                    smartOptionNotice,
+                ],
+            };
+        }
+
+        return {
+            arguments: ["always"],
+            notices: [],
+        };
+    };
+
+    const options = getRuleOptions();
+
+    return {
+        rules: [
+            {
+                ruleName: "eqeqeq",
+                ruleArguments: options.arguments,
+                notices: options.notices,
+            },
+        ],
+    };
+};


Test patch:
diff --git a/src/rules/converters/tests/max-line-length.test.ts b/src/rules/converters/tests/max-line-length.test.ts
new file mode 100644
index 0000000..17332a2
--- /dev/null
+++ b/src/rules/converters/tests/max-line-length.test.ts
@@ -0,0 +1,194 @@
+import { convertMaxLineLength } from "../max-line-length";
+
+describe(convertMaxLineLength, () => {
+    test("conversion without arguments", () => {
+        const result = convertMaxLineLength({
+            ruleArguments: [],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleName: "max-len",
+                },
+            ],
+        });
+    });
+
+    test("conversion with one argument true value", () => {
+        const result = convertMaxLineLength({
+            ruleArguments: [true],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleName: "max-len",
+                },
+            ],
+        });
+    });
+
+    test("conversion with two arguments and first is false", () => {
+        const result = convertMaxLineLength({
+            ruleArguments: [false, 123],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleName: "max-len",
+                },
+            ],
+        });
+    });
+
+    test("conversion with two arguments and second is number", () => {
+        const result = convertMaxLineLength({
+            ruleArguments: [true, 123],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: [{ code: 123 }],
+                    ruleName: "max-len",
+                },
+            ],
+        });
+    });
+
+    test("conversion with two arguments and second is object", () => {
+        const result = convertMaxLineLength({
+            ruleArguments: [
+                true,
+                {
+                    limit: 123,
+                    "ignore-pattern": "^import |^export {(.*?)}",
+                    "check-strings": true,
+                    "check-regex": true,
+                },
+            ],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: [
+                        {
+                            code: 123,
+                            ignorePattern: "^import |^export {(.*?)}",
+                            ignoreStrings: false,
+                            ignoreRegExpLiterals: false,
+                        },
+                    ],
+                    ruleName: "max-len",
+                },
+            ],
+        });
+    });
+
+    test("conversion with check-strings inverting value true to false", () => {
+        const result = convertMaxLineLength({
+            ruleArguments: [
+                true,
+                {
+                    limit: 123,
+                    "check-strings": true,
+                },
+            ],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: [
+                        {
+                            code: 123,
+                            ignoreStrings: false,
+                        },
+                    ],
+                    ruleName: "max-len",
+                },
+            ],
+        });
+    });
+
+    test("conversion with check-strings inverting value false to true", () => {
+        const result = convertMaxLineLength({
+            ruleArguments: [
+                true,
+                {
+                    limit: 123,
+                    "check-strings": false,
+                },
+            ],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: [
+                        {
+                            code: 123,
+                            ignoreStrings: true,
+                        },
+                    ],
+                    ruleName: "max-len",
+                },
+            ],
+        });
+    });
+
+    test("conversion with check-regex inverting value true to false", () => {
+        const result = convertMaxLineLength({
+            ruleArguments: [
+                true,
+                {
+                    limit: 123,
+                    "check-regex": true,
+                },
+            ],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: [
+                        {
+                            code: 123,
+                            ignoreRegExpLiterals: false,
+                        },
+                    ],
+                    ruleName: "max-len",
+                },
+            ],
+        });
+    });
+
+    test("conversion with check-regex inverting value false to true", () => {
+        const result = convertMaxLineLength({
+            ruleArguments: [
+                true,
+                {
+                    limit: 123,
+                    "check-regex": false,
+                },
+            ],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: [
+                        {
+                            code: 123,
+                            ignoreRegExpLiterals: true,
+                        },
+                    ],
+                    ruleName: "max-len",
+                },
+            ],
+        });
+    });
+});
diff --git a/src/rules/converters/tests/triple-equals.test.ts b/src/rules/converters/tests/triple-equals.test.ts
new file mode 100644
index 0000000..ad2940b
--- /dev/null
+++ b/src/rules/converters/tests/triple-equals.test.ts
@@ -0,0 +1,56 @@
+import { convertTripleEquals } from "../triple-equals";
+
+describe(convertTripleEquals, () => {
+    test("conversion without arguments", () => {
+        const result = convertTripleEquals({
+            ruleArguments: [],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: ["always"],
+                    ruleName: "eqeqeq",
+                    notices: [],
+                },
+            ],
+        });
+    });
+
+    test("conversion with an allow-null-check argument", () => {
+        const result = convertTripleEquals({
+            ruleArguments: ["allow-null-check"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: ["smart"],
+                    ruleName: "eqeqeq",
+                    notices: [
+                        'Option "smart" allows for comparing two literal values, evaluating the value of typeof and null comparisons.',
+                    ],
+                },
+            ],
+        });
+    });
+
+    test("conversion with an allow-undefined-check argument", () => {
+        const result = convertTripleEquals({
+            ruleArguments: ["allow-undefined-check"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: ["smart"],
+                    ruleName: "eqeqeq",
+                    notices: [
+                        'Option "allow-undefined-check" is not supported by ESLint. Option "smart" is the closest.',
+                        'Option "smart" allows for comparing two literal values, evaluating the value of typeof and null comparisons.',
+                    ],
+                },
+            ],
+        });
+    });
+});