prefer-template rule parameter for "never"
See original GitHub issueTell 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:
- Created 6 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top GitHub Comments
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.
@j-f1 much better response than the previous one. much appreciated, that’ll get me where I need to be.