10
10
11
11
module . exports = function ( context ) {
12
12
13
- // HTML5 and SVG elements whitelist
14
- var standardElements = [
15
- 'a' , 'abbr' , 'address' , 'area' , 'article' , 'aside' , 'audio' , 'b' , 'base' , 'bdi' , 'bdo' , 'big' , 'blockquote' , 'body' ,
16
- 'br' , 'button' , 'canvas' , 'caption' , 'cite' , 'code' , 'col' , 'colgroup' , 'data' , 'datalist' , 'dd' , 'del' , 'details' ,
17
- 'dfn' , 'dialog' , 'div' , 'dl' , 'dt' , 'em' , 'embed' , 'fieldset' , 'figcaption' , 'figure' , 'footer' , 'form' , 'h1' , 'h2' ,
18
- 'h3' , 'h4' , 'h5' , 'h6' , 'head' , 'header' , 'hr' , 'html' , 'i' , 'iframe' , 'img' , 'input' , 'ins' , 'kbd' , 'keygen' ,
19
- 'label' , 'legend' , 'li' , 'link' , 'main' , 'map' , 'mark' , 'menu' , 'menuitem' , 'meta' , 'meter' , 'nav' , 'noscript' ,
20
- 'object' , 'ol' , 'optgroup' , 'option' , 'output' , 'p' , 'param' , 'picture' , 'pre' , 'progress' , 'q' , 'rp' , 'rt' , 'ruby' ,
21
- 's' , 'samp' , 'script' , 'section' , 'select' , 'small' , 'source' , 'span' , 'strong' , 'style' , 'sub' , 'summary' , 'sup' ,
22
- 'table' , 'tbody' , 'td' , 'textarea' , 'tfoot' , 'th' , 'thead' , 'time' , 'title' , 'tr' , 'track' , 'u' , 'ul' , 'var' ,
23
- 'video' , 'wbr' , 'circle' , 'defs' , 'ellipse' , 'g' , 'line' , 'linearGradient' , 'mask' , 'path' , 'pattern' , 'polygon' ,
24
- 'polyline' , 'radialGradient' , 'rect' , 'stop' , 'svg' , 'text' , 'tspan'
25
- ] ;
13
+ var tagConvention = / ^ [ a - z ] | \- / ;
14
+ function isTagName ( name ) {
15
+ return tagConvention . test ( name ) ;
16
+ }
26
17
27
18
function isComponent ( node ) {
28
- return node . name && node . name . type === 'XJSIdentifier ' && standardElements . indexOf ( node . name . name ) === - 1 ;
19
+ return node . name && node . name . type === 'JSXIdentifier ' && ! isTagName ( node . name . name ) ;
29
20
}
30
21
31
22
function hasChildren ( node ) {
@@ -44,7 +35,7 @@ module.exports = function(context) {
44
35
45
36
return {
46
37
47
- 'XJSOpeningElement ' : function ( node ) {
38
+ 'JSXOpeningElement ' : function ( node ) {
48
39
if ( ! isComponent ( node ) || node . selfClosing || hasChildren ( node ) ) {
49
40
return ;
50
41
}
0 commit comments