Skip to content

Support custom ESLint rule config merging logic #8

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Suppose two TSLint rules end up generating output ESLint ban rule instances. Right now, the second rule will clobber over the first. How unfortunate!

In addition to src/rules/converters, there should be a src/rules/mergers that contains custom mergers for ESLint rule configs. They should take in any number configurations for a particular ESLint rule and output a single configuration. ban's merger, for example, would create a new ban config that bans all the things banned by the input configurations.

I'm thinking convertRules.ts would have to also receive a mergers: Map<string, RuleMerger>. Whenever the converted map receives a second output rule changes, it should use a merger to merge them. If a merger doesn't exist, there should be a ConversionError mentioning the failure.

Another strategy would be to store converted as a Map<string, ESLintRuleOptions[]> in convertRules.ts. At the end, all converted results would have to be looped over to check for arrays of length >=2.... seems less elegant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions