Add checkPrivateFields: false to acorn parser (#17594)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-06-12 04:52:36 +08:00
1 parent 079aebf8b1
commit 98b7dd03ab
6 files changed
+13 -38

No files matched your search

+6
View File
@@ -16,9 +16,15 @@ import {
const parseOptions = {
ecmaVersion: "latest",
// sourceType: "module",
// onInsertedSemicolon: null,
// onTrailingComma: null,
allowReserved: true,
allowReturnOutsideFunction: true,
// allowImportExportEverywhere: true,
// allowAwaitOutsideFunction: null,
allowSuperOutsideMethod: true,
// allowHashBang: true,
checkPrivateFields: false,
locations: false,
ranges: true,
preserveParens: true,
@@ -1,14 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`optional-chaining.js [acorn] format 1`] = `
"Private field '#x' must be declared in an enclosing class (3:13)
1 | // https://github.com/babel/babel/pull/11669
2 |
> 3 | delete obj?.#x.a
| ^
4 |
Cause: Private field '#x' must be declared in an enclosing class (3:12)"
`;
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`optional-chaining.js [espree] format 1`] = `
"Private field '#x' must be declared in an enclosing class (3:13)
@@ -20,16 +10,6 @@ exports[`optional-chaining.js [espree] format 1`] = `
Cause: Private field '#x' must be declared in an enclosing class"
`;
exports[`optional-chaining.js - {"semi":false} [acorn] format 1`] = `
"Private field '#x' must be declared in an enclosing class (3:13)
1 | // https://github.com/babel/babel/pull/11669
2 |
> 3 | delete obj?.#x.a
| ^
4 |
Cause: Private field '#x' must be declared in an enclosing class (3:12)"
`;
exports[`optional-chaining.js - {"semi":false} [espree] format 1`] = `
"Private field '#x' must be declared in an enclosing class (3:13)
1 | // https://github.com/babel/babel/pull/11669
@@ -1,5 +1,4 @@
const errors = {
acorn: ["optional-chaining.js"],
espree: ["optional-chaining.js"],
};
runFormatTest(import.meta, ["babel"], {
@@ -1,14 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`private-in.js [acorn] format 1`] = `
"Unexpected token (1:5)
> 1 | if (#prop in obj) {
| ^
2 | }
3 |
4 | #prop in obj;
Cause: Unexpected token (1:4)"
`;
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`private-in.js [espree] format 1`] = `
"Unexpected token #prop (1:5)
+1 -1
View File
@@ -1,3 +1,3 @@
runFormatTest(import.meta, ["babel"], {
errors: { acorn: true, espree: true },
errors: { espree: true },
});
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`snippet: #0 [acorn] format 1`] = `
"Cannot use keyword 'await' outside an async function (2:20)
"Unexpected token (2:26)
1 | async function foo() {
> 2 | function bar(x = await 2) {}
| ^
| ^
3 | }
Cause: Cannot use keyword 'await' outside an async function (2:19)"
Cause: Unexpected token (2:25)"
`;
exports[`snippet: #0 [acorn] format 2`] = `