Skip to content

Commit 15f9028

Browse files
authored
require-array-join-separator: Check optional member (#1569)
1 parent ff43745 commit 15f9028

4 files changed

+24
-2
lines changed

rules/require-array-join-separator.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ const messages = {
99

1010
const selector = matches([
1111
// `foo.join()`
12-
methodCallSelector({method: 'join', argumentsLength: 0}),
12+
methodCallSelector({
13+
method: 'join',
14+
argumentsLength: 0,
15+
includeOptionalMember: true,
16+
}),
1317
// `[].join.call(foo)` and `Array.prototype.join.call(foo)`
1418
[
1519
methodCallSelector({method: 'call', argumentsLength: 1}),

test/require-array-join-separator.mjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ test.snapshot({
88
'foo.join(",")',
99
'join()',
1010
'foo.join(...[])',
11-
'foo?.join()',
11+
'foo.join?.()',
12+
'foo?.join?.()',
1213
'foo[join]()',
1314
'foo["join"]()',
1415
'[].join.call(foo, ",")',
@@ -71,5 +72,6 @@ test.snapshot({
7172
)/**/
7273
)
7374
`,
75+
'foo?.join()',
7476
],
7577
});

test/snapshots/require-array-join-separator.mjs.md

+16
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,19 @@ Generated by [AVA](https://avajs.dev).
192192
| ^^^^ Missing the separator argument.␊
193193
26 | )␊
194194
`
195+
196+
## Invalid #8
197+
1 | foo?.join()
198+
199+
> Output
200+
201+
`␊
202+
1 | foo?.join(',')␊
203+
`
204+
205+
> Error 1/1
206+
207+
`␊
208+
> 1 | foo?.join()␊
209+
| ^^ Missing the separator argument.␊
210+
`
Binary file not shown.

0 commit comments

Comments
 (0)