Skip to content

Commit

Permalink
Fix no-implicit-coercion templateString examples
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Apr 5, 2021
1 parent 4350ec1 commit bdfe13e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions docs/rules/no-implicit-coercion.md
Expand Up @@ -109,20 +109,34 @@ foo = String(foo);

### templateString

Examples of **incorrect** code for the default `{ "templateString": true }` option:
Examples of **incorrect** code for the `{ "templateString": true }` option:

```js
/*eslint no-implicit-coercion: "error"*/
/*eslint no-implicit-coercion: ["error", { "templateString": true }]*/

`${foo}`;
var s = `${foo}`;
```

Examples of **correct** code for the `{ "templateString": true }` option:

```js
/*eslint no-implicit-coercion: ["error", { "templateString": true }]*/

var s = String(foo);

var s = `a${foo}`;

var s = `${foo}b`;

var s = `${foo}${bar}`;
```

Examples of **correct** code for the default `{ "templateString": false }` option:

```js
/*eslint no-implicit-coercion: "error"*/
/*eslint no-implicit-coercion: ["error", { "templateString": false }]*/

`${foo}`;
var s = `${foo}`;
```

### allow
Expand Down

0 comments on commit bdfe13e

Please sign in to comment.