source: imaps-frontend/node_modules/eslint-plugin-react/lib/rules/jsx-uses-react.js@ d565449

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

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * @fileoverview Prevent React to be marked as unused
3 * @author Glen Mailer
4 */
5
6'use strict';
7
8const pragmaUtil = require('../util/pragma');
9const docsUrl = require('../util/docsUrl');
10const markVariableAsUsed = require('../util/eslint').markVariableAsUsed;
11
12// ------------------------------------------------------------------------------
13// Rule Definition
14// ------------------------------------------------------------------------------
15
16/** @type {import('eslint').Rule.RuleModule} */
17module.exports = {
18 // eslint-disable-next-line eslint-plugin/prefer-message-ids -- https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/292
19 meta: {
20 docs: {
21 description: 'Disallow React to be incorrectly marked as unused',
22 category: 'Best Practices',
23 recommended: true,
24 url: docsUrl('jsx-uses-react'),
25 },
26 schema: [],
27 },
28
29 create(context) {
30 const pragma = pragmaUtil.getFromContext(context);
31 const fragment = pragmaUtil.getFragmentFromContext(context);
32
33 /**
34 * @param {ASTNode} node
35 * @returns {void}
36 */
37 function handleOpeningElement(node) {
38 markVariableAsUsed(pragma, node, context);
39 }
40 // --------------------------------------------------------------------------
41 // Public
42 // --------------------------------------------------------------------------
43
44 return {
45 JSXOpeningElement: handleOpeningElement,
46 JSXOpeningFragment: handleOpeningElement,
47 JSXFragment(node) {
48 markVariableAsUsed(fragment, node, context);
49 },
50 };
51 },
52};
Note: See TracBrowser for help on using the repository browser.