no-multi-str

禁止多行字符串

可以在 JavaScript 中通过在换行符前使用斜杠来创建多行字符串,例如:

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

var x = "Line 1 \
         Line 2";

有些人认为这是一种不好的做法,因为它是 JavaScript 的一个未记录的特性,后来才正式化。

¥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 = "some very \
long text";

此规则的正确代码示例:

¥Examples of correct code for this rule:

在线运行
/*eslint no-multi-str: "error"*/

var x = "some very long text";

var x = "some very " +
        "long text";

版本

此规则是在 ESLint v0.0.9 中引入。

资源

ESLint 中文网
粤ICP备13048890号