-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathno-bind.js
38 lines (33 loc) · 995 Bytes
/
no-bind.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
34
35
36
37
38
'use strict';
const rule = require( '../../src/rules/no-bind' );
const RuleTester = require( '../../tools/rule-tester' );
const bindError = 'Prefer .on/EventTarget#addEventListener to .bind';
const unbindError = 'Prefer .off/EventTarget#removeEventListener to .unbind';
const ruleTester = new RuleTester();
ruleTester.run( 'no-bind', rule, {
valid: [
'bind()',
'[].bind()',
'div.bind()',
'div.bind',
'$div.remove.bind($div)',
'unbind()',
'[].unbind()',
'div.unbind()',
'div.unbind',
'$div.remove.unbind($div)'
],
invalid: [
[ '$("div").bind()', bindError ],
[ '$div.bind()', bindError ],
[ '$("div").first().bind()', bindError ],
[ '$("div").append($("input").bind())', bindError ],
[ '$("div").unbind()', unbindError ],
[ '$div.unbind()', unbindError ],
[ '$("div").first().unbind()', unbindError ],
[ '$("div").append($("input").unbind())', unbindError ]
].map( ( codeError ) => ( {
code: codeError[ 0 ],
errors: [ codeError[ 1 ] ]
} ) )
} );