[ESLint] Why are padded blocks not permitted?
See original GitHub issueI don’t quite understand why the ESLint config file prohibits padded blocks. What would happen if you needed to make a comment after a block opens:
// ESLint Error: "Block must not be padded by blank lines. (padded-blocks)"
$document.ready(() => {
// Initialize/Render React
React.render(React.createElement(Index), $react.get(0));
...
}
// Violates 17.2 of the style guide: "Put an empty line before the [single-line] comment."
$document.ready(() => {
// Initialize/Render React
React.render(React.createElement(Index), $react.get(0));
...
}
In addition, I don’t see anywhere in the style guide where padded blocks are prohibited.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
padded-blocks - 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 >Padding-block rule issue - javascript - Stack Overflow
I've started learning react from tutorials. I got error: /NotesInReact/node_modules/eslint-config-airbnb-base/rules/style.js: ...
Read more >https://unpkg.com/react-beautiful-dnd@2.2.4/.eslintrc
... blocks "padded-blocks": ["error", "never"], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md // Adding ...
Read more >Rules - JavaScript Standard Style
Rules · Use 2 spaces for indentation. eslint: indent · Use single quotes for strings except to avoid escaping. eslint: quotes · No...
Read more >tslint-eslint-rules | Yarn - Package Manager
Improve your TSLint with the missing ESLint Rules ... You want to code in TypeScript but miss all the rules available in ESLint?...
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
Whitespace is beneficial when it adds readability, but not when it creates visual noise. With syntax highlighting, lines padding blocks add zero benefit, but increase the vertical length of code, and reduce the amount you can see at once.
@ljharb , that’s not true for all cases. In several cases, adding a blank line add a HUGE readability improvement to the code, and it outweighs the fact that the code gets longer by 1 single line. For example in a test file:
vs
So what’s the real reason for not allowing the first line of a block to be empty? Myself, I never pad a block at the end, but doing it in the beginning give way more readable code in such cases.
If you want to reduce visual noise, then there also should be no spaces inside object declarations as well imho… So I believe that those both rules are conflicting with the reason behind them. Imho, a styleguide should have some general principles, and use them throughout, unless there is a very good reason not to adhere it.