Blame view
node_modules/eslint-plugin-react/lib/util/pragma.js
891 Bytes
c39994410
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/** * @fileoverview Utility functions for React pragma configuration * @author Yannick Croissant */ 'use strict'; var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/; function getFromContext(context) { var pragma = 'React'; // .eslintrc shared settings (http://eslint.org/docs/user-guide/configuring#adding-shared-settings) if (context.settings.react && context.settings.react.pragma) { pragma = context.settings.react.pragma; // Deprecated pragma option, here for backward compatibility } else if (context.options[0] && context.options[0].pragma) { pragma = context.options[0].pragma; } return pragma.split('.')[0]; } function getFromNode(node) { var matches = JSX_ANNOTATION_REGEX.exec(node.value); if (!matches) { return false; } return matches[1].split('.')[0]; } module.exports = { getFromContext: getFromContext, getFromNode: getFromNode }; |