Skip to content

Commit

Permalink
Merge branch 'main' into improve-using
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Dec 28, 2023
2 parents d58b250 + 365aa94 commit f98d8d3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion eslint.config.js
Expand Up @@ -88,7 +88,7 @@ module.exports = [
parser: parserTypeScriptESLint,
parserOptions: {
allowAutomaticSingleRunInference: true,
project: "./tsconfig.eslint.json",
EXPERIMENTAL_useProjectService: true,
},
},
plugins: {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-helpers/src/helpers/setFunctionName.ts
Expand Up @@ -8,7 +8,7 @@ export default function setFunctionName<T extends Function>(
): T {
if (typeof name === "symbol") {
name = name.description;
name = name ? "[" + (name as string) + "]" : "";
name = name ? "[" + name + "]" : "";
}
// In some older browsers .name was non-configurable, here we catch any
// errors thrown by defineProperty.
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-proposal-import-defer/src/index.ts
Expand Up @@ -95,7 +95,7 @@ export default declare(api => {
(child.isExportNamedDeclaration() && child.node.source !== null) ||
child.isExportAllDeclaration()
) {
const specifier = child.node.source!.value;
const specifier = child.node.source.value;
if (!eagerImports.has(specifier)) {
eagerImports.add(specifier);
}
Expand Down
6 changes: 4 additions & 2 deletions packages/babel-traverse/src/path/removal.ts
Expand Up @@ -30,8 +30,10 @@ export function _removeFromScope(this: NodePath) {
}

export function _callRemovalHooks(this: NodePath) {
for (const fn of hooks) {
if (fn(this, this.parentPath)) return true;
if (this.parentPath) {
for (const fn of hooks) {
if (fn(this, this.parentPath)) return true;
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions packages/babel-traverse/test/removal.js
Expand Up @@ -152,4 +152,17 @@ describe("removal", function () {

expect(rootPath.scope.hasBinding("x")).toBe(true);
});

it("should not throw when removing without `Program`", function () {
const ast = parse("['1']").program.body[0].expression;

traverse(ast, {
noScope: true,
StringLiteral(path) {
path.remove();
},
});

expect(ast.elements.length).toBe(0);
});
});
6 changes: 0 additions & 6 deletions tsconfig.eslint.json

This file was deleted.

0 comments on commit f98d8d3

Please sign in to comment.