Skip to content

[indent] Multiline class members with linebreak right after = #549

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
Philipp91 opened this issue May 22, 2019 · 2 comments
Closed

[indent] Multiline class members with linebreak right after = #549

Philipp91 opened this issue May 22, 2019 · 2 comments
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@Philipp91
Copy link

Repro

{
  "rules": {
    "@typescript-eslint/indent": "error",
  }
}
class Test {
    public test =
        'test';
}

Expected Result

No warning. This is what the auto-formatter does, this is also what I consider to look reasonable.

Actual Result

error Expected indentation of 4 spaces but found 8 on the 'test' line, and auto-fix to:

class Test {
    public test =
    'test';
}

Additional Info

  eslint:linter Linting code for ......ts (pass 1) +0ms
  eslint:traverser Unknown node type "ClassProperty": Estimated visitor keys ["type","key","value","computed","static","readonly","range","loc","accessibility"] +0ms
  eslint:linter Generating fixed text for ......ts (pass 1) +29s
  eslint:source-code-fixer Applying fixes +0ms
  eslint:source-code-fixer shouldFix parameter was false, not attempting fixes +0ms

The problem does not occur if there is no line-break after the = operator, or outside of class properties:

class Test {
    public test = 'test' +
        'test';
}
const test =
    'test';

Versions

package version
@typescript-eslint/eslint-plugin 1.9.0
@typescript-eslint/parser 1.9.0
TypeScript 3.4.5
ESLint 5.16.0
node 8.11.3
npm 6.9.0
@Philipp91 Philipp91 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels May 22, 2019
@Philipp91
Copy link
Author

The error message says that the ClassProperty node type is not known. In the code it's listed as KNOWN_NODES with the remark that eslint doesn't support it.

I couldn't find an upstream tracking bug at eslint or babel-eslint (I'm using version 10.0.1).

When I remove the public keyword, my repro example becomes valid JavaScript, and the non-TS eslint does not complain on the code, though it seems to allow any arbitrary indentation in that position, which seems to be tracked in babel/babel-eslint#598.

@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for team members to take a look labels May 22, 2019
@bradzacher bradzacher added this to the indent rewrite milestone May 22, 2019
@bradzacher
Copy link
Member

Merging into #1824

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants