Run prettier
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import path from "path";
|
||||
|
||||
export default function ({ types: t }) {
|
||||
export default function({ types: t }) {
|
||||
function addDisplayName(id, call) {
|
||||
const props = call.arguments[0].properties;
|
||||
let safe = true;
|
||||
@@ -15,12 +15,16 @@ export default function ({ types: t }) {
|
||||
}
|
||||
|
||||
if (safe) {
|
||||
props.unshift(t.objectProperty(t.identifier("displayName"), t.stringLiteral(id)));
|
||||
props.unshift(
|
||||
t.objectProperty(t.identifier("displayName"), t.stringLiteral(id)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");
|
||||
const isCreateClassAddon = (callee) => callee.name === "createReactClass";
|
||||
const isCreateClassCallExpression = t.buildMatchMemberExpression(
|
||||
"React.createClass",
|
||||
);
|
||||
const isCreateClassAddon = callee => callee.name === "createReactClass";
|
||||
|
||||
function isCreateClass(node) {
|
||||
if (!node || !t.isCallExpression(node)) return false;
|
||||
@@ -29,7 +33,9 @@ export default function ({ types: t }) {
|
||||
if (
|
||||
!isCreateClassCallExpression(node.callee) &&
|
||||
!isCreateClassAddon(node.callee)
|
||||
) return false;
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// no call arguments
|
||||
const args = node.arguments;
|
||||
@@ -46,7 +52,10 @@ export default function ({ types: t }) {
|
||||
visitor: {
|
||||
ExportDefaultDeclaration({ node }, state) {
|
||||
if (isCreateClass(node.declaration)) {
|
||||
let displayName = path.basename(state.file.opts.filename, path.extname(state.file.opts.filename));
|
||||
let displayName = path.basename(
|
||||
state.file.opts.filename,
|
||||
path.extname(state.file.opts.filename),
|
||||
);
|
||||
|
||||
// ./{module name}/index.js
|
||||
if (displayName === "index") {
|
||||
@@ -64,7 +73,7 @@ export default function ({ types: t }) {
|
||||
let id;
|
||||
|
||||
// crawl up the ancestry looking for possible candidates for displayName inference
|
||||
path.find(function (path) {
|
||||
path.find(function(path) {
|
||||
if (path.isAssignmentExpression()) {
|
||||
id = path.node.left;
|
||||
} else if (path.isObjectProperty()) {
|
||||
|
||||
Reference in New Issue
Block a user