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.

arrow-body-style autofix with 'in' in a for-loop init

See original GitHub issue

Tell us about your environment

  • ESLint Version: 5.16.0 (same behaviour with 6.0.0-rc.0)
  • Node Version: 10.16.0
  • npm Version: 6.9.0

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

default

Please show your full configuration:

Configuration
module.exports = {
  parserOptions: {
    ecmaVersion: 6,
  },
  rules: {
    "arrow-body-style": "error",
  }
};

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

for (let a = b => { return b in c; }; ;);
eslint index.js --fix

What did you expect to happen?

Not a SyntaxError in the fixed code.

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

for (let a = b => b in c; ;);

The fix changed semantics and produced an error:

SyntaxError: for-in loop variable declaration may not have an initializer.

This is similar to #11706

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

Yes, when PR #11848 is finished, since it might be a similar fix.

Note

The fixed code is SyntaxError in Node/Chrome and Firefox (with a bit different message).

However, it’s a valid ForStatement for acorn, babel-eslint and other parsers (e.g. not esprima).

Check: AST Explorer

Reported acorn #838

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Apr 25, 2020

@anikethsaha I’m not working on it at the moment, feel free to take this!

1reaction
anikethsahacommented, Apr 25, 2020

@mdjermanovic are you working on this? if not I would like to take this

Read more comments on GitHub >

github_iconTop Results From Across the Web

arrow-body-style - 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 >
Automagically lint and format your code | Nicky blogs
Run the linting setup; A tighter feedback loop: editor configuration ... "arrow-body-style" and "prefer-arrow-callback" are two ESLint core ...
Read more >
eslint-plugin-autofix - npm Package Health Analysis | Snyk
Name 🛠 Description array‑bracket‑spacing 🛠 enforce consistent spacing inside array brackets array‑element‑newline 🛠 enforce line breaks after each array element arrow‑body‑style 🛠 require braces around arrow...
Read more >
Ask Question - Stack Overflow
I am new to eslint and I cannot figure out how to solve this issue. The beginning of my imports is always underlined...
Read more >
Loops in JavaScript - performing repeated operations on a ...
for Loops · Declare and initialize the index variable to 0 . · If index is not less than the array length, go...
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