Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer-object-spread: autofixer may produce invalid code #248

Closed
ajafff opened this issue May 13, 2018 · 1 comment
Closed

prefer-object-spread: autofixer may produce invalid code #248

ajafff opened this issue May 13, 2018 · 1 comment
Labels

Comments

@ajafff
Copy link
Member

ajafff commented May 13, 2018

Related: #186

obj = Object.assign({prop: 1}, {prop: 2});

// fixed to
obj = {prop: 1, prop: 2}; // duplicate key 'prop'

Produces duplicate key error. Found this in the test cases of the rule...

Possible fixes:

  • try really hard to work around the error
    • not fixing such cases
    • removing all overridden occurrences of the duplicate property
      • may introduce even more changes if the initializer has side effects
  • fix to object spread and let no-useless-object-spread do it's job (which is currently not autofixing)
  • don't fix at all
  • make this fix a "suggested / unsafe fix" (introduce suggested fixes for potentially unsafe or undesired fixes #207)
@ajafff
Copy link
Member Author

ajafff commented Oct 17, 2018

Closing as "won't fix" for the reasons outlined in #249 (comment)

@ajafff ajafff closed this as completed Oct 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant