Disallow Multiline Strings (no-multi-str)

It's possible to create multiline strings in JavaScript by using a slash before a newline, such as:

var x = "Line 1 \
         Line 2";

Some consider this to be a bad practice as it was an undocumented feature of JavaScript that was only formalized later.

Rule Details

This rule is aimed at preventing the use of multiline strings.

Examples of incorrect code for this rule:

/*eslint no-multi-str: "error"*/
var x = "Line 1 \
         Line 2";

Examples of correct code for this rule:

/*eslint no-multi-str: "error"*/

var x = "Line 1\n" +
        "Line 2";

Version

This rule was introduced in ESLint 0.0.9.

Resources

Js中文网,专注分享前端最新技术、大厂面试题、聊点程序员轶事、职场感悟,做前端技术的传播者.

加入前端布道师交流群

扫描二维码回复 加群 学习,与大厂大佬讨论技术.

BAT面试题大全