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

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

Comments

@lpaladin
Copy link
Contributor

@lpaladin lpaladin 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.

@lpaladin lpaladin 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
lpaladin pushed a commit to lpaladin/eslint that referenced this issue Jan 4, 2019
lpaladin pushed a commit to lpaladin/eslint that referenced this issue Jan 4, 2019
@not-an-aardvark
Copy link
Member

@not-an-aardvark 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
Copy link
Member

@platinumazure 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!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.