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.

implicit-arrow-linebreak autofixer sometimes adds extra characters

See original GitHub issue

Tell us about your environment

  • ESLint Version: 5.12.0
  • Node Version: 10.15.0
  • npm Version: 6.4.1

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

babel-eslint (but i dont believe it matters)


Configuration
{
  "parser": "babel-eslint",
  "parserOptions": {
    "sourceType": "module"
  },
  "env": {
    "node": true
  },
  "rules": {
    "implicit-arrow-linebreak": "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.

start()
  .then(() => 
    /* If I put a comment here, eslint --fix breaks badly */
    process && typeof process.send === 'function' && process.send('ready')
  )
  .catch(err => {
  	/* catch seems to be needed here */
       console.log('Error: ', err)
  })

eslint --fix

What did you expect to happen?

Code that it “fixes” should not be invalid javascript

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

It creates broken code

start()
  .then(() => ( 
    /* If I put a comment here, eslint --fix breaks badly */
    process && typeof process.send === 'function' && process.send('ready')
         )
        )
  )
  .catch(err => ( {
  	/* catch seems to be needed here */
       console.log('Error: ', err)
  })

Notice that it broke the catch as it seems to assume its an implicit object return

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

not really, wouldnt know where to start


This can get REALLY bad and is especially an issue since its part of eslint-config-airbnb, granted this file is crazy, but the bug ends up filling the entire file up with thousands of invalid lines

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Jan 12, 2019

I’ll look into this.

0reactions
zliycommented, Feb 28, 2019

another falling case:

hello(response =>
  // comment
  response, param => param)

=>

hello(response => (
  // comment
  response
)), param => (param)
Read more comments on GitHub >

github_iconTop Results From Across the Web

implicit-arrow-linebreak - 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 >
demo-outil-edition - node_modules - eslint - CHANGELOG.md
29dbca7 Fix: implicit-arrow-linebreak adds extra characters (fixes #11268) (#11407) (Mark de Dios); 5d2083f Upgrade: eslint-scope@4.0.3 ...
Read more >
eslint - UNPKG
... autofix removes mandatory parentheses (#12905) (Milos Djermanovic) ... Fix: implicit-arrow-linebreak adds extra characters (fixes #11268) (#11407) (Mark ...
Read more >
AirBnB Linter multiple currying in same line making it too long
You can satisfy both rules. You'll see in the implicit-arrow-linebreak docs that you can wrap an implicit return in parentheses:
Read more >
Release Notes | Google Cloud CLI Documentation
Add support for preserving embedded Ascii Control characters in CSV External ... Changed certificate chain output format to remove extra newline between ...
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