Navigation Menu

Skip to content

Commit

Permalink
[eslint config] [breaking] add no-useless-escape rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 27, 2016
1 parent 2456512 commit 81241b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -547,6 +547,20 @@ Other Style Guides
<a name="strings--eval"></a><a name="6.5"></a>
- [6.5](#strings--eval) Never use `eval()` on a string, it opens too many vulnerabilities.

<a name="strings--escaping"></a>
- [6.6](#strings--escaping) Do not unnecessarily escape characters in strings. eslint: [`no-useless-escape`](http://eslint.org/docs/rules/no-useless-escape)

> Why? Backslashes harm readability, thus they should only be present when necessary.
```javascript
// bad
const foo = '\'this\' \i\s \"quoted\"';

// good
const foo = '\'this\' is "quoted"';
const foo = `'this' is "quoted"`;
```

**[⬆ back to top](#table-of-contents)**


Expand Down
3 changes: 3 additions & 0 deletions packages/eslint-config-airbnb/rules/best-practices.js
Expand Up @@ -113,6 +113,9 @@ module.exports = {
'no-unused-labels': 2,
// disallow unnecessary .call() and .apply()
'no-useless-call': 0,
// disallow unnecessary string escaping
// http://eslint.org/docs/rules/no-useless-escape
'no-useless-escape': 2,
// disallow use of void operator
'no-void': 0,
// disallow usage of configurable warning terms in comments: e.g. todo
Expand Down

0 comments on commit 81241b8

Please sign in to comment.