]>
Commit | Line | Data |
---|---|---|
eb39fafa DC |
1 | # disallow octal escape sequences in string literals (no-octal-escape) |
2 | ||
3 | 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. | |
4 | ||
5 | ```js | |
6 | var foo = "Copyright \251"; | |
7 | ``` | |
8 | ||
9 | ## Rule Details | |
10 | ||
11 | This rule disallows octal escape sequences in string literals. | |
12 | ||
13 | If ESLint parses code in strict mode, the parser (instead of this rule) reports the error. | |
14 | ||
15 | Examples of **incorrect** code for this rule: | |
16 | ||
17 | ```js | |
18 | /*eslint no-octal-escape: "error"*/ | |
19 | ||
20 | var foo = "Copyright \251"; | |
21 | ``` | |
22 | ||
23 | Examples of **correct** code for this rule: | |
24 | ||
25 | ```js | |
26 | /*eslint no-octal-escape: "error"*/ | |
27 | ||
28 | var foo = "Copyright \u00A9"; // unicode | |
29 | ||
30 | var foo = "Copyright \xA9"; // hexadecimal | |
31 | ``` |