Skip to content

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

Closed
@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

      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