Skip to content

Proposal for no-useless-concat to report multiline strings #7947

Closed

Description

@vsemozhetbyt

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.

Activity

  1. added
    triageAn ESLint team member will look at this issue soon
    on Jan 19, 2017
  2. added
    enhancementThis change enhances an existing feature of ESLint
    evaluatingThe team will evaluate this issue to decide whether it meets the criteria for inclusion
    ruleRelates to ESLint's core rules
    and removed
    triageAn ESLint team member will look at this issue soon
    on Jan 19, 2017
  3. platinumazure commented on Jan 19, 2017

    @platinumazure
    Member

    We can bikeshed on the option name if necessary, but this seems like a perfectly reasonable enhancement request and I've given it a 👍. So we need a champion and two more 👍s (all from among the ESLint core team) to accept this issue.

  4. jhitchins88 commented on Feb 5, 2017

    @jhitchins88

    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.

  5. ljharb commented on Feb 5, 2017

    @ljharb
    SponsorContributor

    Should it also report on multiline strings ending in \r\n?

  6. jhitchins88 commented on Feb 5, 2017

    @jhitchins88

    I would assume, as it still ends in \n. The bigger question is should it flag this:

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

    Probably not? That's a very specific case that I don't think it should flag, but I could see an argument for doing it, as it's most likely a bug (intended to either be written with a multi-line string template or with \r\n).

    Thoughts?

  7. ljharb commented on Feb 5, 2017

    @ljharb
    SponsorContributor

    Makes sense that it wouldn't flag it; people are rarely going to be doing that anyways.

  8. not-an-aardvark commented on Aug 14, 2017

    @not-an-aardvark
    Member

    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.

  9. locked and limited conversation to collaborators on Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    archived due to ageThis issue has been archived; please open a new issue for any further discussionenhancementThis change enhances an existing feature of ESLintevaluatingThe team will evaluate this issue to decide whether it meets the criteria for inclusionruleRelates to ESLint's core rules

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions