source: imaps-frontend/node_modules/eslint-plugin-react/lib/rules/no-find-dom-node.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.2 KB
Line 
1/**
2 * @fileoverview Prevent usage of findDOMNode
3 * @author Yannick Croissant
4 */
5
6'use strict';
7
8const docsUrl = require('../util/docsUrl');
9const report = require('../util/report');
10
11// ------------------------------------------------------------------------------
12// Rule Definition
13// ------------------------------------------------------------------------------
14
15const messages = {
16 noFindDOMNode: 'Do not use findDOMNode. It doesn’t work with function components and is deprecated in StrictMode. See https://reactjs.org/docs/react-dom.html#finddomnode',
17};
18
19module.exports = {
20 meta: {
21 docs: {
22 description: 'Disallow usage of findDOMNode',
23 category: 'Best Practices',
24 recommended: true,
25 url: docsUrl('no-find-dom-node'),
26 },
27
28 messages,
29
30 schema: [],
31 },
32
33 create(context) {
34 return {
35 CallExpression(node) {
36 const callee = node.callee;
37
38 const isfindDOMNode = (callee.name === 'findDOMNode')
39 || (callee.property && callee.property.name === 'findDOMNode');
40 if (!isfindDOMNode) {
41 return;
42 }
43
44 report(context, messages.noFindDOMNode, 'noFindDOMNode', {
45 node: callee,
46 });
47 },
48 };
49 },
50};
Note: See TracBrowser for help on using the repository browser.