Use named imports for babel types (#13685)

* migrate to named babel types imports

* perf: transform babel types import to destructuring

* fix merge errors

* apply plugin to itself
This commit is contained in:
Huáng Jùnliàng
2021-08-18 10:28:40 -04:00
committed by GitHub
parent fc66d4dd05
commit 614b486780
65 changed files with 1283 additions and 787 deletions

View File

@@ -1,12 +1,13 @@
import * as whitespace from "./whitespace";
import * as parens from "./parentheses";
import * as t from "@babel/types";
const {
import {
FLIPPED_ALIAS_KEYS,
isCallExpression,
isExpressionStatement,
isMemberExpression,
isNewExpression,
} = t;
} from "@babel/types";
function expandAliases(obj) {
const newObj = {};
@@ -22,7 +23,7 @@ function expandAliases(obj) {
}
for (const type of Object.keys(obj)) {
const aliases = t.FLIPPED_ALIAS_KEYS[type];
const aliases = FLIPPED_ALIAS_KEYS[type];
if (aliases) {
for (const alias of aliases) {
add(alias, obj[type]);

View File

@@ -1,6 +1,4 @@
import * as t from "@babel/types";
const {
import {
isArrayTypeAnnotation,
isArrowFunctionExpression,
isAssignmentExpression,
@@ -48,7 +46,8 @@ const {
isVariableDeclarator,
isWhileStatement,
isYieldExpression,
} = t;
} from "@babel/types";
import type * as t from "@babel/types";
const PRECEDENCE = {
"||": 0,
"??": 0,

View File

@@ -1,6 +1,5 @@
import * as t from "@babel/types";
const {
import {
FLIPPED_ALIAS_KEYS,
isArrayExpression,
isAssignmentExpression,
isBinary,
@@ -14,7 +13,9 @@ const {
isOptionalCallExpression,
isOptionalMemberExpression,
isStringLiteral,
} = t;
} from "@babel/types";
import type * as t from "@babel/types";
type WhitespaceObject = {
before?: boolean;
after?: boolean;
@@ -319,7 +320,7 @@ export const list = {
amounts = { after: amounts, before: amounts };
}
[type as string]
.concat(t.FLIPPED_ALIAS_KEYS[type] || [])
.concat(FLIPPED_ALIAS_KEYS[type] || [])
.forEach(function (type) {
nodes[type] = function () {
return amounts;