Skip to content

Commit

Permalink
Rename checkPrivateProperties to checkPrivateFields
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Jul 5, 2023
1 parent eed54a4 commit ebd946e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion acorn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ required):
characters `#!` (as in a shellscript), the first line will be
treated as a comment. Defaults to true when `ecmaVersion` >= 2023.

- **checkPrivateProperties**: By default, the parser will verify that
- **checkPrivateFields**: By default, the parser will verify that
private properties are only used in places where they are valid and
have been declared. Set this to false to turn such checks off.

Expand Down
4 changes: 2 additions & 2 deletions acorn/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pp.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit)
else sawUnary = true
expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression")
} else if (!sawUnary && this.type === tt.privateId) {
if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateProperties) this.unexpected()
if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) this.unexpected()
expr = this.parsePrivateIdent()
// only could be private fields in 'in', such as #x in obj
if (this.type !== tt._in) this.unexpected()
Expand Down Expand Up @@ -1076,7 +1076,7 @@ pp.parsePrivateIdent = function() {
this.finishNode(node, "PrivateIdentifier")

// For validating existence
if (this.options.checkPrivateProperties) {
if (this.options.checkPrivateFields) {
if (this.privateNameStack.length === 0) {
this.raise(node.start, `Private field '#${node.name}' must be declared in an enclosing class`)
} else {
Expand Down
2 changes: 1 addition & 1 deletion acorn/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const defaultOptions = {
// By default, the parser will verify that private properties are
// only used in places where they are valid and have been declared.
// Set this to false to turn such checks off.
checkPrivateProperties: true,
checkPrivateFields: true,
// When `locations` is on, `loc` properties holding objects with
// `start` and `end` properties in `{line, column}` form (with
// line being 1-based and column 0-based) will be attached to the
Expand Down
2 changes: 1 addition & 1 deletion acorn/src/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ pp.enterClassBody = function() {

pp.exitClassBody = function() {
const {declared, used} = this.privateNameStack.pop()
if (!this.options.checkPrivateProperties) return
if (!this.options.checkPrivateFields) return
const len = this.privateNameStack.length
const parent = len === 0 ? null : this.privateNameStack[len - 1]
for (let i = 0; i < used.length; ++i) {
Expand Down

0 comments on commit ebd946e

Please sign in to comment.