
org.sonar.l10n.javascript.rules.javascript.MultilineStringLiterals.html Maven / Gradle / Ivy
Do not do this :
var myString = 'A rather long string of English text, an error message \
actually that just keeps going and going -- an error \
message to make the Energizer bunny blush (right through \
those Schwarzenegger shades)! Where was I? Oh yes, \
you\'ve got an error and all the extraneous whitespace is \
just gravy. Have a nice day.';
The whitespace at the beginning of each line can't be safely stripped at compile time;
whitespace after the slash will result in tricky errors;
and while most script engines support this, it is not part of ECMAScript.
Use string concatenation instead :
var myString = 'A rather long string of English text, an error message ' +
'actually that just keeps going and going -- an error ' +
'message to make the Energizer bunny blush (right through ' +
'those Schwarzenegger shades)! Where was I? Oh yes, ' +
'you\'ve got an error and all the extraneous whitespace is ' +
'just gravy. Have a nice day.';
© 2015 - 2025 Weber Informatics LLC | Privacy Policy