Skip to content

ReferenceTracker returns potential referencesΒ #12826

Open
@mdjermanovic

Description

Tell us about your environment

  • ESLint Version: 7.0.0-alpha.0
  • Node Version: v12.14.0
  • npm Version: v6.13.4

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
module.exports = {
    parserOptions: {
        ecmaVersion: 2020
    },
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Online Demo Link

/*eslint prefer-object-spread: "error" */

var doSomething;

if (foo) {
    doSomething = Object.assign;
} else {
    doSomething = somethingElse;
}

var bar = doSomething({}, a, b);
eslint index.js --fix

What did you expect to happen?

I guess this shouldn't be reported and auto-fixed.

What actually happened? Please include the actual, raw output from ESLint.

Auto-fixed to:

/*eslint prefer-object-spread: "error" */

var doSomething;

if (foo) {
    doSomething = Object.assign;
} else {
    doSomething = somethingElse;
}

var bar = { ...a, ...b};

Are you willing to submit a pull request to fix this bug?

Yes, though this would need some design first.

The problem is: eslint-utils.ReferenceTracker returns references that may be the targeted global in some code paths, but may be something else in other code paths. This feature might be not suitable for some rules.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionbugESLint is working incorrectlyneeds designImportant details about this change need to be discussedruleRelates to ESLint's core rules

Type

No type

Projects

  • Status

    Implementing

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions