Rule proposal: `prefer-regexp-code-point-escape`
See original GitHub issueUnicode code point escapes are new in ES6. They support more bits than older escapes and it’s better to always use them for consistency, even when they’re not required.
- https://exploringjs.com/es6/ch_unicode.html#sec_escape-sequences
- https://mathiasbynens.be/notes/javascript-escapes#unicode-code-point
This overlaps with the no-hex-escapes
rule. Not sure whether we should deprecate that one. It’s plausible that someone wants to prevent Hex escapes, but not prefer code point escapes. Opinions welcome.
Inspired by https://github.com/eslint/eslint/issues/12488.
Fail
const foo = '\123'; // Octal
const foo = '\cA'; // Control escape sequence
const foo = '\x7A'; // Hex
const foo = '\u2661'; // Unicode escape sequence
const foo = '\uD83D\uDCA9'; // Unicode surrogate pair
Pass
const foo = '\u{7A}';
const foo = '\u{1F4A9}';
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Proposed rule: Order Competition Rule - SEC.gov
proposed rule would prohibit a restricted competition trading center from internally executing certain orders of individual investors at a ...
Read more >SEC proposes substantive changes in 4 stock market rules
The proposed amendments would expand the scope of entities subject to Rule 605, modify the information required to be reported under the rule, ......
Read more >SEC Proposes Equity Market Overhaul and Best Execution Rule
The SEC is proposing to amend Regulation NMS to (1) amend the tick sizes under Rule 612 to establish a variable minimum pricing...
Read more >sindresorhus/eslint-plugin-unicorn (Raised $2856.00)
Rule proposal: Require comparator function for `Array#sort()`. Unfunded#2014created bybmish ... Rule proposal: `prefer-regexp-code-point-escape`.
Read more >SEC Proposes Amendments to the Shareholder Proposal Rules
The SEC proposed modifying certain bases for excluding shareholder proposals from company proxy statements. If adopted, these amendments are ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Did you see my arguments for why
\u{7A}
is better? It’s shorter and it lets you use the same syntax always.It also makes escapes stand out more because of the braces, which makes strings with a lot of escapes more readable.
This is now accepted.