0

I am using ESLint to format my Javascript code. There I have the following piece of code:

'<div id="' + sId + '" '; ...

I get an ESLint warning telling me 'Strings should use double quotes', so I went ahead and changed the surrounding single quotes to double quotes and escaped the inner double quote. This lead to an ESLint error, which suggested I use the single quotes exactly as you see above.

Is there a way to solve this conflict so that I don't get the error or the warning? Info: I am stuck with ES5.

Many thanks in advance!

user1728
  • 103
  • 2

1 Answers1

1

You can:

  • Escape double quotes in double-quoted strings ("<div id=\"" + sId + "\" ";)
  • Turn off the linting rule which requires double-quoted strings
  • Use a template literal instead (but that requires ES6 so you'd need to transpile it to ES5 afterwards)
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335