Skip to content

[type-declaration-immutability] add support for union types when they are interfaces #529

@m4thieulavoie

Description

@m4thieulavoie

Bug Report

eslint config:

'functional/type-declaration-immutability': [
          'error',
          {
            rules: [
              {
                identifiers: '^(?!I?Mutable).+',
                immutability: 'ReadonlyShallow',
                comparator: 'AtLeast',
                fixer: false,
              },
            ],
            ignoreInterfaces: true,
          },
        ],

Given the above config, I'm basically wanting anything to be at least ReadonlyShallow except for interfaces, which works great. However, given this example

interface A {
  prop: string;
}

interface B {
  prop2: string;
}

type UnionedType = A | B;

I'm getting the following error

This type is declare to have an immutability of at least "ReadonlyShallow" (actual: "Mutable")

I don't think that my config is off. It seems to me like this is more of a cornercase for this new rule.

Expected behavior

Union type of > 1 interfaces doesn't error out if ignoreInterfaces is true

Actual behavior

Union type of > 1 interfaces errors out if ignoreInterfaces is true

Steps to reproduce

Add above config and use above example

Proposed changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: Won't FixA real bug or issue, but the issue is not impactful enough to spend time on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions