| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 01eaccc commit 59fca4e
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,9 @@ | |||
| 1 | + ## 8.10.0 (2023-07-05) | ||
| 2 | + | ||
| 3 | + ### New features | ||
| 4 | + | ||
| 5 | + Add a `checkPrivateFields` option that disables strict checking of private property use. | ||
| 6 | + | ||
| 1 | 7 | ## 8.9.0 (2023-06-16) | |
| 2 | 8 | ||
| 3 | 9 | ### Bug fixes | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,6 +109,10 @@ required): | |||
| 109 | 109 | characters `#!` (as in a shellscript), the first line will be | |
| 110 | 110 | treated as a comment. Defaults to true when `ecmaVersion` >= 2023. | |
| 111 | 111 | ||
| 112 | + - **checkPrivateFields**: By default, the parser will verify that | ||
| 113 | + private properties are only used in places where they are valid and | ||
| 114 | + have been declared. Set this to false to turn such checks off. | ||
| 115 | + | ||
| 112 | 116 | - **locations**: When `true`, each node has a `loc` object attached | |
| 113 | 117 | with `start` and `end` subobjects, each of which contains the | |
| 114 | 118 | one-based line and zero-based column numbers in `{line, column}` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ declare namespace acorn { | |||
| 11 | 11 | [Symbol.iterator](): Iterator<Token> | |
| 12 | 12 | } | |
| 13 | 13 | ||
| 14 | - type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 'latest' | ||
| 14 | + type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 'latest' | ||
| 15 | 15 | ||
| 16 | 16 | interface Options { | |
| 17 | 17 | ecmaVersion: ecmaVersion | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -372,6 +372,10 @@ | |||
| 372 | 372 | // allowed and treated as a line comment. Enabled by default when | |
| 373 | 373 | // `ecmaVersion` >= 2023. | |
| 374 | 374 | allowHashBang: false, | |
| 375 | + // By default, the parser will verify that private properties are | ||
| 376 | + // only used in places where they are valid and have been declared. | ||
| 377 | + // Set this to false to turn such checks off. | ||
| 378 | + checkPrivateFields: true, | ||
| 375 | 379 | // When `locations` is on, `loc` properties holding objects with | |
| 376 | 380 | // `start` and `end` properties in `{line, column}` form (with | |
| 377 | 381 | // line being 1-based and column 0-based) will be attached to the | |
@@ -1600,6 +1604,7 @@ | |||
| 1600 | 1604 | var ref = this.privateNameStack.pop(); | |
| 1601 | 1605 | var declared = ref.declared; | |
| 1602 | 1606 | var used = ref.used; | |
| 1607 | + if (!this.options.checkPrivateFields) { return } | ||
| 1603 | 1608 | var len = this.privateNameStack.length; | |
| 1604 | 1609 | var parent = len === 0 ? null : this.privateNameStack[len - 1]; | |
| 1605 | 1610 | for (var i = 0; i < used.length; ++i) { | |
@@ -2661,7 +2666,7 @@ | |||
| 2661 | 2666 | else { sawUnary = true; } | |
| 2662 | 2667 | expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); | |
| 2663 | 2668 | } else if (!sawUnary && this.type === types$1.privateId) { | |
| 2664 | - if (forInit || this.privateNameStack.length === 0) { this.unexpected(); } | ||
| 2669 | + if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); } | ||
| 2665 | 2670 | expr = this.parsePrivateIdent(); | |
| 2666 | 2671 | // only could be private fields in 'in', such as #x in obj | |
| 2667 | 2672 | if (this.type !== types$1._in) { this.unexpected(); } | |
@@ -3504,10 +3509,12 @@ | |||
| 3504 | 3509 | this.finishNode(node, "PrivateIdentifier"); | |
| 3505 | 3510 | ||
| 3506 | 3511 | // For validating existence | |
| 3507 | - if (this.privateNameStack.length === 0) { | ||
| 3508 | - this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); | ||
| 3509 | - } else { | ||
| 3510 | - this.privateNameStack[this.privateNameStack.length - 1].used.push(node); | ||
| 3512 | + if (this.options.checkPrivateFields) { | ||
| 3513 | + if (this.privateNameStack.length === 0) { | ||
| 3514 | + this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); | ||
| 3515 | + } else { | ||
| 3516 | + this.privateNameStack[this.privateNameStack.length - 1].used.push(node); | ||
| 3517 | + } | ||
| 3511 | 3518 | } | |
| 3512 | 3519 | ||
| 3513 | 3520 | return node | |
@@ -5907,7 +5914,7 @@ | |||
| 5907 | 5914 | // [walk]: util/walk.js | |
| 5908 | 5915 | ||
| 5909 | 5916 | ||
| 5910 | - var version = "8.9.0"; | ||
| 5917 | + var version = "8.10.0"; | ||
| 5911 | 5918 | ||
| 5912 | 5919 | Parser.acorn = { | |
| 5913 | 5920 | Parser: Parser, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -366,6 +366,10 @@ var defaultOptions = { | |||
| 366 | 366 | // allowed and treated as a line comment. Enabled by default when | |
| 367 | 367 | // `ecmaVersion` >= 2023. | |
| 368 | 368 | allowHashBang: false, | |
| 369 | + // By default, the parser will verify that private properties are | ||
| 370 | + // only used in places where they are valid and have been declared. | ||
| 371 | + // Set this to false to turn such checks off. | ||
| 372 | + checkPrivateFields: true, | ||
| 369 | 373 | // When `locations` is on, `loc` properties holding objects with | |
| 370 | 374 | // `start` and `end` properties in `{line, column}` form (with | |
| 371 | 375 | // line being 1-based and column 0-based) will be attached to the | |
@@ -1594,6 +1598,7 @@ pp$8.exitClassBody = function() { | |||
| 1594 | 1598 | var ref = this.privateNameStack.pop(); | |
| 1595 | 1599 | var declared = ref.declared; | |
| 1596 | 1600 | var used = ref.used; | |
| 1601 | + if (!this.options.checkPrivateFields) { return } | ||
| 1597 | 1602 | var len = this.privateNameStack.length; | |
| 1598 | 1603 | var parent = len === 0 ? null : this.privateNameStack[len - 1]; | |
| 1599 | 1604 | for (var i = 0; i < used.length; ++i) { | |
@@ -2655,7 +2660,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni | |||
| 2655 | 2660 | else { sawUnary = true; } | |
| 2656 | 2661 | expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); | |
| 2657 | 2662 | } else if (!sawUnary && this.type === types$1.privateId) { | |
| 2658 | - if (forInit || this.privateNameStack.length === 0) { this.unexpected(); } | ||
| 2663 | + if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); } | ||
| 2659 | 2664 | expr = this.parsePrivateIdent(); | |
| 2660 | 2665 | // only could be private fields in 'in', such as #x in obj | |
| 2661 | 2666 | if (this.type !== types$1._in) { this.unexpected(); } | |
@@ -3498,10 +3503,12 @@ pp$5.parsePrivateIdent = function() { | |||
| 3498 | 3503 | this.finishNode(node, "PrivateIdentifier"); | |
| 3499 | 3504 | ||
| 3500 | 3505 | // For validating existence | |
| 3501 | - if (this.privateNameStack.length === 0) { | ||
| 3502 | - this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); | ||
| 3503 | - } else { | ||
| 3504 | - this.privateNameStack[this.privateNameStack.length - 1].used.push(node); | ||
| 3506 | + if (this.options.checkPrivateFields) { | ||
| 3507 | + if (this.privateNameStack.length === 0) { | ||
| 3508 | + this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); | ||
| 3509 | + } else { | ||
| 3510 | + this.privateNameStack[this.privateNameStack.length - 1].used.push(node); | ||
| 3511 | + } | ||
| 3505 | 3512 | } | |
| 3506 | 3513 | ||
| 3507 | 3514 | return node | |
@@ -5901,7 +5908,7 @@ pp.readWord = function() { | |||
| 5901 | 5908 | // [walk]: util/walk.js | |
| 5902 | 5909 | ||
| 5903 | 5910 | ||
| 5904 | - var version = "8.9.0"; | ||
| 5911 | + var version = "8.10.0"; | ||
| 5905 | 5912 | ||
| 5906 | 5913 | Parser.acorn = { | |
| 5907 | 5914 | Parser: Parser, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ | |||
| 16 | 16 | ], | |
| 17 | 17 | "./package.json": "./package.json" | |
| 18 | 18 | }, | |
| 19 | - "version": "8.9.0", | ||
| 19 | + "version": "8.10.0", | ||
| 20 | 20 | "engines": { | |
| 21 | 21 | "node": ">=0.4.0" | |
| 22 | 22 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,5 +2,5 @@ | |||
| 2 | 2 | // Refer to tools/update-acorn.sh | |
| 3 | 3 | #ifndef SRC_ACORN_VERSION_H_ | |
| 4 | 4 | #define SRC_ACORN_VERSION_H_ | |
| 5 | - #define ACORN_VERSION "8.9.0" | ||
| 5 | + #define ACORN_VERSION "8.10.0" | ||
| 6 | 6 | #endif // SRC_ACORN_VERSION_H_ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments