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

TypeScript: eslint --fix command crash the code due to the prefer-object-spread rule #13058

Closed
kurone-kito opened this issue Mar 17, 2020 · 1 comment · Fixed by #13063
Closed
Labels
3rd party plugin This is an issue related to a 3rd party plugin, config, or parser archived due to age This issue has been archived; please open a new issue for any further discussion evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules

Comments

@kurone-kito
Copy link

Tell us about your environment

  • ESLint Version: v6.8.0
  • Node Version: v13.11.0
  • npm Version: v6.14.2

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

@typescript-eslint/parser

Please show your full configuration:

Configuration
env:
  browser: true
  es6: true
  node: true
extends:
  - eslint:recommended
  - airbnb-base
  - plugin:@typescript-eslint/recommended
  - plugin:@typescript-eslint/eslint-recommended
  - prettier
  - plugin:prettier/recommended
  - prettier/@typescript-eslint
globals:
  Atomics: readonly
  SharedArrayBuffer: readonly
parser: '@typescript-eslint/parser'
parserOptions:
  ecmaVersion: 2020
  sourceType: module
plugins:
  - '@typescript-eslint'
  - import
  - prettier
root: true
rules:
  '@typescript-eslint/explicit-function-return-type':
    - 'off' # Because type inference cannot be used :(

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

const getObject = () => ({ huge: ['sized'], dynamic: ['object'] });

const obj = Object.assign<{}, Record<string, string[]>>({}, getObject());
console.log(obj);
eslint --fix ./*.ts

What did you expect to happen?

I expected the fix to occur as below:

const getObject = () => ({ huge: ['sized'], dynamic: ['object'] });

const obj = { ...getObject() };
console.log(obj);

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

Actual output code:

const getObject = () => ({ huge: ['sized'], dynamic: ['object'] });

const obj = <{}, Record<string, string[]>>{ ...getObject()};
console.log(obj);

This repository can reproduce the above problem: kurone-kito/example-for-eslint-POS

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

Probably no, because I don't know the cause.

@kurone-kito kurone-kito added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Mar 17, 2020
@kaicataldo kaicataldo added 3rd party plugin This is an issue related to a 3rd party plugin, config, or parser evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Mar 17, 2020
@kaicataldo
Copy link
Member

Thanks for making this issue. I think it's definitely worth exploring if we can change the rule in a generic way to avoid crashing on this syntax, if possible.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 21, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd party plugin This is an issue related to a 3rd party plugin, config, or parser archived due to age This issue has been archived; please open a new issue for any further discussion evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants