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

Issue:
Missing converter: only-arrow-functions
### 💥 Missing Converter

-   `tslint-to-eslint-config` version: 1.2.0
-   `typescript-eslint` version: 2.3.2

#### TSLint Rule Name

`only-arrow-functions`


Pull request description:
added only-arrow-functions converter and unit tests
<!--
👋 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 #179
-   [x] That issue was marked as [`status: accepting prs`](https://github.com/typescript-eslint/tslint-to-eslint-config/labels/status%3A%20accepting%20prs)

## Overview
Added the converter and the unit tests for the only-arrow-functions TSLint rule.

<!-- Brief description of what is changed and how the code change does that. -->


Patch:
diff --git a/src/rules/converters.ts b/src/rules/converters.ts
index f98b219..96a0365 100644
--- a/src/rules/converters.ts
+++ b/src/rules/converters.ts
@@ -45,6 +45,7 @@ import { convertNoEmptyInterface } from "./converters/no-empty-interface";
 import { convertNoEval } from "./converters/no-eval";
 import { convertNoExplicitAny } from "./converters/no-explicit-any";
 import { convertNoFloatingPromises } from "./converters/no-floating-promises";
+import { convertNoForIn } from "./converters/no-for-in";
 import { convertNoForInArray } from "./converters/no-for-in-array";
 import { convertNoInferrableTypes } from "./converters/no-inferrable-types";
 import { convertNoInternalModule } from "./converters/no-internal-module";
@@ -70,6 +71,7 @@ import { convertNoStringLiteral } from "./converters/no-string-literal";
 import { convertNoStringThrow } from "./converters/no-string-throw";
 import { convertNoSwitchCaseFallThrough } from "./converters/no-switch-case-fall-through";
 import { convertNoThisAssignment } from "./converters/no-this-assignment";
+import { convertNoTrailingWhitespace } from "./converters/no-trailing-whitespace";
 import { convertNoUnboundMethod } from "./converters/no-unbound-method";
 import { convertNoUnnecessaryClass } from "./converters/no-unnecessary-class";
 import { convertNoUnnecessaryInitializer } from "./converters/no-unnecessary-initializer";
@@ -80,9 +82,11 @@ import { convertNoUnsafeFinally } from "./converters/no-unsafe-finally";
 import { convertNoUseBeforeDeclare } from "./converters/no-use-before-declare";
 import { convertNoVarKeyword } from "./converters/no-var-keyword";
 import { convertNoVarRequires } from "./converters/no-var-requires";
+import { convertNoVoidExpression } from "./converters/no-void-expression";
 import { convertObjectLiteralKeyQuotes } from "./converters/object-literal-key-quotes";
 import { convertObjectLiteralShorthand } from "./converters/object-literal-shorthand";
 import { convertOneVariablePerDeclaration } from "./converters/one-variable-per-declaration";
+import { convertOnlyArrowFunctions } from "./converters/only-arrow-functions";
 import { convertPreferConst } from "./converters/prefer-const";
 import { convertPreferForOf } from "./converters/prefer-for-of";
 import { convertPreferFunctionOverMethod } from "./converters/prefer-function-over-method";
@@ -141,6 +145,7 @@ export const converters = new Map([
     ["no-empty-interface", convertNoEmptyInterface],
     ["no-eval", convertNoEval],
     ["no-floating-promises", convertNoFloatingPromises],
+    ["no-for-in", convertNoForIn],
     ["no-for-in-array", convertNoForInArray],
     ["no-inferrable-types", convertNoInferrableTypes],
     ["no-internal-module", convertNoInternalModule],
@@ -158,6 +163,7 @@ export const converters = new Map([
     ["no-string-literal", convertNoStringLiteral],
     ["no-string-throw", convertNoStringThrow],
     ["no-switch-case-fall-through", convertNoSwitchCaseFallThrough],
+    ["no-trailing-whitespace", convertNoTrailingWhitespace],
     ["no-this-assignment", convertNoThisAssignment],
     ["no-unbound-method", convertNoUnboundMethod],
     ["no-unnecessary-class", convertNoUnnecessaryClass],
@@ -168,6 +174,7 @@ export const converters = new Map([
     ["no-use-before-declare", convertNoUseBeforeDeclare],
     ["no-var-keyword", convertNoVarKeyword],
     ["no-var-requires", convertNoVarRequires],
+    ["no-void-expression", convertNoVoidExpression],
     ["prefer-for-of", convertPreferForOf],
     ["prefer-object-spread", convertPreferObjectSpread],
     ["promise-function-async", convertPromiseFunctionAsync],
@@ -197,6 +204,7 @@ export const converters = new Map([
     ["object-literal-key-quotes", convertObjectLiteralKeyQuotes],
     ["object-literal-shorthand", convertObjectLiteralShorthand],
     ["one-variable-per-declaration", convertOneVariablePerDeclaration],
+    ["only-arrow-functions", convertOnlyArrowFunctions],
     ["prefer-const", convertPreferConst],
     ["prefer-function-over-method", convertPreferFunctionOverMethod],
     ["prefer-readonly", convertPreferReadonly],
@@ -234,7 +242,6 @@ export const converters = new Map([
     // tslint-microsoft-contrib rules:
     // ["max-func-body-length", convertMaxFuncBodyLength],
     // ["no-empty-line-after-opening-brace", convertNoEmptyLineAfterOpeningBrace], // padded-blocks
-    // ["no-for-in", convertNoForIn], // no-restricted-syntax config
     // ["no-function-expression", convertNoFunctionExpression], // ban-syntax config
     // ["no-suspicious-comment", convertNoSuspiciousComment],
     // ["no-with-statement", convertNoWithStatement],
diff --git a/src/rules/converters/no-for-in.ts b/src/rules/converters/no-for-in.ts
new file mode 100644
index 0000000..ed32259
--- /dev/null
+++ b/src/rules/converters/no-for-in.ts
@@ -0,0 +1,12 @@
+import { RuleConverter } from "../converter";
+
+export const convertNoForIn: RuleConverter = () => {
+    return {
+        rules: [
+            {
+                ruleArguments: ["ForInStatement"],
+                ruleName: "no-restricted-syntax",
+            },
+        ],
+    };
+};
diff --git a/src/rules/converters/no-trailing-whitespace.ts b/src/rules/converters/no-trailing-whitespace.ts
new file mode 100644
index 0000000..ddf7b07
--- /dev/null
+++ b/src/rules/converters/no-trailing-whitespace.ts
@@ -0,0 +1,32 @@
+import { RuleConverter } from "../converter";
+
+export const convertNoTrailingWhitespace: RuleConverter = tslintRule => {
+    const ruleArguments: { [eslintOption in "ignoreComments" | "skipBlankLines"]?: true }[] = [];
+    const notices: string[] = [];
+
+    if (tslintRule.ruleArguments.includes("ignore-comments")) {
+        ruleArguments.push({ ignoreComments: true });
+    }
+
+    if (tslintRule.ruleArguments.includes("ignore-blank-lines")) {
+        ruleArguments.push({ skipBlankLines: true });
+    }
+
+    if (tslintRule.ruleArguments.includes("ignore-template-strings")) {
+        notices.push("ESLint does not support ignoring template strings.");
+    }
+
+    if (tslintRule.ruleArguments.includes("ignore-jsdoc")) {
+        notices.push("ESLint does not support ignoring JSDoc.");
+    }
+
+    return {
+        rules: [
+            {
+                ...(notices.length > 0 && { notices }),
+                ...(ruleArguments.length > 0 && { ruleArguments }),
+                ruleName: "no-trailing-spaces",
+            },
+        ],
+    };
+};
diff --git a/src/rules/converters/no-void-expression.ts b/src/rules/converters/no-void-expression.ts
new file mode 100644
index 0000000..55a1467
--- /dev/null
+++ b/src/rules/converters/no-void-expression.ts
@@ -0,0 +1,15 @@
+import { RuleConverter } from "../converter";
+
+export const convertNoVoidExpression: RuleConverter = tslintRule => {
+    return {
+        rules: [
+            {
+                ...(tslintRule.ruleArguments.length > 0 &&
+                    tslintRule.ruleArguments.includes("ignore-arrow-function-shorthand") && {
+                        notices: ["ESLint does not support ignoring arrow function shorthand."],
+                    }),
+                ruleName: "no-void",
+            },
+        ],
+    };
+};
diff --git a/src/rules/converters/only-arrow-functions.ts b/src/rules/converters/only-arrow-functions.ts
new file mode 100644
index 0000000..17fa60a
--- /dev/null
+++ b/src/rules/converters/only-arrow-functions.ts
@@ -0,0 +1,25 @@
+import { RuleConverter } from "../converter";
+
+export const convertOnlyArrowFunctions: RuleConverter = tslintRule => {
+    const notices: string[] = [];
+
+    if (tslintRule.ruleArguments.includes("allow-declarations")) {
+        notices.push("ESLint does not support allowing standalone function declarations.");
+    }
+
+    if (tslintRule.ruleArguments.includes("allow-named-functions")) {
+        notices.push(
+            "ESLint does not support allowing named functions defined with the function keyword.",
+        );
+    }
+
+    return {
+        rules: [
+            {
+                ...(notices.length > 0 && { notices }),
+                ruleName: "prefer-arrow/prefer-arrow-functions",
+            },
+        ],
+        plugins: ["prefer-arrow"],
+    };
+};


Test patch:
diff --git a/src/rules/converters/tests/no-for-in.test.ts b/src/rules/converters/tests/no-for-in.test.ts
new file mode 100644
index 0000000..af31320
--- /dev/null
+++ b/src/rules/converters/tests/no-for-in.test.ts
@@ -0,0 +1,18 @@
+import { convertNoForIn } from "../no-for-in";
+
+describe(convertNoForIn, () => {
+    test("conversion without arguments", () => {
+        const result = convertNoForIn({
+            ruleArguments: [],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleName: "no-restricted-syntax",
+                    ruleArguments: ["ForInStatement"],
+                },
+            ],
+        });
+    });
+});
diff --git a/src/rules/converters/tests/no-trailing-whitespace.test.ts b/src/rules/converters/tests/no-trailing-whitespace.test.ts
new file mode 100644
index 0000000..4743a28
--- /dev/null
+++ b/src/rules/converters/tests/no-trailing-whitespace.test.ts
@@ -0,0 +1,101 @@
+import { convertNoTrailingWhitespace } from "../no-trailing-whitespace";
+
+describe(convertNoTrailingWhitespace, () => {
+    test("conversion without arguments", () => {
+        const result = convertNoTrailingWhitespace({
+            ruleArguments: [],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleName: "no-trailing-spaces",
+                },
+            ],
+        });
+    });
+
+    test("conversion with ignore-template-strings argument", () => {
+        const result = convertNoTrailingWhitespace({
+            ruleArguments: ["ignore-template-strings"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    notices: ["ESLint does not support ignoring template strings."],
+                    ruleName: "no-trailing-spaces",
+                },
+            ],
+        });
+    });
+
+    test("conversion with ignore-comments argument", () => {
+        const result = convertNoTrailingWhitespace({
+            ruleArguments: ["ignore-comments"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: [{ ignoreComments: true }],
+                    ruleName: "no-trailing-spaces",
+                },
+            ],
+        });
+    });
+
+    test("conversion with ignore-jsdoc argument", () => {
+        const result = convertNoTrailingWhitespace({
+            ruleArguments: ["ignore-jsdoc"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    notices: ["ESLint does not support ignoring JSDoc."],
+                    ruleName: "no-trailing-spaces",
+                },
+            ],
+        });
+    });
+
+    test("conversion with ignore-blank-lines argument", () => {
+        const result = convertNoTrailingWhitespace({
+            ruleArguments: ["ignore-blank-lines"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleArguments: [{ skipBlankLines: true }],
+                    ruleName: "no-trailing-spaces",
+                },
+            ],
+        });
+    });
+
+    test("conversion with all arguments", () => {
+        const result = convertNoTrailingWhitespace({
+            ruleArguments: [
+                "ignore-template-strings",
+                "ignore-comments",
+                "ignore-jsdoc",
+                "ignore-blank-lines",
+            ],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    notices: [
+                        "ESLint does not support ignoring template strings.",
+                        "ESLint does not support ignoring JSDoc.",
+                    ],
+                    ruleArguments: [{ ignoreComments: true }, { skipBlankLines: true }],
+                    ruleName: "no-trailing-spaces",
+                },
+            ],
+        });
+    });
+});
diff --git a/src/rules/converters/tests/no-void-expression.test.ts b/src/rules/converters/tests/no-void-expression.test.ts
new file mode 100644
index 0000000..84a03ad
--- /dev/null
+++ b/src/rules/converters/tests/no-void-expression.test.ts
@@ -0,0 +1,32 @@
+import { convertNoVoidExpression } from "../no-void-expression";
+
+describe(convertNoVoidExpression, () => {
+    test("conversion without arguments", () => {
+        const result = convertNoVoidExpression({
+            ruleArguments: [],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleName: "no-void",
+                },
+            ],
+        });
+    });
+
+    test("conversion with ignore-arrow-function-shorthand argument", () => {
+        const result = convertNoVoidExpression({
+            ruleArguments: ["ignore-arrow-function-shorthand"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    notices: ["ESLint does not support ignoring arrow function shorthand."],
+                    ruleName: "no-void",
+                },
+            ],
+        });
+    });
+});
diff --git a/src/rules/converters/tests/only-arrow-functions.test.ts b/src/rules/converters/tests/only-arrow-functions.test.ts
new file mode 100644
index 0000000..decbb63
--- /dev/null
+++ b/src/rules/converters/tests/only-arrow-functions.test.ts
@@ -0,0 +1,71 @@
+import { convertOnlyArrowFunctions } from "../only-arrow-functions";
+
+describe(convertOnlyArrowFunctions, () => {
+    test("conversion without arguments", () => {
+        const result = convertOnlyArrowFunctions({
+            ruleArguments: [],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    ruleName: "prefer-arrow/prefer-arrow-functions",
+                },
+            ],
+            plugins: ["prefer-arrow"],
+        });
+    });
+
+    test("conversion with allow-declarations argument", () => {
+        const result = convertOnlyArrowFunctions({
+            ruleArguments: ["allow-declarations"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    notices: ["ESLint does not support allowing standalone function declarations."],
+                    ruleName: "prefer-arrow/prefer-arrow-functions",
+                },
+            ],
+            plugins: ["prefer-arrow"],
+        });
+    });
+
+    test("conversion with allow-named-functions argument", () => {
+        const result = convertOnlyArrowFunctions({
+            ruleArguments: ["allow-named-functions"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    notices: [
+                        "ESLint does not support allowing named functions defined with the function keyword.",
+                    ],
+                    ruleName: "prefer-arrow/prefer-arrow-functions",
+                },
+            ],
+            plugins: ["prefer-arrow"],
+        });
+    });
+
+    test("conversion with all arguments", () => {
+        const result = convertOnlyArrowFunctions({
+            ruleArguments: ["allow-declarations", "allow-named-functions"],
+        });
+
+        expect(result).toEqual({
+            rules: [
+                {
+                    notices: [
+                        "ESLint does not support allowing standalone function declarations.",
+                        "ESLint does not support allowing named functions defined with the function keyword.",
+                    ],
+                    ruleName: "prefer-arrow/prefer-arrow-functions",
+                },
+            ],
+            plugins: ["prefer-arrow"],
+        });
+    });
+});