poe-code 6.0.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +307 -937
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/interp/async.d.ts +2 -1
- package/packages/safejs/dist/interp/async.js +25 -24
- package/packages/safejs/dist/interp/interpreter.js +7 -5
- package/packages/safejs/dist/interp/patterns.d.ts +1 -0
- package/packages/safejs/dist/interp/patterns.js +1 -1
- package/packages/safejs/dist/interp/var-hoist.js +5 -135
- package/packages/safejs/dist/lint/index.js +0 -4
- package/packages/safejs/dist/lint/rules/AS001.js +4 -4
- package/packages/safejs/dist/lint/rules/AS003.js +47 -7
- package/packages/safejs/dist/lint/rules/AS006-007.js +48 -7
- package/packages/safejs/dist/parse/bindings.d.ts +6 -0
- package/packages/safejs/dist/parse/bindings.js +90 -0
- package/packages/safejs/dist/parse/parser.js +70 -37
- package/packages/safejs/dist/snapshot/dump-format.d.ts +1 -1
- package/packages/safejs/dist/snapshot/dump-format.js +1 -1
- package/packages/safejs/dist/lint/rules/AS-await-non-promise.d.ts +0 -13
- package/packages/safejs/dist/lint/rules/AS-await-non-promise.js +0 -301
- package/packages/safejs/dist/lint/rules/AS008.d.ts +0 -13
- package/packages/safejs/dist/lint/rules/AS008.js +0 -386
package/dist/index.js
CHANGED
|
@@ -118875,6 +118875,97 @@ var init_error_codes21 = __esm({
|
|
|
118875
118875
|
}
|
|
118876
118876
|
});
|
|
118877
118877
|
|
|
118878
|
+
// packages/safejs/src/parse/bindings.ts
|
|
118879
|
+
function* boundIdentifiers(pattern) {
|
|
118880
|
+
switch (pattern.type) {
|
|
118881
|
+
case "Identifier":
|
|
118882
|
+
yield pattern;
|
|
118883
|
+
return;
|
|
118884
|
+
case "AssignmentPattern":
|
|
118885
|
+
yield* boundIdentifiers(pattern.left);
|
|
118886
|
+
return;
|
|
118887
|
+
case "RestElement":
|
|
118888
|
+
yield* boundIdentifiers(pattern.argument);
|
|
118889
|
+
return;
|
|
118890
|
+
case "ArrayPattern":
|
|
118891
|
+
for (const element of pattern.elements) {
|
|
118892
|
+
if (element !== null) yield* boundIdentifiers(element);
|
|
118893
|
+
}
|
|
118894
|
+
return;
|
|
118895
|
+
case "ObjectPattern":
|
|
118896
|
+
for (const property of pattern.properties) {
|
|
118897
|
+
yield* boundIdentifiers(property.type === "RestElement" ? property : property.value);
|
|
118898
|
+
}
|
|
118899
|
+
return;
|
|
118900
|
+
case "MemberExpression":
|
|
118901
|
+
return;
|
|
118902
|
+
}
|
|
118903
|
+
}
|
|
118904
|
+
function containsParameterExpression(pattern) {
|
|
118905
|
+
switch (pattern.type) {
|
|
118906
|
+
case "AssignmentPattern":
|
|
118907
|
+
case "MemberExpression":
|
|
118908
|
+
return true;
|
|
118909
|
+
case "RestElement":
|
|
118910
|
+
return containsParameterExpression(pattern.argument);
|
|
118911
|
+
case "ArrayPattern":
|
|
118912
|
+
return pattern.elements.some(
|
|
118913
|
+
(element) => element !== null && containsParameterExpression(element)
|
|
118914
|
+
);
|
|
118915
|
+
case "ObjectPattern":
|
|
118916
|
+
return pattern.properties.some(
|
|
118917
|
+
(property) => property.type === "RestElement" ? containsParameterExpression(property.argument) : property.computed || containsParameterExpression(property.value)
|
|
118918
|
+
);
|
|
118919
|
+
case "Identifier":
|
|
118920
|
+
return false;
|
|
118921
|
+
}
|
|
118922
|
+
}
|
|
118923
|
+
function* hoistedVarDeclarations(nodes) {
|
|
118924
|
+
for (const node of nodes) {
|
|
118925
|
+
switch (node.type) {
|
|
118926
|
+
case "VariableDeclaration":
|
|
118927
|
+
if (node.kind === "var") yield node;
|
|
118928
|
+
break;
|
|
118929
|
+
case "BlockStatement":
|
|
118930
|
+
yield* hoistedVarDeclarations(node.body);
|
|
118931
|
+
break;
|
|
118932
|
+
case "IfStatement":
|
|
118933
|
+
yield* hoistedVarDeclarations([node.consequent]);
|
|
118934
|
+
if (node.alternate !== void 0) yield* hoistedVarDeclarations([node.alternate]);
|
|
118935
|
+
break;
|
|
118936
|
+
case "ForStatement":
|
|
118937
|
+
if (node.init?.type === "VariableDeclaration") yield* hoistedVarDeclarations([node.init]);
|
|
118938
|
+
yield* hoistedVarDeclarations([node.body]);
|
|
118939
|
+
break;
|
|
118940
|
+
case "ForInStatement":
|
|
118941
|
+
case "ForOfStatement":
|
|
118942
|
+
if (node.left.type === "VariableDeclaration") yield* hoistedVarDeclarations([node.left]);
|
|
118943
|
+
yield* hoistedVarDeclarations([node.body]);
|
|
118944
|
+
break;
|
|
118945
|
+
case "WhileStatement":
|
|
118946
|
+
case "DoWhileStatement":
|
|
118947
|
+
yield* hoistedVarDeclarations([node.body]);
|
|
118948
|
+
break;
|
|
118949
|
+
case "TryStatement":
|
|
118950
|
+
yield* hoistedVarDeclarations([node.block]);
|
|
118951
|
+
if (node.handler !== void 0) yield* hoistedVarDeclarations([node.handler.body]);
|
|
118952
|
+
if (node.finalizer !== void 0) yield* hoistedVarDeclarations([node.finalizer]);
|
|
118953
|
+
break;
|
|
118954
|
+
case "SwitchStatement":
|
|
118955
|
+
for (const switchCase of node.cases) yield* hoistedVarDeclarations(switchCase.consequent);
|
|
118956
|
+
break;
|
|
118957
|
+
case "ExportNamedDeclaration":
|
|
118958
|
+
yield* hoistedVarDeclarations([node.declaration]);
|
|
118959
|
+
break;
|
|
118960
|
+
}
|
|
118961
|
+
}
|
|
118962
|
+
}
|
|
118963
|
+
var init_bindings = __esm({
|
|
118964
|
+
"packages/safejs/src/parse/bindings.ts"() {
|
|
118965
|
+
"use strict";
|
|
118966
|
+
}
|
|
118967
|
+
});
|
|
118968
|
+
|
|
118878
118969
|
// packages/safejs/src/parse/tokenizer.ts
|
|
118879
118970
|
function tokenize3(source, options = {}) {
|
|
118880
118971
|
const lexer = new Lexer(source, options);
|
|
@@ -120692,26 +120783,6 @@ function createIdentifierName(token) {
|
|
|
120692
120783
|
span: createTokenSpan(token)
|
|
120693
120784
|
};
|
|
120694
120785
|
}
|
|
120695
|
-
function collectBindingIdentifiers(pattern) {
|
|
120696
|
-
switch (pattern.type) {
|
|
120697
|
-
case "Identifier":
|
|
120698
|
-
return [pattern];
|
|
120699
|
-
case "MemberExpression":
|
|
120700
|
-
return [];
|
|
120701
|
-
case "AssignmentPattern":
|
|
120702
|
-
return collectBindingIdentifiers(pattern.left);
|
|
120703
|
-
case "RestElement":
|
|
120704
|
-
return collectBindingIdentifiers(pattern.argument);
|
|
120705
|
-
case "ArrayPattern":
|
|
120706
|
-
return pattern.elements.flatMap(
|
|
120707
|
-
(element) => element === null ? [] : collectBindingIdentifiers(element)
|
|
120708
|
-
);
|
|
120709
|
-
case "ObjectPattern":
|
|
120710
|
-
return pattern.properties.flatMap(
|
|
120711
|
-
(property) => property.type === "RestElement" ? collectBindingIdentifiers(property) : collectBindingIdentifiers(property.value)
|
|
120712
|
-
);
|
|
120713
|
-
}
|
|
120714
|
-
}
|
|
120715
120786
|
function createLoopLabelFields(labels) {
|
|
120716
120787
|
if (labels === void 0 || labels.length === 0) {
|
|
120717
120788
|
return {};
|
|
@@ -121509,6 +121580,7 @@ var MAX_CONDITIONAL_EXPRESSION_DEPTH, MAX_IF_STATEMENT_DEPTH, DisallowedSyntaxEr
|
|
|
121509
121580
|
var init_parser3 = __esm({
|
|
121510
121581
|
"packages/safejs/src/parse/parser.ts"() {
|
|
121511
121582
|
"use strict";
|
|
121583
|
+
init_bindings();
|
|
121512
121584
|
init_tokenizer2();
|
|
121513
121585
|
init_assign_ids();
|
|
121514
121586
|
init_format_error();
|
|
@@ -121550,6 +121622,7 @@ var init_parser3 = __esm({
|
|
|
121550
121622
|
Parser = class {
|
|
121551
121623
|
constructor(tokens) {
|
|
121552
121624
|
this.tokens = tokens;
|
|
121625
|
+
this.functionScopes.add(this.scopes[0]);
|
|
121553
121626
|
}
|
|
121554
121627
|
tokens;
|
|
121555
121628
|
index = 0;
|
|
@@ -121559,6 +121632,8 @@ var init_parser3 = __esm({
|
|
|
121559
121632
|
loopDepth = 0;
|
|
121560
121633
|
generatorBody = false;
|
|
121561
121634
|
scopes = [/* @__PURE__ */ new Map()];
|
|
121635
|
+
functionScopes = /* @__PURE__ */ new WeakSet();
|
|
121636
|
+
varNames = /* @__PURE__ */ new WeakMap();
|
|
121562
121637
|
parseTopLevel() {
|
|
121563
121638
|
if (this.isExportToken(this.currentToken())) {
|
|
121564
121639
|
throw new DisallowedSyntaxError("export", this.currentToken().start);
|
|
@@ -121693,8 +121768,13 @@ var init_parser3 = __esm({
|
|
|
121693
121768
|
return void 0;
|
|
121694
121769
|
}
|
|
121695
121770
|
finishArrowFunctionExpression(start, isAsync, params) {
|
|
121771
|
+
this.withScope(() => {
|
|
121772
|
+
for (const param of params) {
|
|
121773
|
+
for (const identifier of boundIdentifiers(param)) this.declareBinding(identifier);
|
|
121774
|
+
}
|
|
121775
|
+
});
|
|
121696
121776
|
this.expectPunctuator("=>");
|
|
121697
|
-
const body = this.parseArrowFunctionBody();
|
|
121777
|
+
const body = this.parseArrowFunctionBody(params);
|
|
121698
121778
|
return {
|
|
121699
121779
|
type: "ArrowFunctionExpression",
|
|
121700
121780
|
async: isAsync,
|
|
@@ -121734,15 +121814,27 @@ var init_parser3 = __esm({
|
|
|
121734
121814
|
this.conditionalExpressionDepth -= 1;
|
|
121735
121815
|
}
|
|
121736
121816
|
}
|
|
121737
|
-
parseArrowFunctionBody() {
|
|
121817
|
+
parseArrowFunctionBody(params) {
|
|
121738
121818
|
if (this.currentToken().type === "punctuator" && this.currentToken().value === "{") {
|
|
121739
|
-
return this.withFunctionContext(false, () => this.parseBlockStatement());
|
|
121819
|
+
return this.withFunctionContext(false, () => this.parseBlockStatement(params));
|
|
121740
121820
|
}
|
|
121741
121821
|
return this.withFunctionContext(false, () => this.parseExpression().node);
|
|
121742
121822
|
}
|
|
121743
|
-
parseBlockStatement() {
|
|
121823
|
+
parseBlockStatement(params, catchParam) {
|
|
121744
121824
|
const start = this.expectPunctuator("{");
|
|
121745
|
-
return this.withScope(() =>
|
|
121825
|
+
return this.withScope(() => {
|
|
121826
|
+
for (const param of params ?? []) {
|
|
121827
|
+
for (const identifier of boundIdentifiers(param)) {
|
|
121828
|
+
this.declareBinding(identifier, "parameter");
|
|
121829
|
+
}
|
|
121830
|
+
}
|
|
121831
|
+
if (catchParam !== void 0) {
|
|
121832
|
+
for (const identifier of boundIdentifiers(catchParam)) {
|
|
121833
|
+
this.declareBinding(identifier, catchParam.type === "Identifier" ? "catch" : "lexical");
|
|
121834
|
+
}
|
|
121835
|
+
}
|
|
121836
|
+
return this.parseBlockStatementBody(start);
|
|
121837
|
+
}, params !== void 0);
|
|
121746
121838
|
}
|
|
121747
121839
|
parseBlockStatementBody(start) {
|
|
121748
121840
|
const body = [];
|
|
@@ -122266,7 +122358,7 @@ var init_parser3 = __esm({
|
|
|
122266
122358
|
param = this.parseBindingTarget();
|
|
122267
122359
|
this.expectPunctuator(")");
|
|
122268
122360
|
}
|
|
122269
|
-
const body = this.parseBlockStatement();
|
|
122361
|
+
const body = this.parseBlockStatement(void 0, param);
|
|
122270
122362
|
return {
|
|
122271
122363
|
type: "CatchClause",
|
|
122272
122364
|
param,
|
|
@@ -122285,6 +122377,10 @@ var init_parser3 = __esm({
|
|
|
122285
122377
|
const declarator = this.parseVariableDeclarator(kindToken.value);
|
|
122286
122378
|
if (kindToken.value !== "var") {
|
|
122287
122379
|
this.declarePatternBindings(declarator.id);
|
|
122380
|
+
} else {
|
|
122381
|
+
for (const identifier of boundIdentifiers(declarator.id)) {
|
|
122382
|
+
this.declareVarBinding(identifier);
|
|
122383
|
+
}
|
|
122288
122384
|
}
|
|
122289
122385
|
declarations.push(declarator);
|
|
122290
122386
|
const comma = this.consumePunctuator(",");
|
|
@@ -122309,18 +122405,18 @@ var init_parser3 = __esm({
|
|
|
122309
122405
|
);
|
|
122310
122406
|
}
|
|
122311
122407
|
const id = this.parseBindingIdentifier();
|
|
122312
|
-
this.declareBinding(id);
|
|
122408
|
+
this.declareBinding(id, "function");
|
|
122313
122409
|
const params = this.withScope(() => {
|
|
122314
122410
|
const parsedParams = this.parseArrowParameters();
|
|
122315
122411
|
for (const param of parsedParams) {
|
|
122316
|
-
for (const identifier of
|
|
122412
|
+
for (const identifier of boundIdentifiers(param)) {
|
|
122317
122413
|
this.declareBinding(identifier);
|
|
122318
122414
|
}
|
|
122319
122415
|
}
|
|
122320
122416
|
return parsedParams;
|
|
122321
122417
|
});
|
|
122322
122418
|
const generator = generatorToken !== void 0;
|
|
122323
|
-
const body = this.withFunctionContext(generator, () => this.parseBlockStatement());
|
|
122419
|
+
const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
|
|
122324
122420
|
return {
|
|
122325
122421
|
type: "FunctionDeclaration",
|
|
122326
122422
|
async: asyncToken !== void 0,
|
|
@@ -123279,14 +123375,14 @@ var init_parser3 = __esm({
|
|
|
123279
123375
|
const params = this.withScope(() => {
|
|
123280
123376
|
const parsedParams = this.parseArrowParameters();
|
|
123281
123377
|
for (const param of parsedParams) {
|
|
123282
|
-
for (const identifier of
|
|
123378
|
+
for (const identifier of boundIdentifiers(param)) {
|
|
123283
123379
|
this.declareBinding(identifier);
|
|
123284
123380
|
}
|
|
123285
123381
|
}
|
|
123286
123382
|
return parsedParams;
|
|
123287
123383
|
});
|
|
123288
123384
|
const generator = generatorToken !== void 0;
|
|
123289
|
-
const body = this.withFunctionContext(generator, () => this.parseBlockStatement());
|
|
123385
|
+
const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
|
|
123290
123386
|
return {
|
|
123291
123387
|
type: "FunctionExpression",
|
|
123292
123388
|
async: asyncToken !== void 0,
|
|
@@ -123522,13 +123618,13 @@ var init_parser3 = __esm({
|
|
|
123522
123618
|
const params = this.withScope(() => {
|
|
123523
123619
|
const parsedParams = this.parseArrowParameters();
|
|
123524
123620
|
for (const param of parsedParams) {
|
|
123525
|
-
for (const identifier of
|
|
123621
|
+
for (const identifier of boundIdentifiers(param)) {
|
|
123526
123622
|
this.declareBinding(identifier);
|
|
123527
123623
|
}
|
|
123528
123624
|
}
|
|
123529
123625
|
return parsedParams;
|
|
123530
123626
|
});
|
|
123531
|
-
const body = this.withFunctionContext(false, () => this.parseBlockStatement());
|
|
123627
|
+
const body = this.withFunctionContext(false, () => this.parseBlockStatement(params));
|
|
123532
123628
|
return {
|
|
123533
123629
|
type: "FunctionExpression",
|
|
123534
123630
|
async: asyncToken !== void 0,
|
|
@@ -123966,8 +124062,10 @@ var init_parser3 = __esm({
|
|
|
123966
124062
|
this.breakableDepth -= 1;
|
|
123967
124063
|
}
|
|
123968
124064
|
}
|
|
123969
|
-
withScope(callback) {
|
|
123970
|
-
|
|
124065
|
+
withScope(callback, functionBody = false) {
|
|
124066
|
+
const scope = /* @__PURE__ */ new Map();
|
|
124067
|
+
if (functionBody) this.functionScopes.add(scope);
|
|
124068
|
+
this.scopes.push(scope);
|
|
123971
124069
|
try {
|
|
123972
124070
|
return callback();
|
|
123973
124071
|
} finally {
|
|
@@ -123975,21 +124073,41 @@ var init_parser3 = __esm({
|
|
|
123975
124073
|
}
|
|
123976
124074
|
}
|
|
123977
124075
|
declarePatternBindings(pattern) {
|
|
123978
|
-
for (const identifier of
|
|
124076
|
+
for (const identifier of boundIdentifiers(pattern)) {
|
|
123979
124077
|
this.declareBinding(identifier);
|
|
123980
124078
|
}
|
|
123981
124079
|
}
|
|
123982
|
-
declareBinding(identifier) {
|
|
124080
|
+
declareBinding(identifier, kind = "lexical") {
|
|
123983
124081
|
const scope = this.scopes[this.scopes.length - 1];
|
|
123984
124082
|
if (scope === void 0) {
|
|
123985
124083
|
return;
|
|
123986
124084
|
}
|
|
123987
|
-
|
|
124085
|
+
const existing = scope.get(identifier.name);
|
|
124086
|
+
const variableFunction = kind === "function" && this.functionScopes.has(scope);
|
|
124087
|
+
if (existing !== void 0 && !(variableFunction && (existing === "function" || existing === "parameter")) || !variableFunction && this.varNames.get(scope)?.has(identifier.name)) {
|
|
123988
124088
|
throw new Error(
|
|
123989
124089
|
`Cannot redeclare binding '${identifier.name}' at line ${identifier.span.start.line}, column ${identifier.span.start.column}.`
|
|
123990
124090
|
);
|
|
123991
124091
|
}
|
|
123992
|
-
scope.set(identifier.name,
|
|
124092
|
+
scope.set(identifier.name, kind);
|
|
124093
|
+
}
|
|
124094
|
+
declareVarBinding(identifier) {
|
|
124095
|
+
for (let index = this.scopes.length - 1; index >= 0; index--) {
|
|
124096
|
+
const scope = this.scopes[index];
|
|
124097
|
+
const existing = scope.get(identifier.name);
|
|
124098
|
+
if (existing === "lexical" || existing === "function" && !this.functionScopes.has(scope)) {
|
|
124099
|
+
throw new Error(
|
|
124100
|
+
`Cannot redeclare binding '${identifier.name}' at line ${identifier.span.start.line}, column ${identifier.span.start.column}.`
|
|
124101
|
+
);
|
|
124102
|
+
}
|
|
124103
|
+
let names = this.varNames.get(scope);
|
|
124104
|
+
if (names === void 0) {
|
|
124105
|
+
names = /* @__PURE__ */ new Set();
|
|
124106
|
+
this.varNames.set(scope, names);
|
|
124107
|
+
}
|
|
124108
|
+
names.add(identifier.name);
|
|
124109
|
+
if (this.functionScopes.has(scope)) return;
|
|
124110
|
+
}
|
|
123993
124111
|
}
|
|
123994
124112
|
consumePunctuator(value) {
|
|
123995
124113
|
const token = this.currentToken();
|
|
@@ -124414,7 +124532,7 @@ var init_AS001 = __esm({
|
|
|
124414
124532
|
braceContextStack,
|
|
124415
124533
|
nextSignificantChar
|
|
124416
124534
|
);
|
|
124417
|
-
if (canStartStatement && nextSignificantChar === ":" && !this.isLoopLabelStart()) {
|
|
124535
|
+
if (canStartStatement && nextSignificantChar === ":" && token.value !== "default" && !this.isLoopLabelStart()) {
|
|
124418
124536
|
this.report(
|
|
124419
124537
|
"label",
|
|
124420
124538
|
token.start,
|
|
@@ -124472,9 +124590,6 @@ var init_AS001 = __esm({
|
|
|
124472
124590
|
case "class":
|
|
124473
124591
|
case "eval":
|
|
124474
124592
|
case "Function":
|
|
124475
|
-
case "switch":
|
|
124476
|
-
case "this":
|
|
124477
|
-
case "var":
|
|
124478
124593
|
case "with":
|
|
124479
124594
|
this.report(token.value, token.start, token.end);
|
|
124480
124595
|
return;
|
|
@@ -124858,6 +124973,7 @@ var init_AS003 = __esm({
|
|
|
124858
124973
|
"use strict";
|
|
124859
124974
|
init_parser3();
|
|
124860
124975
|
init_known_globals();
|
|
124976
|
+
init_bindings();
|
|
124861
124977
|
AS003Scanner = class {
|
|
124862
124978
|
constructor(filename, allowedGlobals) {
|
|
124863
124979
|
this.filename = filename;
|
|
@@ -124907,6 +125023,9 @@ var init_AS003 = __esm({
|
|
|
124907
125023
|
case "TryStatement":
|
|
124908
125024
|
this.visitTryStatement(node);
|
|
124909
125025
|
return;
|
|
125026
|
+
case "SwitchStatement":
|
|
125027
|
+
this.visitSwitchStatement(node);
|
|
125028
|
+
return;
|
|
124910
125029
|
case "VariableDeclaration":
|
|
124911
125030
|
this.visitVariableDeclaration(node);
|
|
124912
125031
|
return;
|
|
@@ -124930,8 +125049,14 @@ var init_AS003 = __esm({
|
|
|
124930
125049
|
return;
|
|
124931
125050
|
}
|
|
124932
125051
|
}
|
|
124933
|
-
visitBlock(node) {
|
|
124934
|
-
this.
|
|
125052
|
+
visitBlock(node, functionBody = false) {
|
|
125053
|
+
const bindings = this.collectBlockBindings(node.body);
|
|
125054
|
+
if (functionBody) {
|
|
125055
|
+
for (const declaration of hoistedVarDeclarations(node.body)) {
|
|
125056
|
+
bindings.push(...this.collectDeclarationBindings(declaration));
|
|
125057
|
+
}
|
|
125058
|
+
}
|
|
125059
|
+
this.withScope(bindings, () => {
|
|
124935
125060
|
for (const statement of node.body) {
|
|
124936
125061
|
this.visitStatement(statement);
|
|
124937
125062
|
}
|
|
@@ -124948,7 +125073,7 @@ var init_AS003 = __esm({
|
|
|
124948
125073
|
}
|
|
124949
125074
|
}
|
|
124950
125075
|
visitForStatement(node) {
|
|
124951
|
-
const bindings = node.init?.type === "VariableDeclaration" ? this.collectDeclarationBindings(node.init) : [];
|
|
125076
|
+
const bindings = node.init?.type === "VariableDeclaration" && node.init.kind !== "var" ? this.collectDeclarationBindings(node.init) : [];
|
|
124952
125077
|
this.withScope(bindings, () => {
|
|
124953
125078
|
if (node.init !== void 0) {
|
|
124954
125079
|
if (node.init.type === "VariableDeclaration") {
|
|
@@ -124967,7 +125092,7 @@ var init_AS003 = __esm({
|
|
|
124967
125092
|
});
|
|
124968
125093
|
}
|
|
124969
125094
|
visitForOfStatement(node) {
|
|
124970
|
-
const bindings = node.left.type === "VariableDeclaration" ? this.collectDeclarationBindings(node.left) : [];
|
|
125095
|
+
const bindings = node.left.type === "VariableDeclaration" && node.left.kind !== "var" ? this.collectDeclarationBindings(node.left) : [];
|
|
124971
125096
|
this.withScope(bindings, () => {
|
|
124972
125097
|
if (node.left.type === "VariableDeclaration") {
|
|
124973
125098
|
this.visitVariableDeclaration(node.left);
|
|
@@ -124982,6 +125107,18 @@ var init_AS003 = __esm({
|
|
|
124982
125107
|
this.visitExpression(node.test);
|
|
124983
125108
|
this.visitStatement(node.body);
|
|
124984
125109
|
}
|
|
125110
|
+
visitSwitchStatement(node) {
|
|
125111
|
+
this.visitExpression(node.discriminant);
|
|
125112
|
+
this.withScope(
|
|
125113
|
+
this.collectBlockBindings(node.cases.flatMap((switchCase) => switchCase.consequent)),
|
|
125114
|
+
() => {
|
|
125115
|
+
for (const switchCase of node.cases) {
|
|
125116
|
+
if (switchCase.test !== void 0) this.visitExpression(switchCase.test);
|
|
125117
|
+
for (const statement of switchCase.consequent) this.visitStatement(statement);
|
|
125118
|
+
}
|
|
125119
|
+
}
|
|
125120
|
+
);
|
|
125121
|
+
}
|
|
124985
125122
|
visitTryStatement(node) {
|
|
124986
125123
|
this.visitBlock(node.block);
|
|
124987
125124
|
if (node.handler !== void 0) {
|
|
@@ -125055,8 +125192,19 @@ var init_AS003 = __esm({
|
|
|
125055
125192
|
this.visitAssignmentExpression(node);
|
|
125056
125193
|
return;
|
|
125057
125194
|
case "CallExpression":
|
|
125195
|
+
case "NewExpression":
|
|
125058
125196
|
this.visitCallExpression(node);
|
|
125059
125197
|
return;
|
|
125198
|
+
case "SequenceExpression":
|
|
125199
|
+
for (const expression of node.expressions) this.visitExpression(expression);
|
|
125200
|
+
return;
|
|
125201
|
+
case "UpdateExpression":
|
|
125202
|
+
this.visitExpression(node.argument);
|
|
125203
|
+
return;
|
|
125204
|
+
case "TaggedTemplateExpression":
|
|
125205
|
+
this.visitExpression(node.tag);
|
|
125206
|
+
this.visitTemplateLiteral(node.quasi);
|
|
125207
|
+
return;
|
|
125060
125208
|
case "TemplateLiteral":
|
|
125061
125209
|
this.visitTemplateLiteral(node);
|
|
125062
125210
|
return;
|
|
@@ -125074,7 +125222,7 @@ var init_AS003 = __esm({
|
|
|
125074
125222
|
this.visitBindingElement(parameter);
|
|
125075
125223
|
}
|
|
125076
125224
|
if (node.body.type === "BlockStatement") {
|
|
125077
|
-
this.visitBlock(node.body);
|
|
125225
|
+
this.visitBlock(node.body, true);
|
|
125078
125226
|
} else {
|
|
125079
125227
|
this.visitExpression(node.body);
|
|
125080
125228
|
}
|
|
@@ -125288,6 +125436,9 @@ var init_AS003 = __esm({
|
|
|
125288
125436
|
}
|
|
125289
125437
|
collectModuleBindings(body) {
|
|
125290
125438
|
const bindings = [];
|
|
125439
|
+
for (const declaration of hoistedVarDeclarations(body)) {
|
|
125440
|
+
bindings.push(...this.collectDeclarationBindings(declaration));
|
|
125441
|
+
}
|
|
125291
125442
|
for (const statement of body) {
|
|
125292
125443
|
if (statement.type === "ImportDeclaration") {
|
|
125293
125444
|
bindings.push(...this.collectImportBindings(statement));
|
|
@@ -125297,7 +125448,7 @@ var init_AS003 = __esm({
|
|
|
125297
125448
|
bindings.push({ kind: "let", name: statement.id.name });
|
|
125298
125449
|
continue;
|
|
125299
125450
|
}
|
|
125300
|
-
if (statement.type === "VariableDeclaration") {
|
|
125451
|
+
if (statement.type === "VariableDeclaration" && statement.kind !== "var") {
|
|
125301
125452
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
125302
125453
|
continue;
|
|
125303
125454
|
}
|
|
@@ -125313,7 +125464,7 @@ var init_AS003 = __esm({
|
|
|
125313
125464
|
if (statement.type === "FunctionDeclaration") {
|
|
125314
125465
|
bindings.push({ kind: "let", name: statement.id.name });
|
|
125315
125466
|
}
|
|
125316
|
-
if (statement.type === "VariableDeclaration") {
|
|
125467
|
+
if (statement.type === "VariableDeclaration" && statement.kind !== "var") {
|
|
125317
125468
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
125318
125469
|
}
|
|
125319
125470
|
}
|
|
@@ -125586,6 +125737,7 @@ var init_AS006_007 = __esm({
|
|
|
125586
125737
|
"packages/safejs/src/lint/rules/AS006-007.ts"() {
|
|
125587
125738
|
"use strict";
|
|
125588
125739
|
init_parser3();
|
|
125740
|
+
init_bindings();
|
|
125589
125741
|
AS006007Scanner = class {
|
|
125590
125742
|
constructor(filename) {
|
|
125591
125743
|
this.filename = filename;
|
|
@@ -125642,6 +125794,9 @@ var init_AS006_007 = __esm({
|
|
|
125642
125794
|
case "TryStatement":
|
|
125643
125795
|
this.visitTryStatement(node);
|
|
125644
125796
|
return;
|
|
125797
|
+
case "SwitchStatement":
|
|
125798
|
+
this.visitSwitchStatement(node);
|
|
125799
|
+
return;
|
|
125645
125800
|
case "VariableDeclaration":
|
|
125646
125801
|
this.visitVariableDeclaration(node);
|
|
125647
125802
|
return;
|
|
@@ -125659,8 +125814,14 @@ var init_AS006_007 = __esm({
|
|
|
125659
125814
|
return;
|
|
125660
125815
|
}
|
|
125661
125816
|
}
|
|
125662
|
-
visitBlock(node) {
|
|
125663
|
-
this.
|
|
125817
|
+
visitBlock(node, functionBody = false) {
|
|
125818
|
+
const bindings = this.collectBlockBindings(node.body);
|
|
125819
|
+
if (functionBody) {
|
|
125820
|
+
for (const declaration of hoistedVarDeclarations(node.body)) {
|
|
125821
|
+
bindings.push(...this.collectDeclarationBindings(declaration));
|
|
125822
|
+
}
|
|
125823
|
+
}
|
|
125824
|
+
this.withScope(bindings, () => {
|
|
125664
125825
|
for (const statement of node.body) {
|
|
125665
125826
|
this.visitStatement(statement);
|
|
125666
125827
|
}
|
|
@@ -125674,7 +125835,7 @@ var init_AS006_007 = __esm({
|
|
|
125674
125835
|
}
|
|
125675
125836
|
}
|
|
125676
125837
|
visitForStatement(node) {
|
|
125677
|
-
const bindings = node.init?.type === "VariableDeclaration" ? this.collectDeclarationBindings(node.init) : [];
|
|
125838
|
+
const bindings = node.init?.type === "VariableDeclaration" && node.init.kind !== "var" ? this.collectDeclarationBindings(node.init) : [];
|
|
125678
125839
|
this.withScope(bindings, () => {
|
|
125679
125840
|
if (node.init !== void 0) {
|
|
125680
125841
|
if (node.init.type === "VariableDeclaration") {
|
|
@@ -125693,7 +125854,7 @@ var init_AS006_007 = __esm({
|
|
|
125693
125854
|
});
|
|
125694
125855
|
}
|
|
125695
125856
|
visitForOfStatement(node) {
|
|
125696
|
-
const bindings = node.left.type === "VariableDeclaration" ? this.collectDeclarationBindings(node.left) : [];
|
|
125857
|
+
const bindings = node.left.type === "VariableDeclaration" && node.left.kind !== "var" ? this.collectDeclarationBindings(node.left) : [];
|
|
125697
125858
|
this.withScope(bindings, () => {
|
|
125698
125859
|
if (node.left.type === "VariableDeclaration") {
|
|
125699
125860
|
this.visitVariableDeclaration(node.left);
|
|
@@ -125725,6 +125886,16 @@ var init_AS006_007 = __esm({
|
|
|
125725
125886
|
this.visitBlock(node.body);
|
|
125726
125887
|
});
|
|
125727
125888
|
}
|
|
125889
|
+
visitSwitchStatement(node) {
|
|
125890
|
+
this.visitExpression(node.discriminant);
|
|
125891
|
+
const statements = node.cases.flatMap((switchCase) => switchCase.consequent);
|
|
125892
|
+
this.withScope(this.collectBlockBindings(statements), () => {
|
|
125893
|
+
for (const switchCase of node.cases) {
|
|
125894
|
+
if (switchCase.test !== void 0) this.visitExpression(switchCase.test);
|
|
125895
|
+
for (const statement of switchCase.consequent) this.visitStatement(statement);
|
|
125896
|
+
}
|
|
125897
|
+
});
|
|
125898
|
+
}
|
|
125728
125899
|
visitThrowStatement(node) {
|
|
125729
125900
|
this.visitExpression(node.argument);
|
|
125730
125901
|
}
|
|
@@ -125784,8 +125955,19 @@ var init_AS006_007 = __esm({
|
|
|
125784
125955
|
this.visitAssignmentExpression(node);
|
|
125785
125956
|
return;
|
|
125786
125957
|
case "CallExpression":
|
|
125958
|
+
case "NewExpression":
|
|
125787
125959
|
this.visitCallExpression(node);
|
|
125788
125960
|
return;
|
|
125961
|
+
case "SequenceExpression":
|
|
125962
|
+
for (const expression of node.expressions) this.visitExpression(expression);
|
|
125963
|
+
return;
|
|
125964
|
+
case "UpdateExpression":
|
|
125965
|
+
this.visitExpression(node.argument);
|
|
125966
|
+
return;
|
|
125967
|
+
case "TaggedTemplateExpression":
|
|
125968
|
+
this.visitExpression(node.tag);
|
|
125969
|
+
this.visitTemplateLiteral(node.quasi);
|
|
125970
|
+
return;
|
|
125789
125971
|
case "TemplateLiteral":
|
|
125790
125972
|
this.visitTemplateLiteral(node);
|
|
125791
125973
|
return;
|
|
@@ -125804,7 +125986,7 @@ var init_AS006_007 = __esm({
|
|
|
125804
125986
|
this.visitBindingElement(parameter);
|
|
125805
125987
|
}
|
|
125806
125988
|
if (node.body.type === "BlockStatement") {
|
|
125807
|
-
this.visitBlock(node.body);
|
|
125989
|
+
this.visitBlock(node.body, true);
|
|
125808
125990
|
return;
|
|
125809
125991
|
}
|
|
125810
125992
|
this.visitExpression(node.body);
|
|
@@ -126021,6 +126203,9 @@ var init_AS006_007 = __esm({
|
|
|
126021
126203
|
}
|
|
126022
126204
|
collectModuleBindings(body) {
|
|
126023
126205
|
const bindings = [];
|
|
126206
|
+
for (const declaration of hoistedVarDeclarations(body)) {
|
|
126207
|
+
bindings.push(...this.collectDeclarationBindings(declaration));
|
|
126208
|
+
}
|
|
126024
126209
|
for (const statement of body) {
|
|
126025
126210
|
if (statement.type === "ImportDeclaration") {
|
|
126026
126211
|
bindings.push(...this.collectImportBindings(statement));
|
|
@@ -126030,7 +126215,7 @@ var init_AS006_007 = __esm({
|
|
|
126030
126215
|
bindings.push(this.createBinding(statement.id, "let"));
|
|
126031
126216
|
continue;
|
|
126032
126217
|
}
|
|
126033
|
-
if (statement.type === "VariableDeclaration") {
|
|
126218
|
+
if (statement.type === "VariableDeclaration" && statement.kind !== "var") {
|
|
126034
126219
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
126035
126220
|
continue;
|
|
126036
126221
|
}
|
|
@@ -126046,7 +126231,7 @@ var init_AS006_007 = __esm({
|
|
|
126046
126231
|
if (statement.type === "FunctionDeclaration") {
|
|
126047
126232
|
bindings.push(this.createBinding(statement.id, "let"));
|
|
126048
126233
|
}
|
|
126049
|
-
if (statement.type === "VariableDeclaration") {
|
|
126234
|
+
if (statement.type === "VariableDeclaration" && statement.kind !== "var") {
|
|
126050
126235
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
126051
126236
|
}
|
|
126052
126237
|
}
|
|
@@ -126201,406 +126386,16 @@ var init_AS006_007 = __esm({
|
|
|
126201
126386
|
}
|
|
126202
126387
|
});
|
|
126203
126388
|
|
|
126204
|
-
// packages/safejs/src/lint/rules/AS008.ts
|
|
126205
|
-
function AS008(source, options = {}) {
|
|
126206
|
-
return new AS008Scanner(options.filename ?? "<input>").scan(source);
|
|
126207
|
-
}
|
|
126208
|
-
var MESSAGE, AS008Scanner;
|
|
126209
|
-
var init_AS008 = __esm({
|
|
126210
|
-
"packages/safejs/src/lint/rules/AS008.ts"() {
|
|
126211
|
-
"use strict";
|
|
126212
|
-
init_parser3();
|
|
126213
|
-
MESSAGE = "Await is only allowed at the script top level or inside async arrow functions.";
|
|
126214
|
-
AS008Scanner = class {
|
|
126215
|
-
constructor(filename) {
|
|
126216
|
-
this.filename = filename;
|
|
126217
|
-
}
|
|
126218
|
-
filename;
|
|
126219
|
-
diagnostics = [];
|
|
126220
|
-
functionStack = [];
|
|
126221
|
-
scopeDepth = 0;
|
|
126222
|
-
scan(source) {
|
|
126223
|
-
const module = parseModule(source, this.filename);
|
|
126224
|
-
this.visitModule(module);
|
|
126225
|
-
return this.diagnostics;
|
|
126226
|
-
}
|
|
126227
|
-
visitModule(node) {
|
|
126228
|
-
for (const statement of node.body) {
|
|
126229
|
-
this.visitStatement(statement);
|
|
126230
|
-
}
|
|
126231
|
-
}
|
|
126232
|
-
visitStatement(node) {
|
|
126233
|
-
switch (node.type) {
|
|
126234
|
-
case "FunctionDeclaration":
|
|
126235
|
-
this.visitArrowFunction(node);
|
|
126236
|
-
return;
|
|
126237
|
-
case "BlockStatement":
|
|
126238
|
-
this.withNestedScope(() => {
|
|
126239
|
-
this.visitBlock(node);
|
|
126240
|
-
});
|
|
126241
|
-
return;
|
|
126242
|
-
case "ExpressionStatement":
|
|
126243
|
-
this.visitExpression(node.expression);
|
|
126244
|
-
return;
|
|
126245
|
-
case "IfStatement":
|
|
126246
|
-
this.visitIfStatement(node);
|
|
126247
|
-
return;
|
|
126248
|
-
case "ForStatement":
|
|
126249
|
-
this.visitForStatement(node);
|
|
126250
|
-
return;
|
|
126251
|
-
case "ForInStatement":
|
|
126252
|
-
case "ForOfStatement":
|
|
126253
|
-
this.visitForOfStatement(node);
|
|
126254
|
-
return;
|
|
126255
|
-
case "WhileStatement":
|
|
126256
|
-
case "DoWhileStatement":
|
|
126257
|
-
this.visitWhileStatement(node);
|
|
126258
|
-
return;
|
|
126259
|
-
case "TryStatement":
|
|
126260
|
-
this.visitTryStatement(node);
|
|
126261
|
-
return;
|
|
126262
|
-
case "VariableDeclaration":
|
|
126263
|
-
this.visitVariableDeclaration(node);
|
|
126264
|
-
return;
|
|
126265
|
-
case "ReturnStatement":
|
|
126266
|
-
if (node.argument !== void 0) {
|
|
126267
|
-
this.visitExpression(node.argument);
|
|
126268
|
-
}
|
|
126269
|
-
return;
|
|
126270
|
-
case "ThrowStatement":
|
|
126271
|
-
this.visitThrowStatement(node);
|
|
126272
|
-
return;
|
|
126273
|
-
case "ImportDeclaration":
|
|
126274
|
-
case "BreakStatement":
|
|
126275
|
-
case "ContinueStatement":
|
|
126276
|
-
return;
|
|
126277
|
-
}
|
|
126278
|
-
}
|
|
126279
|
-
visitBlock(node) {
|
|
126280
|
-
for (const statement of node.body) {
|
|
126281
|
-
this.visitStatement(statement);
|
|
126282
|
-
}
|
|
126283
|
-
}
|
|
126284
|
-
visitIfStatement(node) {
|
|
126285
|
-
this.visitExpression(node.test);
|
|
126286
|
-
this.visitStatement(node.consequent);
|
|
126287
|
-
if (node.alternate !== void 0) {
|
|
126288
|
-
this.visitStatement(node.alternate);
|
|
126289
|
-
}
|
|
126290
|
-
}
|
|
126291
|
-
visitForStatement(node) {
|
|
126292
|
-
if (node.init !== void 0) {
|
|
126293
|
-
if (node.init.type === "VariableDeclaration") {
|
|
126294
|
-
this.visitVariableDeclaration(node.init);
|
|
126295
|
-
} else {
|
|
126296
|
-
this.visitExpression(node.init);
|
|
126297
|
-
}
|
|
126298
|
-
}
|
|
126299
|
-
if (node.test !== void 0) {
|
|
126300
|
-
this.visitExpression(node.test);
|
|
126301
|
-
}
|
|
126302
|
-
if (node.update !== void 0) {
|
|
126303
|
-
this.visitExpression(node.update);
|
|
126304
|
-
}
|
|
126305
|
-
this.visitStatement(node.body);
|
|
126306
|
-
}
|
|
126307
|
-
visitForOfStatement(node) {
|
|
126308
|
-
if (node.left.type === "VariableDeclaration") {
|
|
126309
|
-
this.visitVariableDeclaration(node.left);
|
|
126310
|
-
} else {
|
|
126311
|
-
this.visitAssignmentTarget(node.left);
|
|
126312
|
-
}
|
|
126313
|
-
this.visitExpression(node.right);
|
|
126314
|
-
this.visitStatement(node.body);
|
|
126315
|
-
}
|
|
126316
|
-
visitWhileStatement(node) {
|
|
126317
|
-
this.visitExpression(node.test);
|
|
126318
|
-
this.visitStatement(node.body);
|
|
126319
|
-
}
|
|
126320
|
-
visitTryStatement(node) {
|
|
126321
|
-
this.visitStatement(node.block);
|
|
126322
|
-
if (node.handler !== void 0) {
|
|
126323
|
-
this.visitCatchClause(node.handler);
|
|
126324
|
-
}
|
|
126325
|
-
if (node.finalizer !== void 0) {
|
|
126326
|
-
this.visitStatement(node.finalizer);
|
|
126327
|
-
}
|
|
126328
|
-
}
|
|
126329
|
-
visitCatchClause(node) {
|
|
126330
|
-
this.withNestedScope(() => {
|
|
126331
|
-
if (node.param !== void 0) {
|
|
126332
|
-
this.visitBindingPattern(node.param);
|
|
126333
|
-
}
|
|
126334
|
-
this.visitBlock(node.body);
|
|
126335
|
-
});
|
|
126336
|
-
}
|
|
126337
|
-
visitThrowStatement(node) {
|
|
126338
|
-
this.visitExpression(node.argument);
|
|
126339
|
-
}
|
|
126340
|
-
visitVariableDeclaration(node) {
|
|
126341
|
-
for (const declarator of node.declarations) {
|
|
126342
|
-
this.visitVariableDeclarator(declarator);
|
|
126343
|
-
}
|
|
126344
|
-
}
|
|
126345
|
-
visitVariableDeclarator(node) {
|
|
126346
|
-
this.visitBindingPattern(node.id);
|
|
126347
|
-
if (node.init !== void 0) {
|
|
126348
|
-
this.visitExpression(node.init);
|
|
126349
|
-
}
|
|
126350
|
-
}
|
|
126351
|
-
visitExpression(node) {
|
|
126352
|
-
switch (node.type) {
|
|
126353
|
-
case "YieldExpression":
|
|
126354
|
-
if (node.argument !== void 0) {
|
|
126355
|
-
this.visitExpression(node.argument);
|
|
126356
|
-
}
|
|
126357
|
-
return;
|
|
126358
|
-
case "FunctionExpression":
|
|
126359
|
-
case "ArrowFunctionExpression":
|
|
126360
|
-
this.visitArrowFunction(node);
|
|
126361
|
-
return;
|
|
126362
|
-
case "AwaitExpression":
|
|
126363
|
-
this.visitAwaitExpression(node);
|
|
126364
|
-
return;
|
|
126365
|
-
case "ArrayExpression":
|
|
126366
|
-
this.visitArrayExpression(node);
|
|
126367
|
-
return;
|
|
126368
|
-
case "ObjectExpression":
|
|
126369
|
-
this.visitObjectExpression(node);
|
|
126370
|
-
return;
|
|
126371
|
-
case "UnaryExpression":
|
|
126372
|
-
this.visitUnaryExpression(node);
|
|
126373
|
-
return;
|
|
126374
|
-
case "BinaryExpression":
|
|
126375
|
-
this.visitBinaryExpression(node);
|
|
126376
|
-
return;
|
|
126377
|
-
case "LogicalExpression":
|
|
126378
|
-
this.visitLogicalExpression(node);
|
|
126379
|
-
return;
|
|
126380
|
-
case "ConditionalExpression":
|
|
126381
|
-
this.visitConditionalExpression(node);
|
|
126382
|
-
return;
|
|
126383
|
-
case "MemberExpression":
|
|
126384
|
-
this.visitMemberExpression(node);
|
|
126385
|
-
return;
|
|
126386
|
-
case "AssignmentExpression":
|
|
126387
|
-
this.visitAssignmentExpression(node);
|
|
126388
|
-
return;
|
|
126389
|
-
case "CallExpression":
|
|
126390
|
-
this.visitCallExpression(node);
|
|
126391
|
-
return;
|
|
126392
|
-
case "TemplateLiteral":
|
|
126393
|
-
this.visitTemplateLiteral(node);
|
|
126394
|
-
return;
|
|
126395
|
-
case "Identifier":
|
|
126396
|
-
case "BooleanLiteral":
|
|
126397
|
-
case "NullLiteral":
|
|
126398
|
-
case "NumericLiteral":
|
|
126399
|
-
case "StringLiteral":
|
|
126400
|
-
case "UndefinedLiteral":
|
|
126401
|
-
return;
|
|
126402
|
-
}
|
|
126403
|
-
}
|
|
126404
|
-
visitArrowFunction(node) {
|
|
126405
|
-
this.functionStack.push(node.async);
|
|
126406
|
-
for (const parameter of node.params) {
|
|
126407
|
-
this.visitBindingElement(parameter);
|
|
126408
|
-
}
|
|
126409
|
-
const body = node.body;
|
|
126410
|
-
if (body.type === "BlockStatement") {
|
|
126411
|
-
this.withNestedScope(() => {
|
|
126412
|
-
this.visitBlock(body);
|
|
126413
|
-
});
|
|
126414
|
-
} else {
|
|
126415
|
-
this.visitExpression(body);
|
|
126416
|
-
}
|
|
126417
|
-
this.functionStack.pop();
|
|
126418
|
-
}
|
|
126419
|
-
visitAwaitExpression(node) {
|
|
126420
|
-
if (!this.isAwaitAllowed()) {
|
|
126421
|
-
this.diagnostics.push({
|
|
126422
|
-
code: "AS008",
|
|
126423
|
-
severity: "error",
|
|
126424
|
-
message: MESSAGE,
|
|
126425
|
-
filename: this.filename,
|
|
126426
|
-
line: node.span.start.line,
|
|
126427
|
-
column: node.span.start.column,
|
|
126428
|
-
span: node.span
|
|
126429
|
-
});
|
|
126430
|
-
}
|
|
126431
|
-
this.visitExpression(node.argument);
|
|
126432
|
-
}
|
|
126433
|
-
visitArrayExpression(node) {
|
|
126434
|
-
for (const element of node.elements) {
|
|
126435
|
-
if (element?.type === "SpreadElement") {
|
|
126436
|
-
this.visitSpreadElement(element);
|
|
126437
|
-
continue;
|
|
126438
|
-
}
|
|
126439
|
-
if (element !== void 0) {
|
|
126440
|
-
this.visitExpression(element);
|
|
126441
|
-
}
|
|
126442
|
-
}
|
|
126443
|
-
}
|
|
126444
|
-
visitObjectExpression(node) {
|
|
126445
|
-
for (const property of node.properties) {
|
|
126446
|
-
if (property.type === "SpreadElement") {
|
|
126447
|
-
this.visitSpreadElement(property);
|
|
126448
|
-
continue;
|
|
126449
|
-
}
|
|
126450
|
-
this.visitProperty(property);
|
|
126451
|
-
}
|
|
126452
|
-
}
|
|
126453
|
-
visitUnaryExpression(node) {
|
|
126454
|
-
this.visitExpression(node.argument);
|
|
126455
|
-
}
|
|
126456
|
-
visitBinaryExpression(node) {
|
|
126457
|
-
this.visitExpression(node.left);
|
|
126458
|
-
this.visitExpression(node.right);
|
|
126459
|
-
}
|
|
126460
|
-
visitLogicalExpression(node) {
|
|
126461
|
-
this.visitExpression(node.left);
|
|
126462
|
-
this.visitExpression(node.right);
|
|
126463
|
-
}
|
|
126464
|
-
visitConditionalExpression(node) {
|
|
126465
|
-
this.visitExpression(node.test);
|
|
126466
|
-
this.visitExpression(node.consequent);
|
|
126467
|
-
this.visitExpression(node.alternate);
|
|
126468
|
-
}
|
|
126469
|
-
visitMemberExpression(node) {
|
|
126470
|
-
this.visitExpression(node.object);
|
|
126471
|
-
if (node.computed) {
|
|
126472
|
-
this.visitExpression(node.property);
|
|
126473
|
-
}
|
|
126474
|
-
}
|
|
126475
|
-
visitAssignmentExpression(node) {
|
|
126476
|
-
this.visitAssignmentTarget(node.left);
|
|
126477
|
-
this.visitExpression(node.right);
|
|
126478
|
-
}
|
|
126479
|
-
visitCallExpression(node) {
|
|
126480
|
-
this.visitExpression(node.callee);
|
|
126481
|
-
for (const argument of node.arguments) {
|
|
126482
|
-
if (argument.type === "SpreadElement") {
|
|
126483
|
-
this.visitSpreadElement(argument);
|
|
126484
|
-
continue;
|
|
126485
|
-
}
|
|
126486
|
-
this.visitExpression(argument);
|
|
126487
|
-
}
|
|
126488
|
-
}
|
|
126489
|
-
visitTemplateLiteral(node) {
|
|
126490
|
-
for (const expression of node.expressions) {
|
|
126491
|
-
this.visitExpression(expression);
|
|
126492
|
-
}
|
|
126493
|
-
}
|
|
126494
|
-
visitProperty(node) {
|
|
126495
|
-
if (node.computed) {
|
|
126496
|
-
this.visitExpression(node.key);
|
|
126497
|
-
}
|
|
126498
|
-
this.visitExpression(node.value);
|
|
126499
|
-
}
|
|
126500
|
-
visitSpreadElement(node) {
|
|
126501
|
-
this.visitExpression(node.argument);
|
|
126502
|
-
}
|
|
126503
|
-
visitAssignmentTarget(node) {
|
|
126504
|
-
if (node.type === "Identifier") {
|
|
126505
|
-
return;
|
|
126506
|
-
}
|
|
126507
|
-
if (node.type === "MetaProperty") {
|
|
126508
|
-
return;
|
|
126509
|
-
}
|
|
126510
|
-
if (node.type === "MemberExpression") {
|
|
126511
|
-
this.visitMemberExpression(node);
|
|
126512
|
-
return;
|
|
126513
|
-
}
|
|
126514
|
-
this.visitBindingPattern(node);
|
|
126515
|
-
}
|
|
126516
|
-
visitBindingElement(node) {
|
|
126517
|
-
if (node.type === "RestElement") {
|
|
126518
|
-
this.visitRestElement(node);
|
|
126519
|
-
return;
|
|
126520
|
-
}
|
|
126521
|
-
this.visitBindingPattern(node);
|
|
126522
|
-
}
|
|
126523
|
-
visitBindingPattern(node) {
|
|
126524
|
-
switch (node.type) {
|
|
126525
|
-
case "Identifier":
|
|
126526
|
-
return;
|
|
126527
|
-
case "MemberExpression":
|
|
126528
|
-
this.visitMemberExpression(node);
|
|
126529
|
-
return;
|
|
126530
|
-
case "AssignmentPattern":
|
|
126531
|
-
this.visitAssignmentPattern(node);
|
|
126532
|
-
return;
|
|
126533
|
-
case "ArrayPattern":
|
|
126534
|
-
this.visitArrayPattern(node);
|
|
126535
|
-
return;
|
|
126536
|
-
case "ObjectPattern":
|
|
126537
|
-
this.visitObjectPattern(node);
|
|
126538
|
-
return;
|
|
126539
|
-
}
|
|
126540
|
-
}
|
|
126541
|
-
visitAssignmentPattern(node) {
|
|
126542
|
-
this.visitBindingPattern(node.left);
|
|
126543
|
-
this.visitExpression(node.right);
|
|
126544
|
-
}
|
|
126545
|
-
visitArrayPattern(node) {
|
|
126546
|
-
for (const element of node.elements) {
|
|
126547
|
-
if (element === null) {
|
|
126548
|
-
continue;
|
|
126549
|
-
}
|
|
126550
|
-
if (element.type === "RestElement") {
|
|
126551
|
-
this.visitRestElement(element);
|
|
126552
|
-
continue;
|
|
126553
|
-
}
|
|
126554
|
-
this.visitBindingPattern(element);
|
|
126555
|
-
}
|
|
126556
|
-
}
|
|
126557
|
-
visitObjectPattern(node) {
|
|
126558
|
-
for (const property of node.properties) {
|
|
126559
|
-
if (property.type === "RestElement") {
|
|
126560
|
-
this.visitRestElement(property);
|
|
126561
|
-
continue;
|
|
126562
|
-
}
|
|
126563
|
-
this.visitAssignmentProperty(property);
|
|
126564
|
-
}
|
|
126565
|
-
}
|
|
126566
|
-
visitAssignmentProperty(node) {
|
|
126567
|
-
if (node.computed) {
|
|
126568
|
-
this.visitExpression(node.key);
|
|
126569
|
-
}
|
|
126570
|
-
this.visitBindingPattern(node.value);
|
|
126571
|
-
}
|
|
126572
|
-
visitRestElement(node) {
|
|
126573
|
-
this.visitAssignmentTarget(node.argument);
|
|
126574
|
-
}
|
|
126575
|
-
isAwaitAllowed() {
|
|
126576
|
-
const currentFunction = this.functionStack.at(-1);
|
|
126577
|
-
if (currentFunction !== void 0) {
|
|
126578
|
-
return true;
|
|
126579
|
-
}
|
|
126580
|
-
return this.scopeDepth === 0;
|
|
126581
|
-
}
|
|
126582
|
-
withNestedScope(callback) {
|
|
126583
|
-
this.scopeDepth += 1;
|
|
126584
|
-
try {
|
|
126585
|
-
callback();
|
|
126586
|
-
} finally {
|
|
126587
|
-
this.scopeDepth -= 1;
|
|
126588
|
-
}
|
|
126589
|
-
}
|
|
126590
|
-
};
|
|
126591
|
-
}
|
|
126592
|
-
});
|
|
126593
|
-
|
|
126594
126389
|
// packages/safejs/src/lint/rules/AS009.ts
|
|
126595
126390
|
function AS009(source, options = {}) {
|
|
126596
126391
|
return new AS009Scanner(options.filename ?? "<input>").scan(source);
|
|
126597
126392
|
}
|
|
126598
|
-
var
|
|
126393
|
+
var MESSAGE, AS009Scanner;
|
|
126599
126394
|
var init_AS009 = __esm({
|
|
126600
126395
|
"packages/safejs/src/lint/rules/AS009.ts"() {
|
|
126601
126396
|
"use strict";
|
|
126602
126397
|
init_parser3();
|
|
126603
|
-
|
|
126398
|
+
MESSAGE = "Async arrow returns a host call without awaiting it. Add 'await' or document that this function intentionally returns a Promise.";
|
|
126604
126399
|
AS009Scanner = class {
|
|
126605
126400
|
constructor(filename) {
|
|
126606
126401
|
this.filename = filename;
|
|
@@ -126950,7 +126745,7 @@ var init_AS009 = __esm({
|
|
|
126950
126745
|
this.diagnostics.push({
|
|
126951
126746
|
code: "AS009",
|
|
126952
126747
|
severity: "error",
|
|
126953
|
-
message:
|
|
126748
|
+
message: MESSAGE,
|
|
126954
126749
|
filename: this.filename,
|
|
126955
126750
|
line: node.span.start.line,
|
|
126956
126751
|
column: node.span.start.column,
|
|
@@ -127746,13 +127541,13 @@ var init_AS010 = __esm({
|
|
|
127746
127541
|
function AS011(source, options = {}) {
|
|
127747
127542
|
return new AS011Scanner(options.filename ?? "<input>").scan(source);
|
|
127748
127543
|
}
|
|
127749
|
-
var FORBIDDEN_PROPERTY_NAMES,
|
|
127544
|
+
var FORBIDDEN_PROPERTY_NAMES, MESSAGE2, AS011Scanner;
|
|
127750
127545
|
var init_AS011 = __esm({
|
|
127751
127546
|
"packages/safejs/src/lint/rules/AS011.ts"() {
|
|
127752
127547
|
"use strict";
|
|
127753
127548
|
init_parser3();
|
|
127754
127549
|
FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
127755
|
-
|
|
127550
|
+
MESSAGE2 = "Property access to '__proto__', 'prototype', and 'constructor' is not allowed.";
|
|
127756
127551
|
AS011Scanner = class {
|
|
127757
127552
|
constructor(filename) {
|
|
127758
127553
|
this.filename = filename;
|
|
@@ -128074,7 +127869,7 @@ var init_AS011 = __esm({
|
|
|
128074
127869
|
this.diagnostics.push({
|
|
128075
127870
|
code: "AS011",
|
|
128076
127871
|
severity: "error",
|
|
128077
|
-
message:
|
|
127872
|
+
message: MESSAGE2,
|
|
128078
127873
|
filename: this.filename,
|
|
128079
127874
|
line: span.start.line,
|
|
128080
127875
|
column: span.start.column,
|
|
@@ -129052,314 +128847,6 @@ var init_AS_async_not_needed = __esm({
|
|
|
129052
128847
|
}
|
|
129053
128848
|
});
|
|
129054
128849
|
|
|
129055
|
-
// packages/safejs/src/lint/rules/AS-await-non-promise.ts
|
|
129056
|
-
function AS_AWAIT_NON_PROMISE(source, options = {}) {
|
|
129057
|
-
return new ASAwaitNonPromiseScanner(options.filename ?? "<input>").scan(source);
|
|
129058
|
-
}
|
|
129059
|
-
function isKnownNonPromiseExpression(node) {
|
|
129060
|
-
switch (node.type) {
|
|
129061
|
-
case "FunctionExpression":
|
|
129062
|
-
case "ArrowFunctionExpression":
|
|
129063
|
-
case "ArrayExpression":
|
|
129064
|
-
case "BinaryExpression":
|
|
129065
|
-
case "BooleanLiteral":
|
|
129066
|
-
case "NullLiteral":
|
|
129067
|
-
case "NumericLiteral":
|
|
129068
|
-
case "ObjectExpression":
|
|
129069
|
-
case "StringLiteral":
|
|
129070
|
-
case "TemplateLiteral":
|
|
129071
|
-
case "UnaryExpression":
|
|
129072
|
-
return true;
|
|
129073
|
-
default:
|
|
129074
|
-
return false;
|
|
129075
|
-
}
|
|
129076
|
-
}
|
|
129077
|
-
var ASAwaitNonPromiseScanner;
|
|
129078
|
-
var init_AS_await_non_promise = __esm({
|
|
129079
|
-
"packages/safejs/src/lint/rules/AS-await-non-promise.ts"() {
|
|
129080
|
-
"use strict";
|
|
129081
|
-
init_parser3();
|
|
129082
|
-
ASAwaitNonPromiseScanner = class {
|
|
129083
|
-
constructor(filename) {
|
|
129084
|
-
this.filename = filename;
|
|
129085
|
-
}
|
|
129086
|
-
filename;
|
|
129087
|
-
diagnostics = [];
|
|
129088
|
-
scan(source) {
|
|
129089
|
-
this.visitModule(parseModule(source, this.filename));
|
|
129090
|
-
return this.diagnostics;
|
|
129091
|
-
}
|
|
129092
|
-
visitModule(node) {
|
|
129093
|
-
for (const statement of node.body) {
|
|
129094
|
-
this.visitStatement(statement);
|
|
129095
|
-
}
|
|
129096
|
-
}
|
|
129097
|
-
visitStatement(node) {
|
|
129098
|
-
switch (node.type) {
|
|
129099
|
-
case "FunctionDeclaration":
|
|
129100
|
-
this.visitArrowFunction(node);
|
|
129101
|
-
return;
|
|
129102
|
-
case "BlockStatement":
|
|
129103
|
-
this.visitBlockStatement(node);
|
|
129104
|
-
return;
|
|
129105
|
-
case "ExpressionStatement":
|
|
129106
|
-
this.visitExpression(node.expression);
|
|
129107
|
-
return;
|
|
129108
|
-
case "IfStatement":
|
|
129109
|
-
this.visitIfStatement(node);
|
|
129110
|
-
return;
|
|
129111
|
-
case "ForStatement":
|
|
129112
|
-
this.visitForStatement(node);
|
|
129113
|
-
return;
|
|
129114
|
-
case "ForInStatement":
|
|
129115
|
-
case "ForOfStatement":
|
|
129116
|
-
this.visitForOfStatement(node);
|
|
129117
|
-
return;
|
|
129118
|
-
case "WhileStatement":
|
|
129119
|
-
case "DoWhileStatement":
|
|
129120
|
-
this.visitWhileStatement(node);
|
|
129121
|
-
return;
|
|
129122
|
-
case "TryStatement":
|
|
129123
|
-
this.visitTryStatement(node);
|
|
129124
|
-
return;
|
|
129125
|
-
case "VariableDeclaration":
|
|
129126
|
-
this.visitVariableDeclaration(node);
|
|
129127
|
-
return;
|
|
129128
|
-
case "ReturnStatement":
|
|
129129
|
-
this.visitReturnStatement(node);
|
|
129130
|
-
return;
|
|
129131
|
-
case "ThrowStatement":
|
|
129132
|
-
this.visitThrowStatement(node);
|
|
129133
|
-
return;
|
|
129134
|
-
case "ExportNamedDeclaration":
|
|
129135
|
-
this.visitVariableDeclaration(node.declaration);
|
|
129136
|
-
return;
|
|
129137
|
-
case "ExportDefaultDeclaration":
|
|
129138
|
-
this.visitExpression(node.declaration);
|
|
129139
|
-
return;
|
|
129140
|
-
case "ImportDeclaration":
|
|
129141
|
-
case "BreakStatement":
|
|
129142
|
-
case "ContinueStatement":
|
|
129143
|
-
return;
|
|
129144
|
-
}
|
|
129145
|
-
}
|
|
129146
|
-
visitBlockStatement(node) {
|
|
129147
|
-
for (const statement of node.body) {
|
|
129148
|
-
this.visitStatement(statement);
|
|
129149
|
-
}
|
|
129150
|
-
}
|
|
129151
|
-
visitIfStatement(node) {
|
|
129152
|
-
this.visitExpression(node.test);
|
|
129153
|
-
this.visitStatement(node.consequent);
|
|
129154
|
-
if (node.alternate !== void 0) {
|
|
129155
|
-
this.visitStatement(node.alternate);
|
|
129156
|
-
}
|
|
129157
|
-
}
|
|
129158
|
-
visitForStatement(node) {
|
|
129159
|
-
if (node.init !== void 0) {
|
|
129160
|
-
if (node.init.type === "VariableDeclaration") {
|
|
129161
|
-
this.visitVariableDeclaration(node.init);
|
|
129162
|
-
} else {
|
|
129163
|
-
this.visitExpression(node.init);
|
|
129164
|
-
}
|
|
129165
|
-
}
|
|
129166
|
-
if (node.test !== void 0) {
|
|
129167
|
-
this.visitExpression(node.test);
|
|
129168
|
-
}
|
|
129169
|
-
if (node.update !== void 0) {
|
|
129170
|
-
this.visitExpression(node.update);
|
|
129171
|
-
}
|
|
129172
|
-
this.visitStatement(node.body);
|
|
129173
|
-
}
|
|
129174
|
-
visitForOfStatement(node) {
|
|
129175
|
-
if (node.left.type === "VariableDeclaration") {
|
|
129176
|
-
this.visitVariableDeclaration(node.left);
|
|
129177
|
-
}
|
|
129178
|
-
this.visitExpression(node.right);
|
|
129179
|
-
this.visitStatement(node.body);
|
|
129180
|
-
}
|
|
129181
|
-
visitWhileStatement(node) {
|
|
129182
|
-
this.visitExpression(node.test);
|
|
129183
|
-
this.visitStatement(node.body);
|
|
129184
|
-
}
|
|
129185
|
-
visitTryStatement(node) {
|
|
129186
|
-
this.visitBlockStatement(node.block);
|
|
129187
|
-
if (node.handler !== void 0) {
|
|
129188
|
-
this.visitCatchClause(node.handler);
|
|
129189
|
-
}
|
|
129190
|
-
if (node.finalizer !== void 0) {
|
|
129191
|
-
this.visitBlockStatement(node.finalizer);
|
|
129192
|
-
}
|
|
129193
|
-
}
|
|
129194
|
-
visitCatchClause(node) {
|
|
129195
|
-
this.visitBlockStatement(node.body);
|
|
129196
|
-
}
|
|
129197
|
-
visitVariableDeclaration(node) {
|
|
129198
|
-
for (const declarator of node.declarations) {
|
|
129199
|
-
this.visitVariableDeclarator(declarator);
|
|
129200
|
-
}
|
|
129201
|
-
}
|
|
129202
|
-
visitVariableDeclarator(node) {
|
|
129203
|
-
if (node.init !== void 0) {
|
|
129204
|
-
this.visitExpression(node.init);
|
|
129205
|
-
}
|
|
129206
|
-
}
|
|
129207
|
-
visitReturnStatement(node) {
|
|
129208
|
-
if (node.argument !== void 0) {
|
|
129209
|
-
this.visitExpression(node.argument);
|
|
129210
|
-
}
|
|
129211
|
-
}
|
|
129212
|
-
visitThrowStatement(node) {
|
|
129213
|
-
this.visitExpression(node.argument);
|
|
129214
|
-
}
|
|
129215
|
-
visitExpression(node) {
|
|
129216
|
-
switch (node.type) {
|
|
129217
|
-
case "YieldExpression":
|
|
129218
|
-
if (node.argument !== void 0) {
|
|
129219
|
-
this.visitExpression(node.argument);
|
|
129220
|
-
}
|
|
129221
|
-
return;
|
|
129222
|
-
case "FunctionExpression":
|
|
129223
|
-
case "ArrowFunctionExpression":
|
|
129224
|
-
this.visitArrowFunction(node);
|
|
129225
|
-
return;
|
|
129226
|
-
case "AwaitExpression":
|
|
129227
|
-
this.visitAwaitExpression(node);
|
|
129228
|
-
return;
|
|
129229
|
-
case "ArrayExpression":
|
|
129230
|
-
this.visitArrayExpression(node);
|
|
129231
|
-
return;
|
|
129232
|
-
case "ObjectExpression":
|
|
129233
|
-
this.visitObjectExpression(node);
|
|
129234
|
-
return;
|
|
129235
|
-
case "UnaryExpression":
|
|
129236
|
-
this.visitUnaryExpression(node);
|
|
129237
|
-
return;
|
|
129238
|
-
case "BinaryExpression":
|
|
129239
|
-
case "LogicalExpression":
|
|
129240
|
-
this.visitBinaryLikeExpression(node);
|
|
129241
|
-
return;
|
|
129242
|
-
case "ConditionalExpression":
|
|
129243
|
-
this.visitConditionalExpression(node);
|
|
129244
|
-
return;
|
|
129245
|
-
case "MemberExpression":
|
|
129246
|
-
this.visitMemberExpression(node);
|
|
129247
|
-
return;
|
|
129248
|
-
case "AssignmentExpression":
|
|
129249
|
-
this.visitAssignmentExpression(node);
|
|
129250
|
-
return;
|
|
129251
|
-
case "CallExpression":
|
|
129252
|
-
this.visitCallExpression(node);
|
|
129253
|
-
return;
|
|
129254
|
-
case "TemplateLiteral":
|
|
129255
|
-
this.visitTemplateLiteral(node);
|
|
129256
|
-
return;
|
|
129257
|
-
case "TaggedTemplateExpression":
|
|
129258
|
-
this.visitTaggedTemplateExpression(node);
|
|
129259
|
-
return;
|
|
129260
|
-
case "Identifier":
|
|
129261
|
-
case "BooleanLiteral":
|
|
129262
|
-
case "MetaProperty":
|
|
129263
|
-
case "NullLiteral":
|
|
129264
|
-
case "NumericLiteral":
|
|
129265
|
-
case "RegexLiteral":
|
|
129266
|
-
case "StringLiteral":
|
|
129267
|
-
case "UndefinedLiteral":
|
|
129268
|
-
return;
|
|
129269
|
-
}
|
|
129270
|
-
}
|
|
129271
|
-
visitArrowFunction(node) {
|
|
129272
|
-
if (node.body.type === "BlockStatement") {
|
|
129273
|
-
this.visitBlockStatement(node.body);
|
|
129274
|
-
return;
|
|
129275
|
-
}
|
|
129276
|
-
this.visitExpression(node.body);
|
|
129277
|
-
}
|
|
129278
|
-
visitAwaitExpression(node) {
|
|
129279
|
-
if (isKnownNonPromiseExpression(node.argument)) {
|
|
129280
|
-
this.report(node.argument.span);
|
|
129281
|
-
}
|
|
129282
|
-
this.visitExpression(node.argument);
|
|
129283
|
-
}
|
|
129284
|
-
visitArrayExpression(node) {
|
|
129285
|
-
for (const element of node.elements) {
|
|
129286
|
-
if (element.type === "SpreadElement") {
|
|
129287
|
-
this.visitExpression(element.argument);
|
|
129288
|
-
continue;
|
|
129289
|
-
}
|
|
129290
|
-
this.visitExpression(element);
|
|
129291
|
-
}
|
|
129292
|
-
}
|
|
129293
|
-
visitObjectExpression(node) {
|
|
129294
|
-
for (const property of node.properties) {
|
|
129295
|
-
if (property.type === "SpreadElement") {
|
|
129296
|
-
this.visitExpression(property.argument);
|
|
129297
|
-
continue;
|
|
129298
|
-
}
|
|
129299
|
-
this.visitProperty(property);
|
|
129300
|
-
}
|
|
129301
|
-
}
|
|
129302
|
-
visitProperty(node) {
|
|
129303
|
-
if (node.computed) {
|
|
129304
|
-
this.visitExpression(node.key);
|
|
129305
|
-
}
|
|
129306
|
-
this.visitExpression(node.value);
|
|
129307
|
-
}
|
|
129308
|
-
visitUnaryExpression(node) {
|
|
129309
|
-
this.visitExpression(node.argument);
|
|
129310
|
-
}
|
|
129311
|
-
visitBinaryLikeExpression(node) {
|
|
129312
|
-
this.visitExpression(node.left);
|
|
129313
|
-
this.visitExpression(node.right);
|
|
129314
|
-
}
|
|
129315
|
-
visitConditionalExpression(node) {
|
|
129316
|
-
this.visitExpression(node.test);
|
|
129317
|
-
this.visitExpression(node.consequent);
|
|
129318
|
-
this.visitExpression(node.alternate);
|
|
129319
|
-
}
|
|
129320
|
-
visitMemberExpression(node) {
|
|
129321
|
-
this.visitExpression(node.object);
|
|
129322
|
-
if (node.computed) {
|
|
129323
|
-
this.visitExpression(node.property);
|
|
129324
|
-
}
|
|
129325
|
-
}
|
|
129326
|
-
visitAssignmentExpression(node) {
|
|
129327
|
-
this.visitExpression(node.right);
|
|
129328
|
-
}
|
|
129329
|
-
visitCallExpression(node) {
|
|
129330
|
-
this.visitExpression(node.callee);
|
|
129331
|
-
for (const argument of node.arguments) {
|
|
129332
|
-
if (argument.type === "SpreadElement") {
|
|
129333
|
-
this.visitExpression(argument.argument);
|
|
129334
|
-
continue;
|
|
129335
|
-
}
|
|
129336
|
-
this.visitExpression(argument);
|
|
129337
|
-
}
|
|
129338
|
-
}
|
|
129339
|
-
visitTemplateLiteral(node) {
|
|
129340
|
-
for (const expression of node.expressions) {
|
|
129341
|
-
this.visitExpression(expression);
|
|
129342
|
-
}
|
|
129343
|
-
}
|
|
129344
|
-
visitTaggedTemplateExpression(node) {
|
|
129345
|
-
this.visitExpression(node.tag);
|
|
129346
|
-
this.visitTemplateLiteral(node.quasi);
|
|
129347
|
-
}
|
|
129348
|
-
report(span) {
|
|
129349
|
-
this.diagnostics.push({
|
|
129350
|
-
code: "AS-AWAIT-NON-PROMISE",
|
|
129351
|
-
severity: "warning",
|
|
129352
|
-
message: "Awaiting a known non-promise value has no effect.",
|
|
129353
|
-
filename: this.filename,
|
|
129354
|
-
line: span.start.line,
|
|
129355
|
-
column: span.start.column,
|
|
129356
|
-
span
|
|
129357
|
-
});
|
|
129358
|
-
}
|
|
129359
|
-
};
|
|
129360
|
-
}
|
|
129361
|
-
});
|
|
129362
|
-
|
|
129363
128850
|
// packages/safejs/src/lint/rules/AS-destructure-null-default.ts
|
|
129364
128851
|
function AS_DESTRUCTURE_NULL_DEFAULT(source, options = {}) {
|
|
129365
128852
|
return new ASDestructureNullDefaultScanner(options.filename ?? "<input>").scan(source);
|
|
@@ -129403,12 +128890,12 @@ function getStaticPropertyKey(key3) {
|
|
|
129403
128890
|
return void 0;
|
|
129404
128891
|
}
|
|
129405
128892
|
}
|
|
129406
|
-
var
|
|
128893
|
+
var MESSAGE3, HINT, ASDestructureNullDefaultScanner;
|
|
129407
128894
|
var init_AS_destructure_null_default = __esm({
|
|
129408
128895
|
"packages/safejs/src/lint/rules/AS-destructure-null-default.ts"() {
|
|
129409
128896
|
"use strict";
|
|
129410
128897
|
init_parser3();
|
|
129411
|
-
|
|
128898
|
+
MESSAGE3 = "Destructuring default values only apply to undefined, not null.";
|
|
129412
128899
|
HINT = "Handle null explicitly before destructuring or use ?? after binding.";
|
|
129413
128900
|
ASDestructureNullDefaultScanner = class {
|
|
129414
128901
|
constructor(filename) {
|
|
@@ -129800,7 +129287,7 @@ var init_AS_destructure_null_default = __esm({
|
|
|
129800
129287
|
this.diagnostics.push({
|
|
129801
129288
|
code: "AS-DESTRUCTURE-NULL-DEFAULT",
|
|
129802
129289
|
severity: "warning",
|
|
129803
|
-
message:
|
|
129290
|
+
message: MESSAGE3,
|
|
129804
129291
|
filename: this.filename,
|
|
129805
129292
|
line: span.start.line,
|
|
129806
129293
|
column: span.start.column,
|
|
@@ -134417,12 +133904,12 @@ function bodyHasExit(node, exitingLabels, allowUnlabeledBreak) {
|
|
|
134417
133904
|
return false;
|
|
134418
133905
|
}
|
|
134419
133906
|
}
|
|
134420
|
-
var
|
|
133907
|
+
var MESSAGE4, ASUnboundedLoopScanner;
|
|
134421
133908
|
var init_AS_unbounded_loop = __esm({
|
|
134422
133909
|
"packages/safejs/src/lint/rules/AS-unbounded-loop.ts"() {
|
|
134423
133910
|
"use strict";
|
|
134424
133911
|
init_parser3();
|
|
134425
|
-
|
|
133912
|
+
MESSAGE4 = "Unbounded loop or generator source has no static exit with break, return, or throw.";
|
|
134426
133913
|
ASUnboundedLoopScanner = class {
|
|
134427
133914
|
constructor(filename) {
|
|
134428
133915
|
this.filename = filename;
|
|
@@ -134720,7 +134207,7 @@ var init_AS_unbounded_loop = __esm({
|
|
|
134720
134207
|
this.diagnostics.push({
|
|
134721
134208
|
code: "AS-UNBOUNDED-LOOP",
|
|
134722
134209
|
severity: "warning",
|
|
134723
|
-
message:
|
|
134210
|
+
message: MESSAGE4,
|
|
134724
134211
|
filename: this.filename,
|
|
134725
134212
|
line: node.span.start.line,
|
|
134726
134213
|
column: node.span.start.column,
|
|
@@ -135994,14 +135481,12 @@ var init_lint3 = __esm({
|
|
|
135994
135481
|
init_AS004();
|
|
135995
135482
|
init_AS005();
|
|
135996
135483
|
init_AS006_007();
|
|
135997
|
-
init_AS008();
|
|
135998
135484
|
init_AS009();
|
|
135999
135485
|
init_AS010();
|
|
136000
135486
|
init_AS011();
|
|
136001
135487
|
init_AS013();
|
|
136002
135488
|
init_AS015();
|
|
136003
135489
|
init_AS_async_not_needed();
|
|
136004
|
-
init_AS_await_non_promise();
|
|
136005
135490
|
init_AS_destructure_null_default();
|
|
136006
135491
|
init_AS_export_import_meta();
|
|
136007
135492
|
init_AS_floating_promise();
|
|
@@ -136026,14 +135511,12 @@ var init_lint3 = __esm({
|
|
|
136026
135511
|
AS_UNUSED_IMPORT,
|
|
136027
135512
|
AS006_007,
|
|
136028
135513
|
AS_MISSING_ASYNC,
|
|
136029
|
-
AS008,
|
|
136030
135514
|
AS009,
|
|
136031
135515
|
AS010,
|
|
136032
135516
|
AS011,
|
|
136033
135517
|
AS013,
|
|
136034
135518
|
AS015,
|
|
136035
135519
|
AS_IMPORT_CYCLE,
|
|
136036
|
-
AS_AWAIT_NON_PROMISE,
|
|
136037
135520
|
AS_FLOATING_PROMISE,
|
|
136038
135521
|
AS_ASYNC_NOT_NEEDED,
|
|
136039
135522
|
AS_JSDOC_TYPE,
|
|
@@ -137035,7 +136518,7 @@ var init_dump_format = __esm({
|
|
|
137035
136518
|
init_arguments();
|
|
137036
136519
|
init_arguments2();
|
|
137037
136520
|
DUMP_FORMAT_VERSION = 1;
|
|
137038
|
-
EXECUTION_SEMANTICS = "jobs-
|
|
136521
|
+
EXECUTION_SEMANTICS = "jobs-v3";
|
|
137039
136522
|
SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
|
|
137040
136523
|
}
|
|
137041
136524
|
});
|
|
@@ -141163,7 +140646,7 @@ async function bindPattern2(pattern, value, target, scope, context) {
|
|
|
141163
140646
|
}
|
|
141164
140647
|
}
|
|
141165
140648
|
function bindIdentifier(pattern, value, target, scope) {
|
|
141166
|
-
if ("assign" in target || target.kind === "var") {
|
|
140649
|
+
if ("assign" in target || target.kind === "var" && target.initialize !== true) {
|
|
141167
140650
|
if ("assign" in target) {
|
|
141168
140651
|
const binding = scope.lookup(pattern.name);
|
|
141169
140652
|
if (!binding.found) {
|
|
@@ -141357,136 +140840,18 @@ var init_patterns = __esm({
|
|
|
141357
140840
|
|
|
141358
140841
|
// packages/safejs/src/interp/var-hoist.ts
|
|
141359
140842
|
function hoistVarDeclarations(node, scope) {
|
|
141360
|
-
|
|
141361
|
-
for (const
|
|
141362
|
-
|
|
141363
|
-
|
|
141364
|
-
return;
|
|
141365
|
-
}
|
|
141366
|
-
switch (node.type) {
|
|
141367
|
-
case "VariableDeclaration":
|
|
141368
|
-
case "IfStatement":
|
|
141369
|
-
case "ForStatement":
|
|
141370
|
-
case "ForInStatement":
|
|
141371
|
-
case "ForOfStatement":
|
|
141372
|
-
case "WhileStatement":
|
|
141373
|
-
case "DoWhileStatement":
|
|
141374
|
-
case "TryStatement":
|
|
141375
|
-
case "SwitchStatement":
|
|
141376
|
-
case "ExportNamedDeclaration":
|
|
141377
|
-
hoistVarStatement(node, scope);
|
|
141378
|
-
return;
|
|
141379
|
-
default:
|
|
141380
|
-
return;
|
|
141381
|
-
}
|
|
141382
|
-
}
|
|
141383
|
-
function hoistVarStatement(statement, scope) {
|
|
141384
|
-
switch (statement.type) {
|
|
141385
|
-
case "VariableDeclaration":
|
|
141386
|
-
declareVarBindings(statement, scope);
|
|
141387
|
-
return;
|
|
141388
|
-
case "BlockStatement":
|
|
141389
|
-
hoistVarDeclarations(statement, scope);
|
|
141390
|
-
return;
|
|
141391
|
-
case "IfStatement":
|
|
141392
|
-
hoistVarStatement(statement.consequent, scope);
|
|
141393
|
-
if (statement.alternate !== void 0) {
|
|
141394
|
-
hoistVarStatement(statement.alternate, scope);
|
|
141395
|
-
}
|
|
141396
|
-
return;
|
|
141397
|
-
case "ForStatement":
|
|
141398
|
-
if (statement.init?.type === "VariableDeclaration") {
|
|
141399
|
-
declareVarBindings(statement.init, scope);
|
|
141400
|
-
}
|
|
141401
|
-
hoistVarStatement(statement.body, scope);
|
|
141402
|
-
return;
|
|
141403
|
-
case "ForInStatement":
|
|
141404
|
-
case "ForOfStatement":
|
|
141405
|
-
if (statement.left.type === "VariableDeclaration") {
|
|
141406
|
-
declareVarBindings(statement.left, scope);
|
|
141407
|
-
}
|
|
141408
|
-
hoistVarStatement(statement.body, scope);
|
|
141409
|
-
return;
|
|
141410
|
-
case "WhileStatement":
|
|
141411
|
-
case "DoWhileStatement":
|
|
141412
|
-
hoistVarStatement(statement.body, scope);
|
|
141413
|
-
return;
|
|
141414
|
-
case "TryStatement":
|
|
141415
|
-
hoistVarDeclarations(statement.block, scope);
|
|
141416
|
-
if (statement.handler !== void 0) {
|
|
141417
|
-
hoistVarDeclarations(statement.handler.body, scope);
|
|
141418
|
-
}
|
|
141419
|
-
if (statement.finalizer !== void 0) {
|
|
141420
|
-
hoistVarDeclarations(statement.finalizer, scope);
|
|
141421
|
-
}
|
|
141422
|
-
return;
|
|
141423
|
-
case "SwitchStatement":
|
|
141424
|
-
for (const switchCase of statement.cases) {
|
|
141425
|
-
for (const consequent of switchCase.consequent) {
|
|
141426
|
-
hoistVarStatement(consequent, scope);
|
|
141427
|
-
}
|
|
140843
|
+
for (const declaration of hoistedVarDeclarations([node])) {
|
|
140844
|
+
for (const declarator of declaration.declarations) {
|
|
140845
|
+
for (const identifier of boundIdentifiers(declarator.id)) {
|
|
140846
|
+
scope.declareVar(identifier.name);
|
|
141428
140847
|
}
|
|
141429
|
-
return;
|
|
141430
|
-
case "ExportNamedDeclaration":
|
|
141431
|
-
hoistVarStatement(statement.declaration, scope);
|
|
141432
|
-
return;
|
|
141433
|
-
case "FunctionDeclaration":
|
|
141434
|
-
case "ExportDefaultDeclaration":
|
|
141435
|
-
case "ImportDeclaration":
|
|
141436
|
-
case "BreakStatement":
|
|
141437
|
-
case "ContinueStatement":
|
|
141438
|
-
case "EmptyStatement":
|
|
141439
|
-
case "ExpressionStatement":
|
|
141440
|
-
case "ReturnStatement":
|
|
141441
|
-
case "ThrowStatement":
|
|
141442
|
-
return;
|
|
141443
|
-
}
|
|
141444
|
-
}
|
|
141445
|
-
function declareVarBindings(declaration, scope) {
|
|
141446
|
-
if (declaration.kind !== "var") {
|
|
141447
|
-
return;
|
|
141448
|
-
}
|
|
141449
|
-
for (const declarator of declaration.declarations) {
|
|
141450
|
-
for (const name of getPatternBindingNames2(declarator.id)) {
|
|
141451
|
-
scope.declareVar(name);
|
|
141452
140848
|
}
|
|
141453
140849
|
}
|
|
141454
140850
|
}
|
|
141455
|
-
function getPatternBindingNames2(pattern) {
|
|
141456
|
-
switch (pattern.type) {
|
|
141457
|
-
case "Identifier":
|
|
141458
|
-
return [pattern.name];
|
|
141459
|
-
case "ArrayPattern":
|
|
141460
|
-
return pattern.elements.flatMap(
|
|
141461
|
-
(element) => element === null || element.type === "MemberExpression" ? [] : getNestedPatternBindingNames(element)
|
|
141462
|
-
);
|
|
141463
|
-
case "ObjectPattern":
|
|
141464
|
-
return pattern.properties.flatMap(
|
|
141465
|
-
(property) => property.type === "RestElement" ? property.argument.type === "MemberExpression" ? [] : getNestedPatternBindingNames(property.argument) : property.value.type === "MemberExpression" ? [] : getNestedPatternBindingNames(property.value)
|
|
141466
|
-
);
|
|
141467
|
-
}
|
|
141468
|
-
}
|
|
141469
|
-
function getNestedPatternBindingNames(pattern) {
|
|
141470
|
-
switch (pattern.type) {
|
|
141471
|
-
case "Identifier":
|
|
141472
|
-
return [pattern.name];
|
|
141473
|
-
case "AssignmentPattern":
|
|
141474
|
-
return pattern.left.type === "MemberExpression" ? [] : getNestedPatternBindingNames(pattern.left);
|
|
141475
|
-
case "RestElement":
|
|
141476
|
-
return pattern.argument.type === "MemberExpression" ? [] : getNestedPatternBindingNames(pattern.argument);
|
|
141477
|
-
case "ArrayPattern":
|
|
141478
|
-
return pattern.elements.flatMap(
|
|
141479
|
-
(element) => element === null || element.type === "MemberExpression" ? [] : getNestedPatternBindingNames(element)
|
|
141480
|
-
);
|
|
141481
|
-
case "ObjectPattern":
|
|
141482
|
-
return pattern.properties.flatMap(
|
|
141483
|
-
(property) => property.type === "RestElement" ? property.argument.type === "MemberExpression" ? [] : getNestedPatternBindingNames(property.argument) : property.value.type === "MemberExpression" ? [] : getNestedPatternBindingNames(property.value)
|
|
141484
|
-
);
|
|
141485
|
-
}
|
|
141486
|
-
}
|
|
141487
140851
|
var init_var_hoist = __esm({
|
|
141488
140852
|
"packages/safejs/src/interp/var-hoist.ts"() {
|
|
141489
140853
|
"use strict";
|
|
140854
|
+
init_bindings();
|
|
141490
140855
|
}
|
|
141491
140856
|
});
|
|
141492
140857
|
|
|
@@ -141609,6 +140974,7 @@ function createGeneratorClosure(node, context, evaluateNode3) {
|
|
|
141609
140974
|
const channel = createGeneratorChannel(async (generatorYield) => {
|
|
141610
140975
|
const result = await evaluateNode3(node.body, {
|
|
141611
140976
|
...closureContext,
|
|
140977
|
+
functionBody: node.body,
|
|
141612
140978
|
generatorYield: (value, yieldNodeId) => {
|
|
141613
140979
|
generator.state = "suspended";
|
|
141614
140980
|
return generatorYield(value, yieldNodeId);
|
|
@@ -141660,6 +141026,7 @@ async function executeClosure(node, args, thisValue, context, evaluateNode3) {
|
|
|
141660
141026
|
const scope = await createClosureScope(node, args, thisValue, context, evaluateNode3);
|
|
141661
141027
|
const result = await evaluateNode3(node.body, {
|
|
141662
141028
|
...context,
|
|
141029
|
+
functionBody: node.body.type === "BlockStatement" ? node.body : void 0,
|
|
141663
141030
|
scope
|
|
141664
141031
|
});
|
|
141665
141032
|
if (result.kind === "error") {
|
|
@@ -141681,16 +141048,28 @@ async function createClosureScope(node, args, thisValue, context, evaluateNode3)
|
|
|
141681
141048
|
scope.declare("arguments", "let", createSandboxArguments(args));
|
|
141682
141049
|
}
|
|
141683
141050
|
await bindParameters(node.params, args, scope, context, evaluateNode3);
|
|
141684
|
-
|
|
141685
|
-
|
|
141051
|
+
const bodyScope = node.params.some(containsParameterExpression) ? scope.child({}, { functionBoundary: true }) : scope;
|
|
141052
|
+
hoistVarDeclarations(node.body, bodyScope);
|
|
141053
|
+
if (bodyScope !== scope) {
|
|
141054
|
+
for (const declaration of hoistedVarDeclarations([node.body])) {
|
|
141055
|
+
for (const declarator of declaration.declarations) {
|
|
141056
|
+
for (const identifier of boundIdentifiers(declarator.id)) {
|
|
141057
|
+
if (!scope.hasOwnBinding(identifier.name)) continue;
|
|
141058
|
+
const parameter = scope.lookup(identifier.name);
|
|
141059
|
+
if (parameter.found) bodyScope.assign(identifier.name, parameter.value);
|
|
141060
|
+
}
|
|
141061
|
+
}
|
|
141062
|
+
}
|
|
141063
|
+
}
|
|
141064
|
+
return bodyScope;
|
|
141686
141065
|
}
|
|
141687
141066
|
function isBlockBody(body) {
|
|
141688
141067
|
return body.type === "BlockStatement";
|
|
141689
141068
|
}
|
|
141690
141069
|
async function bindParameters(params, args, scope, context, evaluateNode3) {
|
|
141691
141070
|
for (const param of params) {
|
|
141692
|
-
for (const
|
|
141693
|
-
scope.predeclare(name, "
|
|
141071
|
+
for (const identifier of boundIdentifiers(param)) {
|
|
141072
|
+
scope.predeclare(identifier.name, "var");
|
|
141694
141073
|
}
|
|
141695
141074
|
}
|
|
141696
141075
|
for (let index = 0; index < params.length; index += 1) {
|
|
@@ -141698,7 +141077,7 @@ async function bindParameters(params, args, scope, context, evaluateNode3) {
|
|
|
141698
141077
|
if (param.type === "RestElement") {
|
|
141699
141078
|
const rest = args.slice(index);
|
|
141700
141079
|
context.budget.allocateArrayLength(rest.length);
|
|
141701
|
-
const binding2 = await bindPattern2(param, rest, { kind: "
|
|
141080
|
+
const binding2 = await bindPattern2(param, rest, { kind: "var", initialize: true }, scope, {
|
|
141702
141081
|
evaluate: (defaultNode) => evaluateNode3(defaultNode, { ...context, scope })
|
|
141703
141082
|
});
|
|
141704
141083
|
if (!binding2.ok) {
|
|
@@ -141711,9 +141090,15 @@ async function bindParameters(params, args, scope, context, evaluateNode3) {
|
|
|
141711
141090
|
}
|
|
141712
141091
|
return;
|
|
141713
141092
|
}
|
|
141714
|
-
const binding = await bindPattern2(
|
|
141715
|
-
|
|
141716
|
-
|
|
141093
|
+
const binding = await bindPattern2(
|
|
141094
|
+
param,
|
|
141095
|
+
args[index],
|
|
141096
|
+
{ kind: "var", initialize: true },
|
|
141097
|
+
scope,
|
|
141098
|
+
{
|
|
141099
|
+
evaluate: (defaultNode) => evaluateNode3(defaultNode, { ...context, scope })
|
|
141100
|
+
}
|
|
141101
|
+
);
|
|
141717
141102
|
if (!binding.ok) {
|
|
141718
141103
|
if (binding.result.kind === "error") {
|
|
141719
141104
|
throw binding.result.error;
|
|
@@ -141724,26 +141109,6 @@ async function bindParameters(params, args, scope, context, evaluateNode3) {
|
|
|
141724
141109
|
}
|
|
141725
141110
|
}
|
|
141726
141111
|
}
|
|
141727
|
-
function getParameterBindingNames(pattern) {
|
|
141728
|
-
switch (pattern.type) {
|
|
141729
|
-
case "Identifier":
|
|
141730
|
-
return [pattern.name];
|
|
141731
|
-
case "MemberExpression":
|
|
141732
|
-
return [];
|
|
141733
|
-
case "AssignmentPattern":
|
|
141734
|
-
return getParameterBindingNames(pattern.left);
|
|
141735
|
-
case "RestElement":
|
|
141736
|
-
return getParameterBindingNames(pattern.argument);
|
|
141737
|
-
case "ArrayPattern":
|
|
141738
|
-
return pattern.elements.flatMap(
|
|
141739
|
-
(element) => element === null ? [] : getParameterBindingNames(element)
|
|
141740
|
-
);
|
|
141741
|
-
case "ObjectPattern":
|
|
141742
|
-
return pattern.properties.flatMap(
|
|
141743
|
-
(property) => property.type === "RestElement" ? getParameterBindingNames(property) : getParameterBindingNames(property.value)
|
|
141744
|
-
);
|
|
141745
|
-
}
|
|
141746
|
-
}
|
|
141747
141112
|
function normalizeClosureResult(result, budget) {
|
|
141748
141113
|
if (isSandboxPromise(result) && (result.synchronousPrefix !== void 0 || result.hostCall !== void 0)) {
|
|
141749
141114
|
return result;
|
|
@@ -141762,6 +141127,7 @@ var init_async = __esm({
|
|
|
141762
141127
|
init_jobs4();
|
|
141763
141128
|
init_cancel2();
|
|
141764
141129
|
init_var_hoist();
|
|
141130
|
+
init_bindings();
|
|
141765
141131
|
init_values();
|
|
141766
141132
|
}
|
|
141767
141133
|
});
|
|
@@ -145647,7 +145013,7 @@ async function evaluateVariableDeclaration(node, context) {
|
|
|
145647
145013
|
continue;
|
|
145648
145014
|
}
|
|
145649
145015
|
if (declarator.id.type === "ArrayPattern" || declarator.id.type === "ObjectPattern") {
|
|
145650
|
-
const names =
|
|
145016
|
+
const names = getPatternBindingNames2(declarator.id);
|
|
145651
145017
|
const restoredBindings = [];
|
|
145652
145018
|
for (const name of names) {
|
|
145653
145019
|
const restored = context.scope.consumeRestoredBinding(name);
|
|
@@ -145718,26 +145084,26 @@ function getForStatementBindingNames(node) {
|
|
|
145718
145084
|
return node.init?.type === "VariableDeclaration" && node.init.kind !== "var" ? getDeclarationBindingNames2(node.init) : [];
|
|
145719
145085
|
}
|
|
145720
145086
|
function getDeclarationBindingNames2(node) {
|
|
145721
|
-
return node.declarations.flatMap((declarator) =>
|
|
145087
|
+
return node.declarations.flatMap((declarator) => getPatternBindingNames2(declarator.id));
|
|
145722
145088
|
}
|
|
145723
|
-
function
|
|
145089
|
+
function getPatternBindingNames2(pattern) {
|
|
145724
145090
|
switch (pattern.type) {
|
|
145725
145091
|
case "Identifier":
|
|
145726
145092
|
return [pattern.name];
|
|
145727
145093
|
case "MemberExpression":
|
|
145728
145094
|
return [];
|
|
145729
145095
|
case "AssignmentPattern":
|
|
145730
|
-
return
|
|
145096
|
+
return getPatternBindingNames2(pattern.left);
|
|
145731
145097
|
case "ArrayPattern":
|
|
145732
145098
|
return pattern.elements.flatMap(
|
|
145733
|
-
(element) => element === null ? [] :
|
|
145099
|
+
(element) => element === null ? [] : getPatternBindingNames2(element)
|
|
145734
145100
|
);
|
|
145735
145101
|
case "ObjectPattern":
|
|
145736
145102
|
return pattern.properties.flatMap(
|
|
145737
|
-
(property) => property.type === "RestElement" ?
|
|
145103
|
+
(property) => property.type === "RestElement" ? getPatternBindingNames2(property) : getPatternBindingNames2(property.value)
|
|
145738
145104
|
);
|
|
145739
145105
|
case "RestElement":
|
|
145740
|
-
return
|
|
145106
|
+
return getPatternBindingNames2(pattern.argument);
|
|
145741
145107
|
}
|
|
145742
145108
|
}
|
|
145743
145109
|
async function evaluateBlockStatement(node, context) {
|
|
@@ -145807,7 +145173,7 @@ function isParseResult(value) {
|
|
|
145807
145173
|
return typeof value === "object" && value !== null && typeof value.type === "string" && Object.hasOwn(value, "span");
|
|
145808
145174
|
}
|
|
145809
145175
|
function createBlockContext(node, context) {
|
|
145810
|
-
const scope = node === context.rootNode || context.generatorResume !== void 0 ? context.scope : context.scope.child();
|
|
145176
|
+
const scope = node === context.rootNode || node === context.functionBody || context.generatorResume !== void 0 ? context.scope : context.scope.child();
|
|
145811
145177
|
const blockContext = {
|
|
145812
145178
|
...context,
|
|
145813
145179
|
scope
|
|
@@ -145818,15 +145184,19 @@ function createBlockContext(node, context) {
|
|
|
145818
145184
|
return blockContext;
|
|
145819
145185
|
}
|
|
145820
145186
|
function predeclareBlockBindings2(node, context) {
|
|
145821
|
-
predeclareStatementListBindings(
|
|
145187
|
+
predeclareStatementListBindings(
|
|
145188
|
+
node.body,
|
|
145189
|
+
context,
|
|
145190
|
+
node === context.functionBody || node === context.rootNode
|
|
145191
|
+
);
|
|
145822
145192
|
}
|
|
145823
|
-
function predeclareStatementListBindings(statements, context) {
|
|
145193
|
+
function predeclareStatementListBindings(statements, context, functionBody = false) {
|
|
145824
145194
|
const { scope } = context;
|
|
145825
145195
|
const names = /* @__PURE__ */ new Set();
|
|
145826
145196
|
for (const statement of statements) {
|
|
145827
145197
|
if (statement.type === "FunctionDeclaration") {
|
|
145828
145198
|
const name = statement.id.name;
|
|
145829
|
-
if (names.has(name)) {
|
|
145199
|
+
if (names.has(name) && !(functionBody && scope.getOwnBindingKind(name) === "var")) {
|
|
145830
145200
|
throw new Error(`Cannot redeclare binding '${name}' in the same scope.`);
|
|
145831
145201
|
}
|
|
145832
145202
|
const closure = createInterpretedClosure(statement, context, evaluateNode2);
|
|
@@ -145840,7 +145210,7 @@ function predeclareStatementListBindings(statements, context) {
|
|
|
145840
145210
|
throw new Error(`Cannot redeclare binding '${name}' in the same scope.`);
|
|
145841
145211
|
}
|
|
145842
145212
|
names.add(name);
|
|
145843
|
-
scope.declare(name, "
|
|
145213
|
+
scope.declare(name, functionBody ? "var" : "let", closure);
|
|
145844
145214
|
continue;
|
|
145845
145215
|
}
|
|
145846
145216
|
if (statement.type !== "VariableDeclaration" || statement.kind === "var") {
|
|
@@ -154757,7 +154127,7 @@ var init_package2 = __esm({
|
|
|
154757
154127
|
"package.json"() {
|
|
154758
154128
|
package_default2 = {
|
|
154759
154129
|
name: "poe-code",
|
|
154760
|
-
version: "
|
|
154130
|
+
version: "7.0.1",
|
|
154761
154131
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
154762
154132
|
license: "MIT",
|
|
154763
154133
|
type: "module",
|