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.

prefer-template rule parameter for "never"

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.4.1
  • Node Version: 8.2.1
  • npm Version: 5.3.0

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

Please show your full configuration: We’re using this and extending it https://github.com/webpack-contrib/eslint-config-webpack

Configuration
{
  "extends": "webpack"
}

What did you do? Please include the actual source code causing the issue.

const foo = 'bar';
const res = foo + ' something';

eslint-config-webpak contains "prefer-template": "error" and "no-useless-concat": "error". Nothing out of the ordinary there. In the project I’m working on, we have a few files which are served to a client (browser). When we ran the --fix option, ESLint went ahead and replaced all of the concats in our client files with template literals.

What did you expect to happen?

Well we expected that behavior.

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

What we didn’t realize was that IE (not Edge) wouldn’t support the change as it doesn’t support template literals. The onus was on us to know the rules that ESLint would apply. However, now that we’ve identified the problem, we need to go back through and fix the template literals, changing them back to regular concats. Unfortunately, prefer-template doesn’t have a rule parameter for reversing that automatic change.

Something along the lines of "prefer-template": ["error", "never"] would be immensely useful for reverting those changes by way of an .eslintrc in the client files directory, and rerunning with --fix.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Sep 14, 2017

I’m not 100% opposed, but I’ll point out that this is a solid use case for source control.

That said, the rule does seem incomplete without this option. I’ll support this. Let’s see what the rest of the team thinks.

0reactions
shellscapecommented, Jan 19, 2018

@j-f1 much better response than the previous one. much appreciated, that’ll get me where I need to be.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected string concatenation - Stack Overflow
Try using a template literal. ie. const ANR = 'Animal Friend,ANR,ANP,$30' const specialityPlates = [ { cName: 'Environmental / Wildlife', ...
Read more >
Rules - ESLint - Pluggable JavaScript Linter
Rules in ESLint are grouped by type to help you understand their purpose. ... Disallow duplicate arguments in `function` definitions ... prefer-template.
Read more >
prefer-template - ESLint Config
prefer-template. - Require template literals instead of string concatenation. Fixable. This rule is aimed to flag usage of + operators with strings.
Read more >
enforce line breaks between arguments of a function call ...
Options. This rule has a string option: "always" (default) requires line breaks between arguments; "never" ...
Read more >
Low level issue - Embold Help Center
Rule Description KPI newline‑before‑return Helps maintain a readable style in your codebase. Understand... no‑consecutive‑blank‑lines Helps maintain a readable style in your codebase. Understand... linebreak‑style Enforces a...
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