jsx-uses-react.js 983 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * @fileoverview Prevent React to be marked as unused
  3. * @author Glen Mailer
  4. */
  5. 'use strict';
  6. const pragmaUtil = require('../util/pragma');
  7. const docsUrl = require('../util/docsUrl');
  8. // ------------------------------------------------------------------------------
  9. // Rule Definition
  10. // ------------------------------------------------------------------------------
  11. module.exports = {
  12. meta: {
  13. docs: {
  14. description: 'Prevent React to be marked as unused',
  15. category: 'Best Practices',
  16. recommended: true,
  17. url: docsUrl('jsx-uses-react')
  18. },
  19. schema: []
  20. },
  21. create: function(context) {
  22. const pragma = pragmaUtil.getFromContext(context);
  23. // --------------------------------------------------------------------------
  24. // Public
  25. // --------------------------------------------------------------------------
  26. return {
  27. JSXOpeningElement: function() {
  28. context.markVariableAsUsed(pragma);
  29. }
  30. };
  31. }
  32. };