Skip to content
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

[no-unexpected-multiline]: False positive with template string #139

Closed
jacobrask opened this issue Jan 25, 2019 · 3 comments
Closed

[no-unexpected-multiline]: False positive with template string #139

jacobrask opened this issue Jan 25, 2019 · 3 comments
Labels
bug Something isn't working enhancement: new base rule extension New base rule extension required to handle a TS specific case external This issue is with another package, not typescript-eslint itself package: typescript-estree Issues related to @typescript-eslint/typescript-estree

Comments

@jacobrask
Copy link

Repro

const IssueTitle = styled.h3<{
  size: StartpageComponentCarousel['params']['size'];
}>`
  display: inline-block;
`;

Gives no-unexpected-multiline error.

Versions

package version
@typescript-eslint/eslint-plugin X.Y.Z
@typescript-eslint/parser 1.1.0
TypeScript 3.2.4
ESLint 5.12.1
node X.Y.Z
npm X.Y.Z
@jacobrask jacobrask added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jan 25, 2019
@bradzacher bradzacher added the bug Something isn't working label Jan 25, 2019
@bradzacher bradzacher added package: typescript-estree Issues related to @typescript-eslint/typescript-estree and removed package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Feb 19, 2019
@bradzacher
Copy link
Member

The problem here is that the code with a type paremeter produces the following AST:

styled.h3<{
  size: StartpageComponentCarousel['params']['size'];
}>`
  display: inline-block;
`
{
  type: "TaggedTemplateExpression",
  tag: {
    type: "MemberExpression",
    // ...
    loc: {
      start: { line: 1, column: 19 },
      end: { line: 1, column: 28 }
    }
  },
  typeParameter: {
    type: "TSTypeParameterInstantiation",
    // ...
    loc: {
      start: { line: 1, column: 28 },
      end: { line: 3, column: 2 }
    }
  },
  qasi: {
    type: "TemplateLiteral",
    // ...
    loc: {
      start: { line: 3, column: 2 },
      end: { line: 5, column: 1 }
    }
  },
}

Notice that the tag ends, and the qasi starts on different lines.
Without the type parameter, the two instead end and start on the same line, respectively.

no-unexpected-multiline is hardcoded to ensure this relationship holds true.
We'll have to bring this rule into the plugin in order to fix this, as it's a TS specfic case.

@bradzacher bradzacher added enhancement: new plugin rule New rule request for eslint-plugin enhancement: new base rule extension New base rule extension required to handle a TS specific case and removed enhancement: new plugin rule New rule request for eslint-plugin labels Apr 15, 2019
@bradzacher
Copy link
Member

bradzacher commented May 10, 2019

potentially will be fixed upstream?
eslint/eslint#11650
eslint/eslint#11698

@bradzacher bradzacher added the external This issue is with another package, not typescript-eslint itself label May 10, 2019
@bradzacher
Copy link
Member

This will be fixed by
eslint/eslint#11698

which is approved and will be merged imminently.
I'm going to close this. Feel free to track the final progress over at the PR

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement: new base rule extension New base rule extension required to handle a TS specific case external This issue is with another package, not typescript-eslint itself package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

No branches or pull requests

2 participants