Skip to content

Commit 81241b8

Browse files
committed
[eslint config] [breaking] add no-useless-escape rule.
1 parent 2456512 commit 81241b8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,20 @@ Other Style Guides
547547
<a name="strings--eval"></a><a name="6.5"></a>
548548
- [6.5](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities.
549549
550+
<a name="strings--escaping"></a>
551+
- [6.6](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](http://eslint.org/docs/rules/no-useless-escape)
552+
553+
> Why? Backslashes harm readability, thus they should only be present when necessary.
554+
555+
```javascript
556+
// bad
557+
const foo = '\'this\' \i\s \"quoted\"';
558+
559+
// good
560+
const foo = '\'this\' is "quoted"';
561+
const foo = `'this' is "quoted"`;
562+
```
563+
550564
**[⬆ back to top](#table-of-contents)**
551565
552566

packages/eslint-config-airbnb/rules/best-practices.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ module.exports = {
113113
'no-unused-labels': 2,
114114
// disallow unnecessary .call() and .apply()
115115
'no-useless-call': 0,
116+
// disallow unnecessary string escaping
117+
// http://eslint.org/docs/rules/no-useless-escape
118+
'no-useless-escape': 2,
116119
// disallow use of void operator
117120
'no-void': 0,
118121
// disallow usage of configurable warning terms in comments: e.g. todo

0 commit comments

Comments
 (0)