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

Issue:
TSLint rule arguments are not picked up
<!--
👋 Hi, thanks for filing an issue on tslint-to-eslint-config! 💖
Please fill out all fields below to ensure your issue is addressed.

If your issue doesn't provide enough info to fully explain or reproduce your bug, it will be closed. 😦
-->

### 🐛 Bug Report

-   `tslint-to-eslint-config` version: 0.2.10
-   ESLint version: 6.5.1
-   Node version: 12.10.0

#### Actual Behavior

<!-- What is the behavior right now? -->
The generated `.eslintrc.js` is missing some rule arguments. I believe it is due to the input TSLint rule arguments being ignored.

Actual output:
```
    "rules": {
        "@typescript-eslint/indent": "error"
    }
```

#### Expected Behavior

Expected output:
```
    "rules": {
        "@typescript-eslint/indent": [
            "error",
            2,
            {
                "FunctionDeclaration": {
                    "parameters": "first"
                },
                "FunctionExpression": {
                    "parameters": "first"
                }
            }
        ]
    }
```

#### Reproduction

<!--
Please paste a link to a repository, Gist, or other means of reproducing your error here.
Note that `tslint-to-eslint-config` includes information from `package.json`, `tsconfig.json`, and other files, so just your ESLint configuration may not be enough.
-->
Sample TSLint config:
```json
{
  "rules": {
    "align": [ true, "parameters", "statements" ],
    "indent": [ true, "spaces", 2 ]
  }
}
```


Pull request:
Again allowed rules from extended rulesets (via reported configs) to be factored in
## PR Checklist

-   [x] Addresses an existing issue: fixes #261
-   [x] That issue was marked as [`status: accepting prs`](https://github.com/typescript-eslint/tslint-to-eslint-config/labels/status%3A%20accepting%20prs)

## Overview

Rules from reported configurations (`tslint --print-config`) weren't being added to the `full` output of `findTSLintConfigurationDependencies`. This adds them back in.

Patch:
diff --git a/src/creation/formatMissingRules.ts b/src/creation/formatMissingRules.ts
index 4497abd..aab1c49 100644
--- a/src/creation/formatMissingRules.ts
+++ b/src/creation/formatMissingRules.ts
@@ -1,7 +1,7 @@
 import { TSLintRuleOptions } from "../rules/types";
 
-export const formatMissingRules = (missing: TSLintRuleOptions[], rulesDirectory: string[]) => {
-    const rules: { [i: string]: unknown } = {};
+export const formatMissingRules = (missing: TSLintRuleOptions[], rulesDirectory: string[] = []) => {
+    const rules: Record<string, unknown> = {};
 
     for (const rule of missing.sort((a, b) => a.ruleName.localeCompare(b.ruleName))) {
         if (rule.ruleSeverity !== "off") {
diff --git a/src/input/findRawConfiguration.ts b/src/input/findRawConfiguration.ts
index 4faf5f4..fd21751 100644
--- a/src/input/findRawConfiguration.ts
+++ b/src/input/findRawConfiguration.ts
@@ -4,7 +4,7 @@ import { importer } from "./importer";
 export const findRawConfiguration = async <Configuration>(
     fileImporter: SansDependencies<typeof importer>,
     filePath: string,
-    defaults: Partial<Configuration>,
+    defaults: Partial<Configuration> = {},
 ): Promise<Configuration | Error> => {
     let results: Configuration;
 
diff --git a/src/input/findTSLintConfiguration.ts b/src/input/findTSLintConfiguration.ts
index d14bfdc..1fe4324 100644
--- a/src/input/findTSLintConfiguration.ts
+++ b/src/input/findTSLintConfiguration.ts
@@ -1,24 +1,18 @@
 import { findRawConfiguration } from "./findRawConfiguration";
 import { findReportedConfiguration } from "./findReportedConfiguration";
 import { Exec } from "../adapters/exec";
-import { OriginalConfigurations } from "./findOriginalConfigurations";
 import { SansDependencies } from "../binding";
 import { importer } from "./importer";
+import { isDefined } from "../utils";
 
 export type TSLintConfiguration = {
     extends?: string[];
-    rulesDirectory: string[];
+    rulesDirectory?: string[];
     rules: TSLintConfigurationRules;
 };
 
 export type TSLintConfigurationRules = Record<string, any>;
 
-const defaultTSLintConfiguration = {
-    extends: [],
-    rulesDirectory: [],
-    rules: {},
-};
-
 export type FindTSLintConfigurationDependencies = {
     exec: Exec;
     importer: SansDependencies<typeof importer>;
@@ -27,12 +21,10 @@ export type FindTSLintConfigurationDependencies = {
 export const findTSLintConfiguration = async (
     dependencies: FindTSLintConfigurationDependencies,
     config: string | undefined,
-): Promise<OriginalConfigurations<TSLintConfiguration> | Error> => {
+) => {
     const filePath = config || "./tslint.json";
     const [rawConfiguration, reportedConfiguration] = await Promise.all([
-        findRawConfiguration<Partial<TSLintConfiguration>>(dependencies.importer, filePath, {
-            extends: [],
-        }),
+        findRawConfiguration<Partial<TSLintConfiguration>>(dependencies.importer, filePath),
         findReportedConfiguration<TSLintConfiguration>(
             dependencies.exec,
             "tslint --print-config",
@@ -52,15 +44,23 @@ export const findTSLintConfiguration = async (
         return rawConfiguration;
     }
 
+    const extensions = Array.from(
+        new Set(
+            [[rawConfiguration.extends], [reportedConfiguration.extends]]
+                .flat(Infinity)
+                .filter(isDefined),
+        ),
+    );
+
+    const rules = {
+        ...rawConfiguration.rules,
+        ...reportedConfiguration.rules,
+    };
+
     return {
         full: {
-            ...defaultTSLintConfiguration,
-            ...rawConfiguration,
-            extends: Array.from(
-                new Set(
-                    [[rawConfiguration.extends], [reportedConfiguration.extends]].flat(Infinity),
-                ),
-            ),
+            ...(extensions.length !== 0 && { extends: extensions }),
+            rules,
         },
         raw: rawConfiguration,
     };


Test patch:
diff --git a/src/creation/formatMissingRules.test.ts b/src/creation/formatMissingRules.test.ts
index 21913b2..cef22e7 100644
--- a/src/creation/formatMissingRules.test.ts
+++ b/src/creation/formatMissingRules.test.ts
@@ -13,7 +13,7 @@ describe("formatMissingRules", () => {
         ];
 
         // Act
-        const output = formatMissingRules(missing, []);
+        const output = formatMissingRules(missing);
 
         // Assert
         expect(output).toEqual([
diff --git a/src/input/findTslintConfiguration.test.ts b/src/input/findTslintConfiguration.test.ts
index 557c711..3b16615 100644
--- a/src/input/findTslintConfiguration.test.ts
+++ b/src/input/findTslintConfiguration.test.ts
@@ -119,10 +119,44 @@ describe("findTSLintConfiguration", () => {
         expect(result).toEqual({
             full: {
                 extends: ["raw", "duplicated", "reported"],
-                rulesDirectory: [],
                 rules: {},
             },
             raw,
         });
     });
+
+    it("adds reported configuration rules on top of raw rules", async () => {
+        // Arrange
+        const raw = {
+            rules: {
+                "raw-rule": true,
+            },
+        };
+        const reported = {
+            rules: {
+                "reported-rule": true,
+            },
+        };
+        const dependencies = createStubDependencies({
+            exec: createStubExec({
+                stdout: JSON.stringify(reported),
+            }),
+            importer: async () => raw,
+        });
+        const config = "./custom/tslint.json";
+
+        // Act
+        const result = await findTSLintConfiguration(dependencies, config);
+
+        // Assert
+        expect(result).toEqual({
+            full: {
+                rules: {
+                    ...raw.rules,
+                    ...reported.rules,
+                },
+            },
+            raw,
+        });
+    });
 });