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.

Proposal for no-useless-concat to report multiline strings

See original GitHub issue

What rule do you want to change? no-useless-concat

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

How will the change be implemented? (New option, new default behavior, etc.)? An object option like { "reportMultiLineStrings": true }.

Please provide some example code that this change will affect:

const privateKey =
'-----BEGIN EC PRIVATE KEY-----\n' +
'MHcCAQEEIF+jnWY1D5kbVYDNvxxo/Y+ku2uJPDwS0r/VuPZQrjjVoAoGCCqGSM49\n' +
'AwEHoUQDQgAEurOxfSxmqIRYzJVagdZfMMSjRNNhB8i3mXyIMq704m2m52FdfKZ2\n' +
'pQhByd5eyj3lgZ7m7jbchtdgyOF8Io/1ng==\n' +
'-----END EC PRIVATE KEY-----\n';

What does the rule currently do for this code? No warning.

What will the rule do after it’s changed? Propose multiline template literal.

See also this comment.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jhitchins88commented, Feb 5, 2017

Basically you want…

const privateKey =
'-----BEGIN EC PRIVATE KEY-----\n' +
'MHcCAQEEIF+jnWY1D5kbVYDNvxxo/Y+ku2uJPDwS0r/VuPZQrjjVoAoGCCqGSM49\n' +
'AwEHoUQDQgAEurOxfSxmqIRYzJVagdZfMMSjRNNhB8i3mXyIMq704m2m52FdfKZ2\n' +
'pQhByd5eyj3lgZ7m7jbchtdgyOF8Io/1ng==\n' +
'-----END EC PRIVATE KEY-----\n';

…to be written like…

const privateKey =
`-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIF+jnWY1D5kbVYDNvxxo/Y+ku2uJPDwS0r/VuPZQrjjVoAoGCCqGSM49
'AwEHoUQDQgAEurOxfSxmqIRYzJVagdZfMMSjRNNhB8i3mXyIMq704m2m52FdfKZ2
'pQhByd5eyj3lgZ7m7jbchtdgyOF8Io/1ng==
'-----END EC PRIVATE KEY-----\n`;

The rule would be okay with this, correct?

const fileName = "/test/test/test/test/testDir/reallyLongDirName" +
    "/it/just/keeps/on/going"

It would search for two strings being concatenated on a line break with a new line character. I’m for it. I’d also be down for implementing it. It shouldn’t be a terribly difficult rule to apply.

0reactions
not-an-aardvarkcommented, Aug 14, 2017

Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get enough support from the team and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after a long time tend to never do it, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-useless-concat - 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 >
Java static code analysis: String multiline concatenation ...
Strings should not be concatenated using '+' in a loop ... The most common pattern for multiline strings in Java < 15 was...
Read more >
Disallow unnecessary concatenation of strings (no-useless ...
Disallow unnecessary concatenation of strings (no-useless-concat). It's unnecessary to concatenate two strings together, such as: var foo = "a" + "b";.
Read more >
Wrap long template literal line to multiline without creating a ...
The solution proposed by @CodingIntrigue is not working for me on node 7. Well, it works if I do not use a line...
Read more >
How do I create a multiline string in JavaScript? - ReqBin
For readability, it was possible to split a long string into several lines and concatenate using the (+) operator. This approach is helpful...
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