profile
viewpoint

Ask questionsEnforce 2 (or more) lines not just one [lines-between-class-members]

<!-- ESLint adheres to the Open JS Foundation Code of Conduct: https://eslint.org/conduct

This template is for requesting a rule change. If you are here for another reason, please see below:

1. To report a bug: https://eslint.org/docs/developer-guide/contributing/reporting-bugs
2. To propose a new rule: https://eslint.org/docs/developer-guide/contributing/new-rules
3. To request a change that is not a bug fix, rule change, or new rule: https://eslint.org/docs/developer-guide/contributing/changes
4. If you have any questions, please stop by our chatroom: https://eslint.org/chat

Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.

-->

What rule do you want to change?

[lines-between-class-members]

Does this change cause the rule to produce more or fewer warnings?

Possibly more.

How will the change be implemented? (New option, new default behavior, etc.)?

Modification to setting in eslint file.

{
  "rules": {
    "lines-between-class-members": [true, 2], <--- This right here, enforces 2 lines
  },
  "rulesDirectory": [
    "node_modules/tslint-lines-between-class-members"
  ]
}

Please provide some example code that this change will affect:

<!-- Put your code examples here -->

// Valid
    componentDidMount() {
        this._isMounted = true;
        this.getProjects();
        this.getPendingInvites();
    }

    
    componentWillUnmount() {
        this._isMounted = false;
    }

// Invalid

    componentDidMount() {
        this._isMounted = true;
        this.getProjects();
        this.getPendingInvites();
    }
    
   componentWillUnmount() {
        this._isMounted = false;
    }

What does the rule currently do for this code?

Can only be used to enforce 1 space between class members.

What will the rule do after it's changed?

Be able to enforce more than 1 space. Some people like to use 2 spaces.

Are you willing to submit a pull request to implement this change?

No I don't know how this works under the hood.

eslint/eslint

Answer questions IgorNovozhilov

I also thought about this when I was working on PR #12663. But since the review of the changes took a long time, I left the idea with the revision for later.

useful!

Related questions

TypeError: this.cliEngine is not a constructor hot 3
Rule change request: no-async-promise-executor should be if-async-promise-executor-then-try-catch-surrounding-await hot 2
ESLint configuration in **** eslintrc is invalid: - Unexpected top-level property &#34;react/sort-comp&#34;. hot 2
Error: Unexpected top-level property "$schema" hot 1
SyntaxError: Invalid regular expression flags From 6.6.0 Release hot 1
Error while running ESLint: Invalid regular expression flags hot 1
Incorrect configuration error for no-param-reassign hot 1
Eslint does not respect .eslintignore when using file match pattern - eslint hot 1
eslint: eslint whole folder fails on git bash hot 1
Personal config (~/.eslintrc) doesn&#39;t load global-installed configs/parsers/plugins hot 1
'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead (node/no-deprecated-api) hot 1
6.0.0-alpha.1 tries to process configuration files in ignored directories hot 1
Allow excluding class expressions in max-classes-per-file hot 1
The new ignorePatterns option does not exist in json.schemastore.org/eslintrc hot 1
Cannot set property 'hasAwait' of null hot 1
Github User Rank List