noMultiStr
¥Summary
-
规则生效日期:
v2.3.8¥Rule available since:
v2.3.8 -
¥Diagnostic Category:
lint/nursery/noMultiStr -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
来源:
¥Sources:
-
与
no-multi-str相同¥Same as
no-multi-str
-
¥How to configure
{ "linter": { "rules": { "nursery": { "noMultiStr": "error" } } }}¥Description
禁止通过转义换行符创建多行字符串。
¥Disallow creating multiline strings by escaping newlines.
不建议转义换行符来创建多行字符串,因为这可能会导致反斜杠后出现意外的空格,从而引发一些不易察觉的错误。
¥Escaping newlines to create multiline strings is discouraged because it can lead to subtle errors caused by unexpected whitespace after the backslash.
¥Examples
¥Invalid
const foo = "Line 1\n\Line 2";code-block.js:2:5 lint/nursery/noMultiStr ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Escaping newlines to create multiline strings is disallowed.
1 │ const foo =
> 2 │ “Line 1\n\
│ ^^^^^^^^^^
> 3 │ Line 2”;
│ ^^^^^^^
4 │
¥Valid
const foo = "Line 1\nLine 2";const bar = `Line 1Line 2`;¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号