@@ -2,7 +2,7 @@ module.exports = {
2
2
meta : {
3
3
type : 'suggestion' ,
4
4
docs : {
5
- description : 'Disallow the use of shorthand methods' ,
5
+ description : 'Disallow the use of shorthand event methods' ,
6
6
category : 'jQuery deprecated functions' ,
7
7
recommended : true ,
8
8
url : 'https://api.jquery.com/load/'
@@ -11,7 +11,7 @@ module.exports = {
11
11
} ,
12
12
13
13
/**
14
- * Executes the function to check if shorthand methods are used.
14
+ * Executes the function to check if shorthand event methods are used.
15
15
*
16
16
* @param {Object } context
17
17
* @returns {Object }
@@ -23,23 +23,28 @@ module.exports = {
23
23
24
24
return {
25
25
/**
26
- * Checks if shorthand methods are used and reports it .
26
+ * Checks if shorthand event methods are used.
27
27
*
28
28
* @param {Object } node - The node to check.
29
29
*/
30
30
CallExpression : function ( node ) {
31
- var names = [ 'load' , 'unload' , 'error' ] ,
32
- name ;
31
+ var namesToMsg = {
32
+ 'unload' : 'jQuery.unload() was removed, use .on("unload", fn) instead.' ,
33
+ 'ready' : 'jQuery.ready(handler) is deprecated and should be replaced with jQuery(handler)'
34
+ } ,
35
+ name ,
36
+ message ;
33
37
34
38
if ( node . callee . type !== 'MemberExpression' ) { return ; }
35
39
36
- if ( ! names . includes ( node . callee . property . name ) ) { return ; }
40
+ name = node . callee . property . name ;
41
+ if ( ! namesToMsg . hasOwnProperty ( name ) ) { return ; }
42
+ message = namesToMsg [ name ] ;
37
43
38
44
if ( utils . isjQuery ( node ) ) {
39
- name = node . callee . property . name ;
40
45
context . report ( {
41
46
node : node ,
42
- message : 'jQuery.' + name + '() was removed, use .on("' + name + '", fn) instead.'
47
+ message : message
43
48
} ) ;
44
49
}
45
50
}
0 commit comments