katoikia-app/web-ui/web-react/node_modules/eslint-plugin-react/lib/rules/jsx-uses-react.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2022-07-06 04:15:11 +00:00
/**
* @fileoverview Prevent React to be marked as unused
* @author Glen Mailer
*/
'use strict';
const pragmaUtil = require('../util/pragma');
const docsUrl = require('../util/docsUrl');
// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
module.exports = {
meta: {
docs: {
description: 'Prevent React to be marked as unused',
category: 'Best Practices',
recommended: true,
url: docsUrl('jsx-uses-react')
},
schema: []
},
create(context) {
const pragma = pragmaUtil.getFromContext(context);
function handleOpeningElement() {
context.markVariableAsUsed(pragma);
}
// --------------------------------------------------------------------------
// Public
// --------------------------------------------------------------------------
return {
JSXOpeningElement: handleOpeningElement,
JSXOpeningFragment: handleOpeningElement
};
}
};