UNPKG

charlike

Version:

Small, fast, simple and streaming project scaffolder for myself, but not only. Supports hundreds of template engines through the @JSTransformers API or if you want custom `render` function passed through options

45 lines (33 loc) 1 kB
/** * @fileoverview Prevent React to be marked as unused * @author Glen Mailer */ 'use strict'; 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; } }; } };