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

Assignment to ternary expression using function parameter as condition triggers no-param-reassign #11236

Closed
zhouhaoyu opened this Issue Jan 4, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@zhouhaoyu
Copy link
Contributor

zhouhaoyu commented Jan 4, 2019

Tell us about your environment

  • ESLint Version: 5.9.0
  • Node Version: 8.12.0
  • npm Version: 6.4.1

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

Please show your full configuration:

Configuration
{
    "parser": "babel-eslint",
    "extends": "airbnb",
    "env": {
        "browser": true
    },
    "rules": {
        "jsx-a11y/click-events-have-key-events": "off",
        "jsx-a11y/no-static-element-interactions": "off",
        "react/jsx-one-expression-per-line": [true, { "allow": "literal" }],
        "no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"]
    }
}

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

function test(arg) {
  const array = [[1], [2]];
  (arg ? array[0] : array[1])[0] = 3;
  return array;
}
yarn eslint src/

What did you expect to happen?
The above code should not emit lint errors.

What actually happened? Please include the actual, raw output from ESLint.
error Assignment to property of function parameter 'arg' no-param-reassign

Are you willing to submit a pull request to fix this bug?
Will try if possible.

@zhouhaoyu zhouhaoyu changed the title Assignment to ternary expression using function parameter triggers no-param-reassign Assignment to ternary expression using function parameter as condition triggers no-param-reassign Jan 4, 2019

zhouhaoyu added a commit to zhouhaoyu/eslint that referenced this issue Jan 4, 2019

zhouhaoyu added a commit to zhouhaoyu/eslint that referenced this issue Jan 4, 2019

@not-an-aardvark not-an-aardvark added rule accepted and removed triage labels Jan 4, 2019

@not-an-aardvark

This comment has been minimized.

Copy link
Member

not-an-aardvark commented Jan 4, 2019

Thanks for the report, I can reproduce this issue. It seems to only occur when using the props: true option.

@platinumazure

This comment has been minimized.

Copy link
Member

platinumazure commented Jan 4, 2019

Hi @zhouhaoyu, thanks for the issue!

I can reproduce in the demo, so I'm marking this as accepted. Thanks also for the PR-- I'll review that shortly!

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