question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-unexpected-multiline and template literal with typescript

See original GitHub issue

Tell us about your environment

  • eslint 6.9.0
  • node v11.6.0
  • npm 6.9.0
  • typescript 3.3.4

What parser (default, Babel-ESLint, etc.) are you using?

Not sure. I use CRA 3 without ejecting.

Please show your full configuration:

Configuration
{
  "extends": "react-app"
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

function myTag<T>(...args): any {
  return undefined;
}

export const test = myTag<{
  field: boolean;
}>`
  test;
`;

The command:

eslint --ext js,ts,ts,tsx src

What did you expect to happen?

No eslint warnings will be raised

What actually happened? Please include the actual, raw output from ESLint.

./src/test.ts
  Line 5:  Unexpected newline between template tag and template literal  no-unexpected-multiline

But with

function myTag<T>(...args): any {
  return undefined;
}

export const test = myTag<{ field: boolean }>`
  test;
`;

No warnings are showing.

It especially frustrates when you are using styled-components and component have a lot of props, that will not fit the maximum line length.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
hardfistcommented, May 30, 2019

same issue, prettier will automatic format

export const test = myTag<{ field: boolean }>`
  test;
`;

to

export const test = myTag<{
  field: boolean;
}>`
  test;
`;

which will cause eslint error, which is verify frustrating

0reactions
aladdin-addcommented, Jul 9, 2021

Closing because there hasn’t been activity for a few days. If it still occurs, please file a new issue. thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrap long template literal line to multiline without creating a ...
If you introduce a line continuation ( \ ) at the point of the newline in the literal, it won't create a newline...
Read more >
Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
no-unexpected-multiline - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
How to Create Multi-Line String with Template Literals
It's super easy now to create multi-line strings with Template Literals in JavaScript. No more messy string line breaks. Yay, ES6!
Read more >
Prettier 2.2: new JavaScript parsers, TS 4.1 and ESM ...
Template Literal Types. // Input type HelloWorld = `Hello, ${keyof World}` // Prettier 2.1 SyntaxError: Unexpected token, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found