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.

Add auto-fixing to newline-before-return

See original GitHub issue

Following @alberto’s suit. If accepted, I’d like to implement this. I’ll table this for now in favor of JSCS compatibility issues. If anyone else is interested in picking this up, please feel free.

Some interesting challenges I found while doing some initial work on this:

  • Keeping indentation (Not sure if necessary, given multi-pass auto-fixing, but seems like a nice thing to have)
  • If there’s a comment between the return statement and the previous token, I think that the newline should come after the previous token (but before the comment), as this seemed to me to be the more often used case. This shouldn’t be the behavior if the comment is on the same line as the previous token, though (in which case the newline should probably come after the comment).

Alternatively, if we feel like making those decisions is overreaching for a stylistic rule like this, then we can just not auto-fix if there are comments between the return statement and the previous token.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:42 (38 by maintainers)

github_iconTop GitHub Comments

2reactions
vitorbalcommented, Sep 1, 2016

Quick update: I’ll probably have a PR for this by the weekend!

1reaction
vitorbalcommented, Aug 31, 2016

Okay, agreed. Thanks for the input everyone! I will work on this most likely during the weekend.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Any solution to autofix or autocorrect ESLint rules?
If you run eslint with the --fix flag it will try to fix any linting changes that it can, and let you know...
Read more >
Rules - 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 >
Eslint-plugin-autofix - npm.io
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 >
How To Enable Linting on Save with Visual Studio Code and ...
For the needs of this tutorial, you will need to have ESLint installed and configured. First, create a new project directory: mkdir eslint-save- ......
Read more >
demo-outil-edition - node_modules - eslint - CHANGELOG.md
... Add no-setter-return rule (fixes #12285) (#12346) (Milos Djermanovic); 0afb518 Fix: invalid autofix in function-call-argument-newline ...
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