|
2 | 2 |
|
3 | 3 | ## CLI Architecture |
4 | 4 |
|
5 | | -- CLI usage starts in `bin/tslint-to-eslint-config`, which immediately calls `src/cli/main.ts`. |
6 | | -- CLI settings are parsed and read in `src/cli/runCli.ts`. |
7 | | -- Application logic is run by `src/conversion/convertConfig.ts`. |
| 5 | +1. CLI usage starts in `bin/tslint-to-eslint-config`, which immediately calls `src/cli/main.ts`. |
| 6 | +2. CLI settings are parsed and read in `src/cli/runCli.ts`. |
| 7 | +3. Application logic is run by `src/conversion/convertConfig.ts`. |
8 | 8 |
|
9 | | -## Dependencies |
| 9 | +## Configuration Conversion |
10 | 10 |
|
11 | | -Methods are created using a variant of [Dependency Injection](http://en.wikipedia.org/wiki/Dependency_Injection). |
12 | | -Any method with dependencies that should be stubbed out during tests, such as file system bindings, logging, or other methods, |
13 | | -takes in a first argument of name `dependencies`. |
14 | | -Its dependencies object is manually created in `src/cli/main.ts` and bound to the method with `bind`. |
| 11 | +Within `src/conversion/convertConfig.ts`, the following steps occur: |
| 12 | + |
| 13 | +1. Existing configurations are read from disk |
| 14 | +2. TSLint rules are converted into their ESLint configurations |
| 15 | +3. ESLint configurations are simplified based on extended ESLint presets |
| 16 | +4. The simplified configuration is written to the output config file |
| 17 | +5. A summary of the results is printed to the user's console |
| 18 | + |
| 19 | +### Conversion Results |
| 20 | + |
| 21 | +The overall configuration generated by steps 2-3 and printed in 4-5 contains the following information: |
| 22 | + |
| 23 | +### Rule Converters |
| 24 | + |
| 25 | +Each TSLint rule should output at least one ESLint rule as the equivalent. |
| 26 | +"Converters" for TSLint rules are located in `src/rules/converters/`, and keyed under their names by the map in `src/rules/converters.ts`. |
| 27 | + |
| 28 | +Each converter for a TSLint rule takes an arguments object for the rule, and returns an array of objects containing: |
| 29 | + |
| 30 | +- `rules`: At least one equivalent ESLint rule and options |
| 31 | +- `notices`: Any extra info that should be printed after conversion |
| 32 | +- `plugins`: Any plugins that should now be installed if not already |
| 33 | + |
| 34 | +The `rules` output is an array of objects containing: |
| 35 | + |
| 36 | +- `ruleName`: Equivalent ESLint rule name that should be enabled |
| 37 | +- `ruleArguments`: Any arguments for that ESLint rule |
| 38 | + |
| 39 | +Multiple objects must be supported because some general-use TSLint rules can only be represented by two or more ESLint rules. |
| 40 | +For example, TSLint's `no-banned-terms` is represented by ESLint's `no-caller` and `no-eval`. |
| 41 | + |
| 42 | +### Rule Mergers |
| 43 | + |
| 44 | +It's possible that one ESLint rule will be output by multiple converters. |
| 45 | +"Mergers" for those ESLint rules should take in two configurations to the same rule and output the equivalent single configuration. |
| 46 | +These are located in `src/rules/mergers/`, and keyed under their names by the map in `src/rules/mergers.ts`. |
| 47 | + |
| 48 | +For example, `@typescript-eslint/ban-types` spreads both arguments' `types` members into one large `types` object. |
0 commit comments