@@ -147,7 +147,8 @@ function getDOMPropertyNames(context) {
147
147
// ------------------------------------------------------------------------------
148
148
149
149
/**
150
- * Checks if a node matches the JSX tag convention.
150
+ * Checks if a node matches the JSX tag convention. This also checks if a node
151
+ * is extended as a webcomponent using the attribute "is".
151
152
* @param {Object } node - JSX element being tested.
152
153
* @returns {boolean } Whether or not the node name match the JSX tag convention.
153
154
*/
@@ -194,7 +195,7 @@ function tagNameHasDot(node) {
194
195
* Get the standard name of the attribute.
195
196
* @param {String } name - Name of the attribute.
196
197
* @param {String } context - eslint context
197
- * @returns {String } The standard name of the attribute.
198
+ * @returns {String | undefined } The standard name of the attribute, or undefined if no standard name was found .
198
199
*/
199
200
function getStandardName ( name , context ) {
200
201
if ( DOM_ATTRIBUTE_NAMES [ name ] ) {
@@ -203,13 +204,9 @@ function getStandardName(name, context) {
203
204
if ( SVGDOM_ATTRIBUTE_NAMES [ name ] ) {
204
205
return SVGDOM_ATTRIBUTE_NAMES [ name ] ;
205
206
}
206
- let i = - 1 ;
207
207
const names = getDOMPropertyNames ( context ) ;
208
- const found = names . some ( ( element , index ) => {
209
- i = index ;
210
- return element . toLowerCase ( ) === name ;
211
- } ) ;
212
- return found ? names [ i ] : null ;
208
+ // Let's find a possible attribute match with a case-insensitive search.
209
+ return names . find ( ( element ) => element . toLowerCase ( ) === name . toLowerCase ( ) ) ;
213
210
}
214
211
215
212
// ------------------------------------------------------------------------------
@@ -259,6 +256,8 @@ module.exports = {
259
256
}
260
257
261
258
const tagName = getTagName ( node ) ;
259
+
260
+ // 1. Some attributes are allowed on some tags only.
262
261
const allowedTags = ATTRIBUTE_TAGS_MAP [ name ] ;
263
262
if ( tagName && allowedTags && / [ ^ A - Z ] / . test ( tagName . charAt ( 0 ) ) && allowedTags . indexOf ( tagName ) === - 1 ) {
264
263
context . report ( {
@@ -272,8 +271,12 @@ module.exports = {
272
271
} ) ;
273
272
}
274
273
274
+ // 2. Otherwise, we'll try to find if the attribute is a close version
275
+ // of what we should normally have with React. If yes, we'll report an
276
+ // error. We don't want to report if the input attribute name is the
277
+ // standard name though!
275
278
const standardName = getStandardName ( name , context ) ;
276
- if ( ! isTagName ( node ) || ! standardName ) {
279
+ if ( ! isTagName ( node ) || ! standardName || standardName === name ) {
277
280
return ;
278
281
}
279
282
context . report ( {
0 commit comments