noOctalEscape
此内容尚不支持你的语言。
Diagnostic Category: lint/nursery/noOctalEscape
Since: v1.9.3
Sources:
- Same as:
no-octal-escape
Description
Section titled DescriptionDisallow octal escape sequences in string literals
As of the ECMAScript 5 specification, octal escape sequences in string literals are deprecated and should not be used. Unicode escape sequences should be used instead.
Examples
Section titled ExamplesInvalid
Section titled Invalidvar foo = "Copyright \251";
code-block.js:1:11 lint/nursery/noOctalEscape ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Don’t use octal
> 1 │ var foo = “Copyright \251”;
│ ^^^^^^^^^^^^^^^^
2 │
ℹ Don’t use octal escape sequences: “Copyright \251”
ℹ Use unicode or hexidecimal escape sequences instead.
Valid
Section titled Validvar foo = "Copyright \u00A9"; // unicode
var foo = "Copyright \xA9"; // hexadecimal
How to configure
Section titled How to configure{ "linter": { "rules": { "nursery": { "noOctalEscape": "error" } } }}