d4fe53165b39ba1348b7629db2b9923458713e92
[platform/framework/web/crosswalk-tizen.git] /
1 /**
2  * @fileoverview Prevent React to be marked as unused
3  * @author Glen Mailer
4  */
5 'use strict';
6
7 var variableUtil = require('../util/variable');
8
9 // ------------------------------------------------------------------------------
10 // Rule Definition
11 // ------------------------------------------------------------------------------
12
13 var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
14
15 module.exports = function(context) {
16
17   var id = 'React';
18
19   // --------------------------------------------------------------------------
20   // Public
21   // --------------------------------------------------------------------------
22
23   return {
24
25     JSXOpeningElement: function() {
26       variableUtil.markVariableAsUsed(context, id);
27     },
28
29     BlockComment: function(node) {
30       var matches = JSX_ANNOTATION_REGEX.exec(node.value);
31       if (!matches) {
32         return;
33       }
34       id = matches[1].split('.')[0];
35     }
36
37   };
38
39 };