forked from sindresorhus/eslint-plugin-unicorn
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefer-includes.js
33 lines (32 loc) · 908 Bytes
/
prefer-includes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {test} from './utils/test.js';
test.snapshot({
valid: [
'str.indexOf(\'foo\') !== -n',
'str.indexOf(\'foo\') !== 1',
'str.indexOf(\'foo\') === -2',
'!str.indexOf(\'foo\') === 1',
'!str.indexOf(\'foo\') === -n',
'str.includes(\'foo\')',
'\'foobar\'.includes(\'foo\')',
'[1,2,3].includes(4)',
'null.indexOf(\'foo\') !== 1',
'f(0) < 0',
'something.indexOf(foo, 0, another) !== -1',
'_.indexOf(foo, bar) !== -1',
'lodash.indexOf(foo, bar) !== -1',
'underscore.indexOf(foo, bar) !== -1'
],
invalid: [
'\'foobar\'.indexOf(\'foo\') !== -1',
'str.indexOf(\'foo\') != -1',
'str.indexOf(\'foo\') > -1',
'str.indexOf(\'foo\') == -1',
'\'foobar\'.indexOf(\'foo\') >= 0',
'[1,2,3].indexOf(4) !== -1',
'str.indexOf(\'foo\') < 0',
'\'\'.indexOf(\'foo\') < 0',
'(a || b).indexOf(\'foo\') === -1',
'foo.indexOf(bar, 0) !== -1',
'foo.indexOf(bar, 1) !== -1'
]
});