Support class fields with lines-between-class-members
See original GitHub issueTell us about your environment
- ESLint Version: 6.1.0
- Node Version: 12.6.0
- npm Version: 6.10.0
What parser (default, Babel-ESLint, etc.) are you using? babel-eslint
Please show your full configuration:
Configuration
module.exports = {
root: true,
parser: 'babel-eslint',
env: {
node: true
},
extends: [
'standard',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:prettier/recommended'
],
plugins: [],
settings: {
'import/resolver': {
node: { extensions: ['.js', '.mjs'] }
}
},
rules: {
curly: ['error', 'all'],
'dot-notation': 'error',
'import/first': 'error',
'import/no-mutable-exports': 'error',
'import/no-unresolved': 'off',
'import/order': 'error',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-lonely-if': 'error',
'no-useless-rename': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: 'block-like', next: '*' },
{ blankLine: 'always', prev: 'break', next: '*' },
{ blankLine: 'always', prev: '*', next: 'class' },
{ blankLine: 'always', prev: '*', next: 'default' },
{ blankLine: 'always', prev: '*', next: 'do' },
{ blankLine: 'always', prev: '*', next: 'for' },
{ blankLine: 'always', prev: '*', next: 'function' },
{ blankLine: 'always', prev: '*', next: 'if' },
{ blankLine: 'always', prev: '*', next: 'iife' },
{ blankLine: 'always', prev: '*', next: 'switch' },
{ blankLine: 'always', prev: '*', next: 'try' },
{ blankLine: 'always', prev: '*', next: 'while' }
],
'prefer-const': 'error',
'require-await': 'error'
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
class SocketServer {
#closing = false
#connections = []
#logger
#message = ''
#messageHandler
#port
#server
constructor() {}
}
npx eslint .
What did you expect to happen? I expected no error for the private class fields after the first.
What actually happened? Please include the actual, raw output from ESLint.
I got errors for all private class fields after the first.
/Users/aparajita/Developer/projects/clients/willsub/js/socket-server/index.js
20:3 error Expected blank line between class members lines-between-class-members
21:3 error Expected blank line between class members lines-between-class-members
22:3 error Expected blank line between class members lines-between-class-members
23:3 error Expected blank line between class members lines-between-class-members
24:3 error Expected blank line between class members lines-between-class-members
25:3 error Expected blank line between class members lines-between-class-members
✖ 6 problems (6 errors, 0 warnings)
6 errors and 0 warnings potentially fixable with the `--fix` option.
This is related to #11153, which was closed in January because class fields are currently Stage 3.
However, since then support for this is out there by default, no --experimental flag required:
Babel 7.0+
Node 12
Public fields are enabled by default in Chrome 72 / V8 7.2
Private fields are enabled by default in Chrome 74 / V8 7.4
Partial, in-progress support in Firefox 67
Further implementations are on the way:
In progress in TypeScript
Out for review in Safari/JSC
In progress in Firefox/SpiderMonkey
Given the wide support for this language feature, I’m hoping you will reconsider waiting for it to reach Stage 4 before supporting it in eslint.
Are you willing to submit a pull request to fix this bug?
Maybe.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
FYI, I submitted a PR at babel/eslint-plugin-babel.
There have been exceptions in the past, and we decided to clarify this policy in an effort to be clearer and more consistent. Is the rule currently crashing? If so, we would definitely want to fix that (as per our policy). Otherwise, I suggest making an issue in https://github.com/babel/eslint-plugin-babel to see if a modified version of the rule can be added there.