question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:20 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
mysticateacommented, Aug 24, 2016

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

I will fix this.

0reactions
mysticateacommented, Aug 24, 2016

Thank you for explaining. I understood it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prefer-const - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Release Notes — Airflow Documentation
In order to make airflow dags test more useful as a testing and debugging tool, we no longer run a backfill job and...
Read more >
Zephyr 2.4.0 — Zephyr Project Documentation - nRF51 SDK
Enabled the new TCP stack, TCP2, by default. This stack was introduced in Zephyr v2.1.0 to improve network protocol testability with open source ......
Read more >
4. Release Notes — Buildbot 2.4.0 documentation
UI now shows a paginated view for trigger step sub builds. 4.1.5. Deprecations and Removals¶. Support for older browsers that were not working...
Read more >
Apache 2.4 Change Log
Credits: The Apache HTTP Server project would like to thank Gaetan Ferry ... While working on some servers, EAB handling is not uniform...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found