Open
Description
opened on Jan 25, 2020
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.
/*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.
Metadata
Assignees
Labels
Type
Projects
Status
Implementing
Activity