8000 [indent] Add support for emacs-style indentation of `MemberExpression`s · Issue #1540 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

[indent] Add support for emacs-style indentation of MemberExpressions #1540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
c32hedge opened this issue Jan 29, 2020 · 1 comment
Closed
Labels
external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@c32hedge
Copy link
c32hedge commented Jan 29, 2020

Repro

{
  "rules": {
    "indent": "off",
    "@typescript-eslint/indent": ["error", 2, { "MemberExpression": 1 } ] // (default value)
  }
}
    cy.wrap(dataStore.getUsers()
            .map(t => t.MadeUpName[0].getAPI()
                 .then(api => apiInstances.push(api))))
      .then(() => dataStore.upload());

Expected Result

I would like an option that would keep the indentation the same as in my example code, which is what emacs does (I believe it's a function called typescript--proper-indentation in the typescript-mode major mode).

Actual Result

Currently my options are limited to specifying an absolute number of indentation levels, or turning the MemberExpression rule off. With the default value of 1, the code above gets "fixed" as:

    cy.wrap(dataStore.getUsers()
      .map(t => t.MadeUpName[0].getAPI()
        .then(api => apiInstances.push(api))))
      .then(() => dataStore.upload());

This is actually harmful, since the .map now lines up with the second .then as if .map were chained to cy.wrap instead of dataStore.getUsers().

Changing MemberExpression to a higher number doesn't help either since it will continue indenting the second .then as well, maintaining the false alignment.

Currently my only option is to use "off" for MemberExpression, but then I don't get any enforcement.

I have similar issues with the ClassProperty and AssignmentPattern AST nodes but that's probably worth discussing in a separate issue (actually, looks like the ClassProperty issue already exists: #549)

I saw an old eslint proposal for adding support for a "first" option for the MemberExpression rule (eslint/eslint#9383), but that doesn't seem to quite match what I'm looking for--none of the examples in the long thread there seem to cover my example above.

Additional Info

N/A (new feature request, not a problem with an existing rule)

Versions

package version
@typescript-eslint/eslint-plugin 2.17.0
@typescript-eslint/parser 2.17.0
TypeScript 3.5.3
ESLint 6.8.0
node 13.7.0
npm 6.13.6
@c32hedge c32hedge added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jan 29, 2020
@bradzacher
Copy link
Member

Thanks for the suggestion!

This rule is maintained by eslint core; our version just adds support for typescript features.
We're not otherwise looking to deviate from the core implementation.

If you'd like to see this added, please raise this issue in the eslint repo.
https://github.com/eslint/eslint

@bradzacher bradzacher added external This issue is with another package, not typescript-eslint itself and removed triage Waiting for team members to take a look labels Jan 29, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants
0