Skip to content

Rule proposal: disallow duplicate union and intersection types #2738

@remcohaszing

Description

@remcohaszing

I would like to propose a new rule: no-duplicate-union-intersection.

This rule reports duplicates in unions and intersections. The autofixer will remove all duplicates, keeping the first one.

The following lines will be reported:

type A = 1 | 2 | 3 | 1;
type B = 'foo' | 'bar' | 'foo';
type C = A | B | A | B;

This will be autofixed to:

type A = 1 | 2 | 3;
type B = 'foo' | 'bar';
type C = A | B;

The rule won’t try to resolve references. This may be an addition for later.

If this is accepted, I’m willing to implement this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy