Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Bug: false positive: "no-unnecessary-qualifier" #4387

Closed
benny-medflyt opened this issue Dec 16, 2018 · 1 comment
Closed

Bug: false positive: "no-unnecessary-qualifier" #4387

benny-medflyt opened this issue Dec 16, 2018 · 1 comment

Comments

@benny-medflyt
Copy link

Bug Report

  • TSLint version: 5.11.0
  • TypeScript version: 3.2.2

TypeScript code being linted

export namespace OuterNamespace {
    export const Foo = "Foo";

    export namespace InnerNamespace {
        export function Foo(): any {
            return {
                type: OuterNamespace.Foo
            };
        }
    }
}

console.log(OuterNamespace.InnerNamespace.Foo());

with tslint.json configuration:

{
    "extends": ["tslint:latest"],
    "rules": {
        "no-namespace": false,
        "no-shadowed-variable": false,
        "no-console": false,
        "no-unnecessary-qualifier": true
    }
}

Actual behavior

Qualifier is unnecessary since 'OuterNamespace' is in scope. (no-unnecessary-qualifier)
   5 |         export function Foo(): any {
   6 |             return {
>  7 |                 type: OuterNamespace.Foo,
     |                      ^
   8 |             };
   9 |         }
  10 |     }

Expected behavior

This should produce no tslint errors. Note that if we remove the qualifier OuterNamespace then the output of the program will change, from:

{ type: 'Foo' }

to:

{ type: [Function: Foo] }
@JoshuaKGoldberg
Copy link
Contributor

Duplicate of #2413.

It might also be fixed by the soon-to-be-released 5.12.0 (🎉!); if not, likely still a duplicate.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants