Skip to content

Bug: no-shadow-restricted-names doesn't flag shadowing caused by imports #19271

@cakoose

Description

@cakoose

Environment

Node version: N/A (repro'd in playground)
npm version: N/A (repro'd in playground)
Local ESLint version: N/A (repro'd in playground)
Global ESLint version: N/A (repro'd in playground)
Operating System: Running playground in Chrome on MacOS

What parser are you using?

Default (Espree)

What did you do?

Configuration
export default [
    {
        "rules": {
            "no-shadow-restricted-names": [
                "error"
            ]
        },
        "languageOptions": {
            "ecmaVersion": "latest",
            "sourceType": "module"
        }
    }
];
import {undefined} from 'blah'; // Bad: No warning for this shadowing of 'undefined'

function f(x, undefined) { // Good: I get a warning for this shadowing of 'undefined'
  if (x === undefined) return 1;
}

What did you expect to happen?

I expect a warning on the import line.

What actually happened?

No warning for the import line.

Link to Minimal Reproducible Example

https://eslint.org/play/#eyJ0ZXh0IjoiaW1wb3J0IHt1bmRlZmluZWR9IGZyb20gJ2JsYWgnOyAvLyBCYWQ6IE5vIHdhcm5pbmcgZm9yIHRoaXMgc2hhZG93aW5nIG9mICd1bmRlZmluZWQnXG5cbmZ1bmN0aW9uIGYoeCwgdW5kZWZpbmVkKSB7IC8vIEdvb2Q6IEkgZ2V0IGEgd2FybmluZyBmb3IgdGhpcyBzaGFkb3dpbmcgb2YgJ3VuZGVmaW5lZCdcbiAgaWYgKHggPT09IHVuZGVmaW5lZCkgcmV0dXJuIDE7XG59XG4iLCJvcHRpb25zIjp7InJ1bGVzIjp7Im5vLXNoYWRvdy1yZXN0cmljdGVkLW5hbWVzIjpbImVycm9yIl19LCJsYW5ndWFnZU9wdGlvbnMiOnsiZWNtYVZlcnNpb24iOiJsYXRlc3QiLCJzb3VyY2VUeXBlIjoibW9kdWxlIiwicGFyc2VyT3B0aW9ucyI6eyJlY21hRmVhdHVyZXMiOnt9fX19fQ==

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionbugESLint is working incorrectlyrepro:yesIssues with a reproducible exampleruleRelates to ESLint's core rules

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions