]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-octal-escape.md
38fa4fcadb396fd40c430210bea2d4e1c45ba6ad
[pve-eslint.git] / eslint / docs / src / rules / no-octal-escape.md
1 ---
2 title: no-octal-escape
3 layout: doc
4 rule_type: suggestion
5 ---
6
7
8 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.
9
10 ```js
11 var foo = "Copyright \251";
12 ```
13
14 ## Rule Details
15
16 This rule disallows octal escape sequences in string literals.
17
18 If ESLint parses code in strict mode, the parser (instead of this rule) reports the error.
19
20 Examples of **incorrect** code for this rule:
21
22 ::: incorrect
23
24 ```js
25 /*eslint no-octal-escape: "error"*/
26
27 var foo = "Copyright \251";
28 ```
29
30 :::
31
32 Examples of **correct** code for this rule:
33
34 ::: correct
35
36 ```js
37 /*eslint no-octal-escape: "error"*/
38
39 var foo = "Copyright \u00A9"; // unicode
40
41 var foo = "Copyright \xA9"; // hexadecimal
42 ```
43
44 :::