Require padding depending on line count
See original GitHub issueWhat rule do you want to change?
padded-blocks
Does this change cause the rule to produce more or fewer warnings?
It depends.
How will the change be implemented? (New option, new default behavior, etc.)?
New option: min-expression-count and max-expression-count.
/*eslint padded-blocks: ["error", "always", { allowSingleLineBlocks: false, minExpressionCount: 3 }]*/
/*eslint padded-blocks: ["error", "never", { allowSingleLineBlocks: true, maxExpressionCount: 2 }]*/
Please provide some example code that this change will affect:
// not allowed
function foo() {
bar();
bar();
bar();
}
// allowed
function foo() {
bar();
bar();
bar();
}
// allowed
function foo() {
bar();
bar();
}
// allowed
function foo() {
bar();
}
// not allowed
function foo() {
bar();
}
// allowed
function foo() { bar(); }
// not allowed
function foo() { bar(); bar(); bar(); }
What does the rule currently do for this code? Disregards the lines in blocks
What will the rule do after it’s changed? Consider if a body is long enough to see it worth padding
Are you willing to submit a pull request to implement this change? Yes, if pointed in the right direction
I know it’s not the most common style, bu we have a huge codebase that we want to switch to ESLint. It would be great if this is possible.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
it’s not necessary to fork eslint repo. You can simply write your own eslint plugin and you can even extend the eslint’s base rule , refer this example on how to extend a base rule.
Thanks a lot for the input, I’ll try extending the rule.