Add auto-fixing to newline-before-return
See original GitHub issueFollowing @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:
- Created 7 years ago
- Reactions:5
- Comments:42 (38 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Quick update: I’ll probably have a PR for this by the weekend!
Okay, agreed. Thanks for the input everyone! I will work on this most likely during the weekend.