mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
/**
|
|
* @fileoverview Prevent usage of findDOMNode
|
|
* @author Yannick Croissant
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const docsUrl = require('../util/docsUrl');
|
|
|
|
// ------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
// ------------------------------------------------------------------------------
|
|
|
|
module.exports = {
|
|
meta: {
|
|
docs: {
|
|
description: 'Prevent usage of findDOMNode',
|
|
category: 'Best Practices',
|
|
recommended: true,
|
|
url: docsUrl('no-find-dom-node')
|
|
},
|
|
schema: []
|
|
},
|
|
|
|
create(context) {
|
|
// --------------------------------------------------------------------------
|
|
// Public
|
|
// --------------------------------------------------------------------------
|
|
|
|
return {
|
|
|
|
CallExpression(node) {
|
|
const callee = node.callee;
|
|
|
|
const isfindDOMNode = (callee.name === 'findDOMNode') ||
|
|
(callee.property && callee.property.name === 'findDOMNode');
|
|
if (!isfindDOMNode) {
|
|
return;
|
|
}
|
|
|
|
context.report({
|
|
node: callee,
|
|
message: 'Do not use findDOMNode'
|
|
});
|
|
}
|
|
};
|
|
}
|
|
};
|