padded-blocks rule - add a multi-line option to this rule
See original GitHub issueWhat rule do you want to change? padded-blocks
Does this change cause the rule to produce more or fewer warnings? Potentially fewer warning depending on the situation.
How will the change be implemented? (New option, new default behavior, etc.)? Added an option to padded-blocks to specify a minimum number of lines required before the rule takes affect.
Please provide some example code that this change will affect:
Currently in JSCS, we have the rule of requirePaddingNewlinesInBlocks. The equivalent rule in seems to be padded-blocks in ESLINT. However, there is no way to specify a minimum number of lines required before the rule takes affect. So here is the problem:
Using JSCS, I can specify `“requirePaddingNewlinesInBlocks”: 1" and the following are valid for this rule:
function foo() { // valid since more than 1 line between the blocks is required to throw an error
return bar();
}
function foo() { // valid
dobar();
return bar();
}
Using ESLINT with the rule "padded-blocks": [2, "always"]
function foo() { // not valid according to ESLINT
return bar();
}
function foo() { // valid
dobar();
return bar();
}
What does the rule currently do for this code? The rule currently causes a linting error whenever padding is not around the blocks. So I would like to specify a rule like this:
"padded-blocks": [2, "always"]
So that we have an equivalent for the JSCS rule. Note: PolyJuice currently translate the rule as "padded-blocks": [2, "always"]
.
What will the rule do after it’s changed?
In the example above, the linting error for the ESLINT example will be removed.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:12 (8 by maintainers)
Top GitHub Comments
How about
minLines
?(Noting that this is related to, but hopefully not a duplicate of, #7356. I had recommended in chat that this could probably be done as an atomic proposal rather than waiting for #7356 to get moving. If anyone on the core team disagrees, I apologize for causing any confusion.)
Hi @sscaff1, thanks for the issue.
I think this behavior should definitely be behind a new option. Maybe something like this?
"padded-blocks": [2, { "withMoreLinesThan": 1 }]
(But please let’s find a better option name)