Allow padding on simple returns for newline-before-return
See original GitHub issueESLint Version: 2.10.1
Problem:
Using newline-before-return
with padded-blocks
causes a conflict, as padded-blocks
insists on padded spacing for functions, and newline-before-return
complains if there is a newline before a return statement by itself in a function.
Recommended Solution:
Add an option to newline-before-return
to ignore scenarios where the only statement in a function block is the return statement.
For example:
"newline-before-return": ["error", {
"pad-getters": true // (New) Ensure getter returns are padded on either side by a newline
}]
This will allow ESLint to properly support it’s built-in plugins without changing the default functionality of the newline-before-return
rule. With the above configuration:
This code would result in an error:
function getVar() {
return this.var;
}
This code would be valid with both plugins:
function getVar() {
return this.var;
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (11 by maintainers)
Top Results From Across the Web
newline-before-return - ESLint - Pluggable JavaScript Linter
This rule was deprecated in ESLint v4.0.0 and replaced by the padding-line-between-statements rule. There is no hard and fast rule about whether empty...
Read more >Has ESlint a rule about blank line before the first statement in ...
The padded-blocks rule allows you to require newlines at the start and end of blocks, including function bodies.
Read more >Injecting a Line Break | CSS-Tricks
The text after the break should be inline/inline-block, because it's going to have a background and padding and such.
Read more >The Dos and Don'ts of Adding an HTML Line Break
The second uses multiple paragraph elements and no line breaks. As a result, unnecessary padding and margins are added between lines. HTML.
Read more >HTML Line Break – How to Break a Line with the HTML <br ...
You can insert line breaks in HTML with the <br> tag, which is equivalent to a carriage return on a keyboard. Be aware...
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 FreeTop 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
Top GitHub Comments
I think
newline-before-return
should not error when it is the first statement in a block, regardless of the newlines and that should be left topadded-blocks
.The doc says (emphasis mine):
Can we document what should be considered as breaking change? See JSCS example https://github.com/jscs-dev/node-jscs/blob/master/OVERVIEW.md#user-content-versioning--semver for reference