44 */
55'use strict' ;
66
7+ var versionUtil = require ( '../util/version' ) ;
8+
79// ------------------------------------------------------------------------------
810// Constants
911// ------------------------------------------------------------------------------
1012
1113var UNKNOWN_MESSAGE = 'Unknown property \'{{name}}\' found, use \'{{standardName}}\' instead' ;
1214
1315var DOM_ATTRIBUTE_NAMES = {
14- // Standard
1516 'accept-charset' : 'acceptCharset' ,
1617 class : 'className' ,
1718 for : 'htmlFor' ,
18- 'http-equiv' : 'httpEquiv' ,
19- // SVG
19+ 'http-equiv' : 'httpEquiv'
20+ } ;
21+
22+ var SVGDOM_ATTRIBUTE_NAMES = {
2023 'clip-path' : 'clipPath' ,
2124 'fill-opacity' : 'fillOpacity' ,
2225 'font-family' : 'fontFamily' ,
@@ -87,13 +90,18 @@ function isTagName(node) {
8790
8891/**
8992 * Get the standard name of the attribute.
93+ * @param {Object } context The current rule context.
9094 * @param {String } name - Name of the attribute.
9195 * @returns {String } The standard name of the attribute.
9296 */
93- function getStandardName ( name ) {
97+ function getStandardName ( context , name ) {
9498 if ( DOM_ATTRIBUTE_NAMES [ name ] ) {
9599 return DOM_ATTRIBUTE_NAMES [ name ] ;
96100 }
101+ // Also check for SVG attribute for React <15
102+ if ( ! versionUtil . test ( context , '15.0.0' ) && SVGDOM_ATTRIBUTE_NAMES [ name ] ) {
103+ return SVGDOM_ATTRIBUTE_NAMES [ name ] ;
104+ }
97105 var i ;
98106 var found = DOM_PROPERTY_NAMES . some ( function ( element , index ) {
99107 i = index ;
@@ -114,7 +122,7 @@ module.exports = function(context) {
114122
115123 JSXAttribute : function ( node ) {
116124 var name = sourceCode . getText ( node . name ) ;
117- var standardName = getStandardName ( name ) ;
125+ var standardName = getStandardName ( context , name ) ;
118126 if ( ! isTagName ( node ) || ! standardName ) {
119127 return ;
120128 }
0 commit comments