add more plugins, rename some

This commit is contained in:
Sebastian McKenzie
2015-09-15 06:12:46 +01:00
parent 3e8cbc60eb
commit 9969224a93
328 changed files with 2013 additions and 1543 deletions

View File

@@ -0,0 +1,42 @@
export default function () {
var immutabilityVisitor = {
enter(path, state) {
var stop = () => {
state.isImmutable = false;
path.stop();
};
if (path.isJSXClosingElement()) {
path.skip();
return;
}
if (path.isJSXIdentifier({ name: "ref" }) && path.parentPath.isJSXAttribute({ name: path.node })) {
return stop();
}
if (path.isJSXIdentifier() || path.isIdentifier() || path.isJSXMemberExpression()) {
return;
}
if (!path.isImmutable()) stop();
}
};
return {
visitor: {
JSXElement(path) {
if (path.node._hoisted) return;
var state = { isImmutable: true };
path.traverse(immutabilityVisitor, state);
if (state.isImmutable) {
path.hoist();
} else {
path.node._hoisted = true;
}
}
}
};
}