eslint: `prefer-const` not triggered (regression from 2.4.0)

What version of ESLint are you using? 2.7.0

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

“babel-eslint”: “~6.0.0”

Please show your full configuration:

{
  "parser": "babel-eslint",
  "extends": "airbnb",
  "rules": {
      "semi": [2, "never"],
      "arrow-body-style": 0
  }
}

What did you do? Please include the actual source code causing the issue.

import React, { PropTypes } from 'react'

const innerStyle = {
  color: '#343434',
  color2: 'white',
}

const ToolBar = ({ style, draw }) => {
  let dynStyle = {
    ...innerStyle,
    ...style,
  }

  dynStyle.color = draw ? dynStyle.color2 : dynStyle.color

  return (
    <div style={dynStyle} />
  )
}

ToolBar.propTypes = {
  style: PropTypes.object,
  draw: PropTypes.bool,
}

export default ToolBar

What did you expect to happen? prefer-const should trigger and ask me to change let dynStyle to const dynStyle

What actually happened? Please include the actual, raw output from ESLint. ESLint don’t trigger the prefer-const rule.


Note I tried these versions :

  • ~2.4.0 : Works
  • ~2.5.0 : Doesn’t work
  • ~2.6.0 : Doesn’t work
  • ~2.7.0 : Doesn’t work

Commits that are related to prefer-const (maybe I miss some) :

  • 2.6: 9b73ffd Update: destructuring option of prefer-const rule (fixes #5594) (Toru Nagashima)
  • 2.5: 9a22625 Fix: prefer-const false positive at non-blocked if (fixes #5610) (Toru Nagashima)
  • 2.5: 87d74b2 Fix: prefer-const got to not change scopes (refs #5284) (Toru Nagashima)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Oh, I’m sorry. I had lost the track of this issue.

I will fix this.