source: imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-is-mounted.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[d565449]1/**
2 * @fileoverview Prevent usage of isMounted
3 * @author Joe Lencioni
4 */
5
6'use strict';
7
8const docsUrl = require('../util/docsUrl');
9const getAncestors = require('../util/eslint').getAncestors;
10const report = require('../util/report');
11
12// ------------------------------------------------------------------------------
13// Rule Definition
14// ------------------------------------------------------------------------------
15
16const messages = {
17 noIsMounted: 'Do not use isMounted',
18};
19
20module.exports = {
21 meta: {
22 docs: {
23 description: 'Disallow usage of isMounted',
24 category: 'Best Practices',
25 recommended: true,
26 url: docsUrl('no-is-mounted'),
27 },
28
29 messages,
30
31 schema: [],
32 },
33
34 create(context) {
35 return {
36 CallExpression(node) {
37 const callee = node.callee;
38 if (callee.type !== 'MemberExpression') {
39 return;
40 }
41 if (callee.object.type !== 'ThisExpression' || callee.property.name !== 'isMounted') {
42 return;
43 }
44 const ancestors = getAncestors(context, node);
45 for (let i = 0, j = ancestors.length; i < j; i++) {
46 if (ancestors[i].type === 'Property' || ancestors[i].type === 'MethodDefinition') {
47 report(context, messages.noIsMounted, 'noIsMounted', {
48 node: callee,
49 });
50 break;
51 }
52 }
53 },
54 };
55 },
56};
Note: See TracBrowser for help on using the repository browser.