don't consider JSXIdentifier HTML tags to be references - fixes #1683

This commit is contained in:
Sebastian McKenzie
2015-06-04 22:23:24 +01:00
parent 0f13097f59
commit 9aa17a6cc2
3 changed files with 28 additions and 1 deletions

View File

@@ -1,9 +1,20 @@
import * as react from "../../../transformation/helpers/react";
import * as t from "../../../types";
export var ReferencedIdentifier = {
types: ["Identifier", "JSXIdentifier"],
checkPath({ node, parent }, opts) {
return (t.isIdentifier(node, opts) || t.isJSXIdentifier(node, opts)) && t.isReferenced(node, parent);
if (!t.isIdentifier(node, opts)) {
if (t.isJSXIdentifier(node, opts)) {
if (react.isCompatTag(node.name)) return false;
} else {
// not a JSXIdentifier or an Identifier
return false;
}
}
// check if node is referenced
return t.isReferenced(node, parent);
}
};