orionsoft-react-scripts
Version:
Orionsoft Configuration and scripts for Create React App.
45 lines (33 loc) • 1 kB
JavaScript
/**
* @fileoverview Prevent React to be marked as unused
* @author Glen Mailer
*/
;
var pragmaUtil = require('../util/pragma');
// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
module.exports = {
meta: {
docs: {
description: 'Prevent React to be marked as unused',
category: 'Best Practices',
recommended: true
},
schema: []
},
create: function(context) {
var pragma = pragmaUtil.getFromContext(context);
// --------------------------------------------------------------------------
// Public
// --------------------------------------------------------------------------
return {
JSXOpeningElement: function() {
context.markVariableAsUsed(pragma);
},
BlockComment: function(node) {
pragma = pragmaUtil.getFromNode(node) || pragma;
}
};
}
};