`'padded-blocks': ['error', 'never']` doesn't appear to disallow padding in ES6 `class` declarations
See original GitHub issueTell us about your environment
NodeJS (literally just index.js
, package.json
, and a node_modules
folder).
- ESLint Version: v3.12.2
- Node Version: v6.9.2
- npm Version: 3.10.9
What parser (default, Babel-ESLint, etc.) are you using?: Default
Please show your full configuration:
'use strict';
const ESLintConfiguration = {
root: true,
parserOptions: {
sourceType: 'script'
},
env: {
es6: true,
node: true
},
rules: {
'padded-blocks': ['error', 'never']
}
}
module.exports = ESLintConfiguration;
What did you do? Please include the actual source code causing the issue. Linted this file:
'use strict';
class SomeClass {
constructor(opts) {
this.opts = opts;
}
}
const instance = new SomeClass(12);
console.log(instance.opts);
Specifically, I ran this command:
`npm bin`/eslint index.js
What did you expect to happen?
/Users/treybrisbane/src/personal/eslint-test/index.js
3:17 error Block must not be padded by blank lines padded-blocks
5:20 error Block must not be padded by blank lines padded-blocks
9:2 error Block must not be padded by blank lines padded-blocks
11:1 error Block must not be padded by blank lines padded-blocks
✖ 4 problems (4 errors, 0 warnings)
What actually happened? Please include the actual, raw output from ESLint.
/Users/treybrisbane/src/personal/eslint-test/index.js
5:20 error Block must not be padded by blank lines padded-blocks
9:2 error Block must not be padded by blank lines padded-blocks
✖ 2 problems (2 errors, 0 warnings)
Interestingly, if I use this configuration (note the more specific padded-blocks
options)…
'use strict';
const ESLintConfiguration = {
root: true,
parserOptions: {
sourceType: 'script'
},
env: {
es6: true,
node: true
},
rules: {
'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }]
}
}
module.exports = ESLintConfiguration;
… I get the expected output.
It seems as though simply supplying 'never'
to padded-blocks
does NOT set classes: 'never'
, but DOES set blocks: 'never'
(what about switches
?).
This may be a documentation oversight, but if this is intended behaviour, it seems a bit unintuitive!
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
@alberto Do you think we could change the default behavior in a major release? I think this is probably a bit confusing as is.
Thanks for the clarification, guys. 😃