Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Dec 31, 2020
1 parent f8fe6ac commit ea67473
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function needAddParenthesesToMemberExpressionObject(node, sourceCode) {
case "MemberExpression":
case "CallExpression":
case "ChainExpression":
case "TemplateLiteral":
return false;
case "NewExpression": {
// `new Foo.bar` is different with `new Foo().bar`
Expand Down
2 changes: 2 additions & 0 deletions test/prefer-string-starts-ends-with.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,7 @@ test.visualize([
'/^a/.test(new SomeString())',
'/^a/.test(foo?.bar)',
'/^a/.test(foo?.bar())',
'/^a/.test(`string`)',
'/^a/.test(tagged`string`)',
'(/^a/).test((0, "string"))'
]);
32 changes: 32 additions & 0 deletions test/snapshots/prefer-string-starts-ends-with.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,38 @@ Generated by [AVA](https://avajs.dev).

## prefer-string-starts-ends-with - #9

> Snapshot 1
`␊
Input:␊
1 | /^a/.test(`string`)␊
Output:␊
1 | `string`.startsWith('a')␊
Error 1/1:␊
> 1 | /^a/.test(`string`)␊
| ^^^^^^^^^^^^^^^^^^^ Prefer `String#startsWith()` over a regex with `^`.␊
`

## prefer-string-starts-ends-with - #10

> Snapshot 1
`␊
Input:␊
1 | /^a/.test(tagged`string`)␊
Output:␊
1 | (tagged`string`).startsWith('a')␊
Error 1/1:␊
> 1 | /^a/.test(tagged`string`)␊
| ^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `String#startsWith()` over a regex with `^`.␊
`

## prefer-string-starts-ends-with - #11

> Snapshot 1
`␊
Expand Down
Binary file modified test/snapshots/prefer-string-starts-ends-with.js.snap
Binary file not shown.

0 comments on commit ea67473

Please sign in to comment.