From 6bb160459383a2eeec5d65e3de07e37e997b5f1a Mon Sep 17 00:00:00 2001 From: golopot Date: Tue, 19 Mar 2019 19:36:12 +0800 Subject: [PATCH] [Fix]`no-unknown-property`: fix case like `` Fixes #2204 --- lib/rules/no-unknown-property.js | 19 +++++++++++++++++++ tests/lib/rules/no-unknown-property.js | 1 + 2 files changed, 20 insertions(+) diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js index 5d03286fb7..cc881a8a3b 100644 --- a/lib/rules/no-unknown-property.js +++ b/lib/rules/no-unknown-property.js @@ -167,6 +167,20 @@ function getTagName(node) { return null; } +/** + * Test wether the tag name for the JSXAttribute is + * something like + * @param {JSXAttribute} node - JSXAttribute being tested. + * @returns {Boolean} result + */ +function tagNameHasDot(node) { + return !!( + node.parent && + node.parent.name && + node.parent.name.type === 'JSXMemberExpression' + ); +} + /** * Get the standard name of the attribute. * @param {String} name - Name of the attribute. @@ -231,6 +245,11 @@ module.exports = { return; } + // Ignore tags like + if (tagNameHasDot(node)) { + return; + } + const tagName = getTagName(node); const allowedTags = ATTRIBUTE_TAGS_MAP[name]; if (tagName && allowedTags && /[^A-Z]/.test(tagName.charAt(0)) && allowedTags.indexOf(tagName) === -1) { diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js index ea94c86717..65fd9dcb16 100644 --- a/tests/lib/rules/no-unknown-property.js +++ b/tests/lib/rules/no-unknown-property.js @@ -29,6 +29,7 @@ ruleTester.run('no-unknown-property', rule, { valid: [ {code: ';'}, {code: ';'}, + {code: ';'}, {code: ';'}, {code: ';'}, {code: ';'},