|
1 | 1 | module.exports = { |
2 | | - meta: { |
3 | | - type: 'suggestion', |
4 | | - docs: { |
5 | | - description: 'Disallow the use of the deprecated `andSelf` method', |
6 | | - category: 'jQuery deprecated functions', |
7 | | - recommended: true, |
8 | | - url: 'https://api.jquery.com/andself/' |
| 2 | + meta: { |
| 3 | + type: 'suggestion', |
| 4 | + docs: { |
| 5 | + description: 'Disallow the use of the deprecated `andSelf` method', |
| 6 | + category: 'jQuery deprecated functions', |
| 7 | + recommended: true, |
| 8 | + url: 'https://api.jquery.com/andself/' |
| 9 | + }, |
| 10 | + schema: [], |
| 11 | + messages: { |
| 12 | + andSelf: 'jQuery.andSelf() removed, use jQuery.addBack()' |
| 13 | + } |
9 | 14 | }, |
10 | | - schema: [], |
11 | | - messages: { |
12 | | - andSelf: 'jQuery.andSelf() removed, use jQuery.addBack()' |
13 | | - } |
14 | | - }, |
15 | 15 |
|
16 | | - create: function(context) { |
17 | | - 'use strict'; |
18 | | - var utils = require('./utils.js'); |
| 16 | + /** |
| 17 | + * Executes the function to check if andSelf is used. |
| 18 | + * |
| 19 | + * @param {Object} context |
| 20 | + * @returns {Object} |
| 21 | + */ |
| 22 | + create: function (context) { |
| 23 | + 'use strict'; |
19 | 24 |
|
20 | | - return { |
21 | | - CallExpression: function(node) { |
22 | | - if (node.callee.type !== 'MemberExpression') return; |
23 | | - if (node.callee.property.name !== 'andSelf') return; |
| 25 | + var utils = require('./utils.js'); |
24 | 26 |
|
25 | | - if (utils.isjQuery(node)) { |
26 | | - context.report({ |
27 | | - node: node, |
28 | | - messageId: 'andSelf' |
29 | | - }); |
30 | | - } |
31 | | - } |
32 | | - }; |
33 | | - } |
| 27 | + return { |
| 28 | + /** |
| 29 | + * Checks if andSelf is used in the node and reports it. |
| 30 | + * |
| 31 | + * @param {Object} node - The node to check. |
| 32 | + */ |
| 33 | + CallExpression: function (node) { |
| 34 | + // jscs:disable requireCurlyBraces |
| 35 | + if (node.callee.type !== 'MemberExpression') return; |
| 36 | + |
| 37 | + if (node.callee.property.name !== 'andSelf') return; |
| 38 | + // jscs:enable requireCurlyBraces |
| 39 | + |
| 40 | + if (utils.isjQuery(node)) { |
| 41 | + context.report({ |
| 42 | + node: node, |
| 43 | + messageId: 'andSelf' |
| 44 | + }); |
| 45 | + } |
| 46 | + } |
| 47 | + }; |
| 48 | + } |
34 | 49 | }; |
0 commit comments