@fedify/lint 2.4.0-dev.2122 → 2.4.0-dev.2129
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/deno.json +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{outbox-listener-delivery-required-6phcPuk2.js → outbox-listener-delivery-required-BcXW12PB.js} +136 -31
- package/dist/{outbox-listener-delivery-required-DyJ1I2D0.cjs → outbox-listener-delivery-required-CWEUOlLf.cjs} +136 -31
- package/dist/oxlint.cjs +1 -1
- package/dist/oxlint.js +1 -1
- package/package.json +3 -3
package/deno.json
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
//#endregion
|
|
27
|
-
const require_outbox_listener_delivery_required = require("./outbox-listener-delivery-required-
|
|
27
|
+
const require_outbox_listener_delivery_required = require("./outbox-listener-delivery-required-CWEUOlLf.cjs");
|
|
28
28
|
let _fxts_core = require("@fxts/core");
|
|
29
29
|
let _typescript_eslint_parser = require("@typescript-eslint/parser");
|
|
30
30
|
_typescript_eslint_parser = __toESM(_typescript_eslint_parser, 1);
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as name, C as eslint$5, D as eslint$11, E as eslint$10, O as eslint$21, S as eslint$4, T as eslint$13, _ as eslint$15, a as eslint$23, b as eslint$2, c as eslint$16, d as eslint$22, f as eslint$6, g as eslint$14, h as eslint$9, i as eslint$27, j as version, k as RULE_IDS, l as eslint$17, m as eslint$8, n as eslint$25, o as eslint$18, p as eslint$7, r as eslint$26, s as eslint$19, t as eslint$24, u as eslint$20, v as eslint$1, w as eslint$12, x as eslint$3, y as eslint } from "./outbox-listener-delivery-required-
|
|
1
|
+
import { A as name, C as eslint$5, D as eslint$11, E as eslint$10, O as eslint$21, S as eslint$4, T as eslint$13, _ as eslint$15, a as eslint$23, b as eslint$2, c as eslint$16, d as eslint$22, f as eslint$6, g as eslint$14, h as eslint$9, i as eslint$27, j as version, k as RULE_IDS, l as eslint$17, m as eslint$8, n as eslint$25, o as eslint$18, p as eslint$7, r as eslint$26, s as eslint$19, t as eslint$24, u as eslint$20, v as eslint$1, w as eslint$12, x as eslint$3, y as eslint } from "./outbox-listener-delivery-required-BcXW12PB.js";
|
|
2
2
|
import { fromEntries, keys, map, pipe } from "@fxts/core";
|
|
3
3
|
import parser from "@typescript-eslint/parser";
|
|
4
4
|
//#region src/index.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { always, every, head, isEmpty, isObject, negate, pipe, pipeLazy, prop, some, toArray, unless, when } from "@fxts/core";
|
|
2
2
|
//#region deno.json
|
|
3
3
|
var name = "@fedify/lint";
|
|
4
|
-
var version = "2.4.0-dev.
|
|
4
|
+
var version = "2.4.0-dev.2129+c0ddb433";
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/lib/const.ts
|
|
7
7
|
/**
|
|
@@ -1135,11 +1135,46 @@ function alwaysExits(node) {
|
|
|
1135
1135
|
default: return false;
|
|
1136
1136
|
}
|
|
1137
1137
|
}
|
|
1138
|
-
function
|
|
1138
|
+
function collectBindingExpressions(node, out, bindings, declares = false) {
|
|
1139
|
+
switch (node.type) {
|
|
1140
|
+
case "VariableDeclaration":
|
|
1141
|
+
for (const decl of node.declarations) {
|
|
1142
|
+
const names = [];
|
|
1143
|
+
collectBoundNames(decl.id, names);
|
|
1144
|
+
if (node.kind === "var") for (const name of names) bindings?.declaredHere.add(name);
|
|
1145
|
+
collectBindingExpressions(decl.id, out, bindings, true);
|
|
1146
|
+
}
|
|
1147
|
+
break;
|
|
1148
|
+
case "ObjectPattern":
|
|
1149
|
+
for (const prop of node.properties) if (prop.type === "Property") {
|
|
1150
|
+
if (prop.computed) out.push(prop.key);
|
|
1151
|
+
collectBindingExpressions(prop.value, out, bindings, declares);
|
|
1152
|
+
} else if (prop.type === "RestElement") collectBindingExpressions(prop.argument, out, bindings, declares);
|
|
1153
|
+
break;
|
|
1154
|
+
case "ArrayPattern":
|
|
1155
|
+
for (const elem of node.elements) if (elem != null) collectBindingExpressions(elem, out, bindings, declares);
|
|
1156
|
+
break;
|
|
1157
|
+
case "AssignmentPattern":
|
|
1158
|
+
out.push(node);
|
|
1159
|
+
if (declares) bindings?.declarationPatterns.add(node);
|
|
1160
|
+
collectBindingExpressions(node.left, out, bindings, declares);
|
|
1161
|
+
break;
|
|
1162
|
+
case "RestElement":
|
|
1163
|
+
collectBindingExpressions(node.argument, out, bindings, declares);
|
|
1164
|
+
break;
|
|
1165
|
+
case "MemberExpression": {
|
|
1166
|
+
const object = node.object;
|
|
1167
|
+
if (object.type !== "Identifier") out.push(object);
|
|
1168
|
+
if (node.computed) out.push(node.property);
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
function collectReachableStatements(node, out, bindings) {
|
|
1139
1174
|
switch (node.type) {
|
|
1140
1175
|
case "BlockStatement":
|
|
1141
1176
|
for (const [index, statement] of node.body.entries()) {
|
|
1142
|
-
collectReachableStatements(statement, out);
|
|
1177
|
+
collectReachableStatements(statement, out, bindings);
|
|
1143
1178
|
if (alwaysExits(statement)) {
|
|
1144
1179
|
for (const rest of node.body.slice(index + 1)) if (rest.type === "FunctionDeclaration") out.push(rest);
|
|
1145
1180
|
return;
|
|
@@ -1149,49 +1184,53 @@ function collectReachableStatements(node, out) {
|
|
|
1149
1184
|
case "IfStatement": {
|
|
1150
1185
|
const test = node.test;
|
|
1151
1186
|
out.push(test);
|
|
1152
|
-
if (!isStaticallyFalsy(test)) collectReachableStatements(node.consequent, out);
|
|
1153
|
-
if (node.alternate != null && !isStaticallyTruthy(test)) collectReachableStatements(node.alternate, out);
|
|
1187
|
+
if (!isStaticallyFalsy(test)) collectReachableStatements(node.consequent, out, bindings);
|
|
1188
|
+
if (node.alternate != null && !isStaticallyTruthy(test)) collectReachableStatements(node.alternate, out, bindings);
|
|
1154
1189
|
return;
|
|
1155
1190
|
}
|
|
1156
1191
|
case "TryStatement":
|
|
1157
|
-
collectReachableStatements(node.block, out);
|
|
1158
|
-
if (node.handler != null) collectReachableStatements(node.handler.body, out);
|
|
1159
|
-
if (node.finalizer != null) collectReachableStatements(node.finalizer, out);
|
|
1192
|
+
collectReachableStatements(node.block, out, bindings);
|
|
1193
|
+
if (node.handler != null) collectReachableStatements(node.handler.body, out, bindings);
|
|
1194
|
+
if (node.finalizer != null) collectReachableStatements(node.finalizer, out, bindings);
|
|
1160
1195
|
return;
|
|
1161
1196
|
case "SwitchStatement":
|
|
1162
1197
|
out.push(node.discriminant);
|
|
1163
1198
|
for (const switchCase of node.cases) {
|
|
1164
1199
|
if (switchCase.test != null) out.push(switchCase.test);
|
|
1165
1200
|
for (const statement of switchCase.consequent) {
|
|
1166
|
-
collectReachableStatements(statement, out);
|
|
1201
|
+
collectReachableStatements(statement, out, bindings);
|
|
1167
1202
|
if (alwaysExits(statement)) break;
|
|
1168
1203
|
}
|
|
1169
1204
|
}
|
|
1170
1205
|
return;
|
|
1171
1206
|
case "WhileStatement":
|
|
1207
|
+
out.push(node.test);
|
|
1208
|
+
if (!isStaticallyFalsy(node.test)) collectReachableStatements(node.body, out, bindings);
|
|
1209
|
+
return;
|
|
1172
1210
|
case "DoWhileStatement":
|
|
1173
1211
|
out.push(node.test);
|
|
1174
|
-
collectReachableStatements(node.body, out);
|
|
1212
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1175
1213
|
return;
|
|
1176
1214
|
case "ForStatement":
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
node.update
|
|
1181
|
-
|
|
1182
|
-
|
|
1215
|
+
if (node.init != null) out.push(node.init);
|
|
1216
|
+
if (node.test != null) out.push(node.test);
|
|
1217
|
+
if (node.test == null || !isStaticallyFalsy(node.test)) {
|
|
1218
|
+
if (node.update != null) out.push(node.update);
|
|
1219
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1220
|
+
}
|
|
1183
1221
|
return;
|
|
1184
1222
|
case "ForInStatement":
|
|
1185
1223
|
case "ForOfStatement":
|
|
1224
|
+
collectBindingExpressions(node.left, out, bindings);
|
|
1186
1225
|
out.push(node.right);
|
|
1187
|
-
collectReachableStatements(node.body, out);
|
|
1226
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1188
1227
|
return;
|
|
1189
1228
|
case "LabeledStatement":
|
|
1190
|
-
collectReachableStatements(node.body, out);
|
|
1229
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1191
1230
|
return;
|
|
1192
1231
|
case "WithStatement":
|
|
1193
1232
|
out.push(node.object);
|
|
1194
|
-
collectReachableStatements(node.body, out);
|
|
1233
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1195
1234
|
return;
|
|
1196
1235
|
default:
|
|
1197
1236
|
out.push(node);
|
|
@@ -1243,6 +1282,22 @@ function collectReferencedNames(node, out, crossFunctions = false) {
|
|
|
1243
1282
|
if (n.type === "AssignmentExpression" && n.operator === "=") {
|
|
1244
1283
|
if (getAssignmentTargetName(n.left) != null) {
|
|
1245
1284
|
collectReferencedNames(n.right, out, crossFunctions);
|
|
1285
|
+
let current = n.left;
|
|
1286
|
+
while (current.type === "MemberExpression") {
|
|
1287
|
+
if (current.computed) collectReferencedNames(current.property, out, crossFunctions);
|
|
1288
|
+
current = current.object;
|
|
1289
|
+
}
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
if (n.type === "AssignmentPattern") {
|
|
1294
|
+
if (getAssignmentTargetName(n.left) != null) {
|
|
1295
|
+
collectReferencedNames(n.right, out, crossFunctions);
|
|
1296
|
+
let current = n.left;
|
|
1297
|
+
while (current.type === "MemberExpression") {
|
|
1298
|
+
if (current.computed) collectReferencedNames(current.property, out, crossFunctions);
|
|
1299
|
+
current = current.object;
|
|
1300
|
+
}
|
|
1246
1301
|
return;
|
|
1247
1302
|
}
|
|
1248
1303
|
}
|
|
@@ -1325,19 +1380,19 @@ function collectHeldFunctions(node, out) {
|
|
|
1325
1380
|
* reachable, so it can be layered on top of (and correctly shadow) the outer
|
|
1326
1381
|
* scope's names.
|
|
1327
1382
|
*/
|
|
1328
|
-
function collectFunctionsByName(node, out) {
|
|
1383
|
+
function collectFunctionsByName(node, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations) {
|
|
1329
1384
|
if (node == null || typeof node !== "object") return;
|
|
1330
1385
|
if (Array.isArray(node)) {
|
|
1331
|
-
for (const item of node) collectFunctionsByName(item, out);
|
|
1386
|
+
for (const item of node) collectFunctionsByName(item, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1332
1387
|
return;
|
|
1333
1388
|
}
|
|
1334
1389
|
if (!isNode(node)) return;
|
|
1335
1390
|
const n = node;
|
|
1336
|
-
const bindTo = (names, from) => {
|
|
1391
|
+
const bindTo = (names, from, bindings = out) => {
|
|
1337
1392
|
const functions = [];
|
|
1338
1393
|
collectHeldFunctions(from, functions);
|
|
1339
1394
|
if (functions.length < 1) return;
|
|
1340
|
-
for (const name of names)
|
|
1395
|
+
for (const name of names) bindings.set(name, [...bindings.get(name) ?? [], ...functions]);
|
|
1341
1396
|
};
|
|
1342
1397
|
if (n.type === "FunctionDeclaration") {
|
|
1343
1398
|
if (n.id?.name != null) bindTo([n.id.name], n);
|
|
@@ -1348,26 +1403,49 @@ function collectFunctionsByName(node, out) {
|
|
|
1348
1403
|
return;
|
|
1349
1404
|
}
|
|
1350
1405
|
if (isFunctionLikeNode(n)) return;
|
|
1406
|
+
if (n.type === "StaticBlock") {
|
|
1407
|
+
collectFunctionsByName(n.body, out, assignmentDefaults, declarationPatterns, /* @__PURE__ */ new Set(), scopeDeclarations);
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
if (n.type === "VariableDeclaration") {
|
|
1411
|
+
if (n.kind === "var" || scopeDeclarations.has(n)) for (const decl of n.declarations) {
|
|
1412
|
+
const names = [];
|
|
1413
|
+
collectBoundNames(decl.id, names);
|
|
1414
|
+
for (const name of names) declaredHere.add(name);
|
|
1415
|
+
}
|
|
1416
|
+
for (const decl of n.declarations) collectFunctionsByName(decl, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1351
1419
|
if (n.type === "VariableDeclarator") {
|
|
1352
1420
|
const decl = n;
|
|
1421
|
+
const names = [];
|
|
1422
|
+
collectBoundNames(decl.id, names);
|
|
1353
1423
|
if (decl.init != null) {
|
|
1354
|
-
const names = [];
|
|
1355
|
-
collectBoundNames(decl.id, names);
|
|
1356
1424
|
bindTo(names, decl.init);
|
|
1357
|
-
collectFunctionsByName(decl.init, out);
|
|
1425
|
+
collectFunctionsByName(decl.init, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1358
1426
|
}
|
|
1359
1427
|
return;
|
|
1360
1428
|
}
|
|
1429
|
+
if (n.type === "AssignmentPattern") {
|
|
1430
|
+
const names = [];
|
|
1431
|
+
if (n.left.type === "MemberExpression") {
|
|
1432
|
+
const name = getAssignmentTargetName(n.left);
|
|
1433
|
+
if (name != null) names.push(name);
|
|
1434
|
+
} else collectBoundNames(n.left, names);
|
|
1435
|
+
bindTo(names, n.right, n.left.type === "MemberExpression" || !declarationPatterns.has(n) ? assignmentDefaults : out);
|
|
1436
|
+
collectFunctionsByName(n.right, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1361
1439
|
if (n.type === "AssignmentExpression") {
|
|
1362
1440
|
const name = getAssignmentTargetName(n.left);
|
|
1363
1441
|
if (name != null) bindTo([name], n.right);
|
|
1364
|
-
collectFunctionsByName(n.right, out);
|
|
1442
|
+
collectFunctionsByName(n.right, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1365
1443
|
return;
|
|
1366
1444
|
}
|
|
1367
1445
|
const record = n;
|
|
1368
1446
|
for (const key in record) {
|
|
1369
1447
|
if (key === "parent") continue;
|
|
1370
|
-
collectFunctionsByName(record[key], out);
|
|
1448
|
+
collectFunctionsByName(record[key], out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1371
1449
|
}
|
|
1372
1450
|
}
|
|
1373
1451
|
/**
|
|
@@ -1410,11 +1488,27 @@ function walkUsedScopes(root, visit) {
|
|
|
1410
1488
|
if (visited.has(scopeRoot)) return;
|
|
1411
1489
|
visited.add(scopeRoot);
|
|
1412
1490
|
const statements = [];
|
|
1413
|
-
|
|
1491
|
+
const declarationPatterns = /* @__PURE__ */ new Set();
|
|
1492
|
+
const declaredHere = /* @__PURE__ */ new Set();
|
|
1493
|
+
collectReachableStatements(scopeRoot, statements, {
|
|
1494
|
+
declarationPatterns,
|
|
1495
|
+
declaredHere
|
|
1496
|
+
});
|
|
1414
1497
|
const functionsHere = /* @__PURE__ */ new Map();
|
|
1415
|
-
|
|
1498
|
+
const assignmentDefaultsHere = /* @__PURE__ */ new Map();
|
|
1499
|
+
for (const param of scopeFn?.params ?? []) {
|
|
1500
|
+
const names = [];
|
|
1501
|
+
collectBoundNames(param, names);
|
|
1502
|
+
for (const name of names) functionsHere.set(name, []);
|
|
1503
|
+
}
|
|
1504
|
+
const scopeDeclarations = new Set(scopeRoot.type === "BlockStatement" ? scopeRoot.body : []);
|
|
1505
|
+
for (const statement of statements) collectFunctionsByName(statement, functionsHere, assignmentDefaultsHere, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1416
1506
|
const functionsByName = new Map(outerFunctionsByName);
|
|
1417
1507
|
for (const [name, functions] of functionsHere) functionsByName.set(name, functions);
|
|
1508
|
+
for (const [name, functions] of assignmentDefaultsHere) {
|
|
1509
|
+
const base = declaredHere.has(name) ? functionsHere.get(name) ?? [] : functionsByName.get(name) ?? [];
|
|
1510
|
+
functionsByName.set(name, [...base, ...functions]);
|
|
1511
|
+
}
|
|
1418
1512
|
visit({
|
|
1419
1513
|
fn: scopeFn,
|
|
1420
1514
|
statements,
|
|
@@ -1428,7 +1522,7 @@ function walkUsedScopes(root, visit) {
|
|
|
1428
1522
|
for (const fn of functions) reached.add(fn);
|
|
1429
1523
|
}
|
|
1430
1524
|
const held = /* @__PURE__ */ new Set();
|
|
1431
|
-
for (const functions of
|
|
1525
|
+
for (const bindings of [functionsHere, assignmentDefaultsHere]) for (const functions of bindings.values()) for (const fn of functions) held.add(fn);
|
|
1432
1526
|
for (const statement of statements) {
|
|
1433
1527
|
const nested = [];
|
|
1434
1528
|
collectNestedFunctions(statement, nested);
|
|
@@ -1670,7 +1764,11 @@ function fateOf(expression, analysis, shape = "promise") {
|
|
|
1670
1764
|
case "DoWhileStatement":
|
|
1671
1765
|
case "ForStatement": return DROPPED;
|
|
1672
1766
|
case "LogicalExpression":
|
|
1767
|
+
if (get(parent, "operator") === "&&" && get(parent, "left") === current) return DROPPED;
|
|
1768
|
+
current = parent;
|
|
1769
|
+
continue;
|
|
1673
1770
|
case "Property":
|
|
1771
|
+
if (get(parent, "computed") && get(parent, "key") === current) return DROPPED;
|
|
1674
1772
|
current = parent;
|
|
1675
1773
|
continue;
|
|
1676
1774
|
case "ObjectExpression":
|
|
@@ -1689,6 +1787,7 @@ function fateOf(expression, analysis, shape = "promise") {
|
|
|
1689
1787
|
continue;
|
|
1690
1788
|
}
|
|
1691
1789
|
case "MemberExpression": {
|
|
1790
|
+
if (get(parent, "computed") && get(parent, "property") === current) return DROPPED;
|
|
1692
1791
|
if (get(parent, "object") !== current) return HANDLED;
|
|
1693
1792
|
const call = parentOf(parent);
|
|
1694
1793
|
const name = memberName(parent);
|
|
@@ -1722,6 +1821,12 @@ function fateOf(expression, analysis, shape = "promise") {
|
|
|
1722
1821
|
if (name == null) return HANDLED;
|
|
1723
1822
|
return analysis.mentioned.has(name) ? HANDLED : DROPPED;
|
|
1724
1823
|
}
|
|
1824
|
+
case "AssignmentPattern": {
|
|
1825
|
+
if (get(parent, "right") !== current) return HANDLED;
|
|
1826
|
+
const name = getAssignmentTargetName(asNode(get(parent, "left")) ?? parent);
|
|
1827
|
+
if (name == null) return HANDLED;
|
|
1828
|
+
return analysis.mentioned.has(name) ? HANDLED : DROPPED;
|
|
1829
|
+
}
|
|
1725
1830
|
default: return HANDLED;
|
|
1726
1831
|
}
|
|
1727
1832
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
let _fxts_core = require("@fxts/core");
|
|
2
2
|
//#region deno.json
|
|
3
3
|
var name = "@fedify/lint";
|
|
4
|
-
var version = "2.4.0-dev.
|
|
4
|
+
var version = "2.4.0-dev.2129+c0ddb433";
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/lib/const.ts
|
|
7
7
|
/**
|
|
@@ -1135,11 +1135,46 @@ function alwaysExits(node) {
|
|
|
1135
1135
|
default: return false;
|
|
1136
1136
|
}
|
|
1137
1137
|
}
|
|
1138
|
-
function
|
|
1138
|
+
function collectBindingExpressions(node, out, bindings, declares = false) {
|
|
1139
|
+
switch (node.type) {
|
|
1140
|
+
case "VariableDeclaration":
|
|
1141
|
+
for (const decl of node.declarations) {
|
|
1142
|
+
const names = [];
|
|
1143
|
+
collectBoundNames(decl.id, names);
|
|
1144
|
+
if (node.kind === "var") for (const name of names) bindings?.declaredHere.add(name);
|
|
1145
|
+
collectBindingExpressions(decl.id, out, bindings, true);
|
|
1146
|
+
}
|
|
1147
|
+
break;
|
|
1148
|
+
case "ObjectPattern":
|
|
1149
|
+
for (const prop of node.properties) if (prop.type === "Property") {
|
|
1150
|
+
if (prop.computed) out.push(prop.key);
|
|
1151
|
+
collectBindingExpressions(prop.value, out, bindings, declares);
|
|
1152
|
+
} else if (prop.type === "RestElement") collectBindingExpressions(prop.argument, out, bindings, declares);
|
|
1153
|
+
break;
|
|
1154
|
+
case "ArrayPattern":
|
|
1155
|
+
for (const elem of node.elements) if (elem != null) collectBindingExpressions(elem, out, bindings, declares);
|
|
1156
|
+
break;
|
|
1157
|
+
case "AssignmentPattern":
|
|
1158
|
+
out.push(node);
|
|
1159
|
+
if (declares) bindings?.declarationPatterns.add(node);
|
|
1160
|
+
collectBindingExpressions(node.left, out, bindings, declares);
|
|
1161
|
+
break;
|
|
1162
|
+
case "RestElement":
|
|
1163
|
+
collectBindingExpressions(node.argument, out, bindings, declares);
|
|
1164
|
+
break;
|
|
1165
|
+
case "MemberExpression": {
|
|
1166
|
+
const object = node.object;
|
|
1167
|
+
if (object.type !== "Identifier") out.push(object);
|
|
1168
|
+
if (node.computed) out.push(node.property);
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
function collectReachableStatements(node, out, bindings) {
|
|
1139
1174
|
switch (node.type) {
|
|
1140
1175
|
case "BlockStatement":
|
|
1141
1176
|
for (const [index, statement] of node.body.entries()) {
|
|
1142
|
-
collectReachableStatements(statement, out);
|
|
1177
|
+
collectReachableStatements(statement, out, bindings);
|
|
1143
1178
|
if (alwaysExits(statement)) {
|
|
1144
1179
|
for (const rest of node.body.slice(index + 1)) if (rest.type === "FunctionDeclaration") out.push(rest);
|
|
1145
1180
|
return;
|
|
@@ -1149,49 +1184,53 @@ function collectReachableStatements(node, out) {
|
|
|
1149
1184
|
case "IfStatement": {
|
|
1150
1185
|
const test = node.test;
|
|
1151
1186
|
out.push(test);
|
|
1152
|
-
if (!isStaticallyFalsy(test)) collectReachableStatements(node.consequent, out);
|
|
1153
|
-
if (node.alternate != null && !isStaticallyTruthy(test)) collectReachableStatements(node.alternate, out);
|
|
1187
|
+
if (!isStaticallyFalsy(test)) collectReachableStatements(node.consequent, out, bindings);
|
|
1188
|
+
if (node.alternate != null && !isStaticallyTruthy(test)) collectReachableStatements(node.alternate, out, bindings);
|
|
1154
1189
|
return;
|
|
1155
1190
|
}
|
|
1156
1191
|
case "TryStatement":
|
|
1157
|
-
collectReachableStatements(node.block, out);
|
|
1158
|
-
if (node.handler != null) collectReachableStatements(node.handler.body, out);
|
|
1159
|
-
if (node.finalizer != null) collectReachableStatements(node.finalizer, out);
|
|
1192
|
+
collectReachableStatements(node.block, out, bindings);
|
|
1193
|
+
if (node.handler != null) collectReachableStatements(node.handler.body, out, bindings);
|
|
1194
|
+
if (node.finalizer != null) collectReachableStatements(node.finalizer, out, bindings);
|
|
1160
1195
|
return;
|
|
1161
1196
|
case "SwitchStatement":
|
|
1162
1197
|
out.push(node.discriminant);
|
|
1163
1198
|
for (const switchCase of node.cases) {
|
|
1164
1199
|
if (switchCase.test != null) out.push(switchCase.test);
|
|
1165
1200
|
for (const statement of switchCase.consequent) {
|
|
1166
|
-
collectReachableStatements(statement, out);
|
|
1201
|
+
collectReachableStatements(statement, out, bindings);
|
|
1167
1202
|
if (alwaysExits(statement)) break;
|
|
1168
1203
|
}
|
|
1169
1204
|
}
|
|
1170
1205
|
return;
|
|
1171
1206
|
case "WhileStatement":
|
|
1207
|
+
out.push(node.test);
|
|
1208
|
+
if (!isStaticallyFalsy(node.test)) collectReachableStatements(node.body, out, bindings);
|
|
1209
|
+
return;
|
|
1172
1210
|
case "DoWhileStatement":
|
|
1173
1211
|
out.push(node.test);
|
|
1174
|
-
collectReachableStatements(node.body, out);
|
|
1212
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1175
1213
|
return;
|
|
1176
1214
|
case "ForStatement":
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
node.update
|
|
1181
|
-
|
|
1182
|
-
|
|
1215
|
+
if (node.init != null) out.push(node.init);
|
|
1216
|
+
if (node.test != null) out.push(node.test);
|
|
1217
|
+
if (node.test == null || !isStaticallyFalsy(node.test)) {
|
|
1218
|
+
if (node.update != null) out.push(node.update);
|
|
1219
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1220
|
+
}
|
|
1183
1221
|
return;
|
|
1184
1222
|
case "ForInStatement":
|
|
1185
1223
|
case "ForOfStatement":
|
|
1224
|
+
collectBindingExpressions(node.left, out, bindings);
|
|
1186
1225
|
out.push(node.right);
|
|
1187
|
-
collectReachableStatements(node.body, out);
|
|
1226
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1188
1227
|
return;
|
|
1189
1228
|
case "LabeledStatement":
|
|
1190
|
-
collectReachableStatements(node.body, out);
|
|
1229
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1191
1230
|
return;
|
|
1192
1231
|
case "WithStatement":
|
|
1193
1232
|
out.push(node.object);
|
|
1194
|
-
collectReachableStatements(node.body, out);
|
|
1233
|
+
collectReachableStatements(node.body, out, bindings);
|
|
1195
1234
|
return;
|
|
1196
1235
|
default:
|
|
1197
1236
|
out.push(node);
|
|
@@ -1243,6 +1282,22 @@ function collectReferencedNames(node, out, crossFunctions = false) {
|
|
|
1243
1282
|
if (n.type === "AssignmentExpression" && n.operator === "=") {
|
|
1244
1283
|
if (getAssignmentTargetName(n.left) != null) {
|
|
1245
1284
|
collectReferencedNames(n.right, out, crossFunctions);
|
|
1285
|
+
let current = n.left;
|
|
1286
|
+
while (current.type === "MemberExpression") {
|
|
1287
|
+
if (current.computed) collectReferencedNames(current.property, out, crossFunctions);
|
|
1288
|
+
current = current.object;
|
|
1289
|
+
}
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
if (n.type === "AssignmentPattern") {
|
|
1294
|
+
if (getAssignmentTargetName(n.left) != null) {
|
|
1295
|
+
collectReferencedNames(n.right, out, crossFunctions);
|
|
1296
|
+
let current = n.left;
|
|
1297
|
+
while (current.type === "MemberExpression") {
|
|
1298
|
+
if (current.computed) collectReferencedNames(current.property, out, crossFunctions);
|
|
1299
|
+
current = current.object;
|
|
1300
|
+
}
|
|
1246
1301
|
return;
|
|
1247
1302
|
}
|
|
1248
1303
|
}
|
|
@@ -1325,19 +1380,19 @@ function collectHeldFunctions(node, out) {
|
|
|
1325
1380
|
* reachable, so it can be layered on top of (and correctly shadow) the outer
|
|
1326
1381
|
* scope's names.
|
|
1327
1382
|
*/
|
|
1328
|
-
function collectFunctionsByName(node, out) {
|
|
1383
|
+
function collectFunctionsByName(node, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations) {
|
|
1329
1384
|
if (node == null || typeof node !== "object") return;
|
|
1330
1385
|
if (Array.isArray(node)) {
|
|
1331
|
-
for (const item of node) collectFunctionsByName(item, out);
|
|
1386
|
+
for (const item of node) collectFunctionsByName(item, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1332
1387
|
return;
|
|
1333
1388
|
}
|
|
1334
1389
|
if (!isNode(node)) return;
|
|
1335
1390
|
const n = node;
|
|
1336
|
-
const bindTo = (names, from) => {
|
|
1391
|
+
const bindTo = (names, from, bindings = out) => {
|
|
1337
1392
|
const functions = [];
|
|
1338
1393
|
collectHeldFunctions(from, functions);
|
|
1339
1394
|
if (functions.length < 1) return;
|
|
1340
|
-
for (const name of names)
|
|
1395
|
+
for (const name of names) bindings.set(name, [...bindings.get(name) ?? [], ...functions]);
|
|
1341
1396
|
};
|
|
1342
1397
|
if (n.type === "FunctionDeclaration") {
|
|
1343
1398
|
if (n.id?.name != null) bindTo([n.id.name], n);
|
|
@@ -1348,26 +1403,49 @@ function collectFunctionsByName(node, out) {
|
|
|
1348
1403
|
return;
|
|
1349
1404
|
}
|
|
1350
1405
|
if (isFunctionLikeNode(n)) return;
|
|
1406
|
+
if (n.type === "StaticBlock") {
|
|
1407
|
+
collectFunctionsByName(n.body, out, assignmentDefaults, declarationPatterns, /* @__PURE__ */ new Set(), scopeDeclarations);
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
if (n.type === "VariableDeclaration") {
|
|
1411
|
+
if (n.kind === "var" || scopeDeclarations.has(n)) for (const decl of n.declarations) {
|
|
1412
|
+
const names = [];
|
|
1413
|
+
collectBoundNames(decl.id, names);
|
|
1414
|
+
for (const name of names) declaredHere.add(name);
|
|
1415
|
+
}
|
|
1416
|
+
for (const decl of n.declarations) collectFunctionsByName(decl, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1351
1419
|
if (n.type === "VariableDeclarator") {
|
|
1352
1420
|
const decl = n;
|
|
1421
|
+
const names = [];
|
|
1422
|
+
collectBoundNames(decl.id, names);
|
|
1353
1423
|
if (decl.init != null) {
|
|
1354
|
-
const names = [];
|
|
1355
|
-
collectBoundNames(decl.id, names);
|
|
1356
1424
|
bindTo(names, decl.init);
|
|
1357
|
-
collectFunctionsByName(decl.init, out);
|
|
1425
|
+
collectFunctionsByName(decl.init, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1358
1426
|
}
|
|
1359
1427
|
return;
|
|
1360
1428
|
}
|
|
1429
|
+
if (n.type === "AssignmentPattern") {
|
|
1430
|
+
const names = [];
|
|
1431
|
+
if (n.left.type === "MemberExpression") {
|
|
1432
|
+
const name = getAssignmentTargetName(n.left);
|
|
1433
|
+
if (name != null) names.push(name);
|
|
1434
|
+
} else collectBoundNames(n.left, names);
|
|
1435
|
+
bindTo(names, n.right, n.left.type === "MemberExpression" || !declarationPatterns.has(n) ? assignmentDefaults : out);
|
|
1436
|
+
collectFunctionsByName(n.right, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1361
1439
|
if (n.type === "AssignmentExpression") {
|
|
1362
1440
|
const name = getAssignmentTargetName(n.left);
|
|
1363
1441
|
if (name != null) bindTo([name], n.right);
|
|
1364
|
-
collectFunctionsByName(n.right, out);
|
|
1442
|
+
collectFunctionsByName(n.right, out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1365
1443
|
return;
|
|
1366
1444
|
}
|
|
1367
1445
|
const record = n;
|
|
1368
1446
|
for (const key in record) {
|
|
1369
1447
|
if (key === "parent") continue;
|
|
1370
|
-
collectFunctionsByName(record[key], out);
|
|
1448
|
+
collectFunctionsByName(record[key], out, assignmentDefaults, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1371
1449
|
}
|
|
1372
1450
|
}
|
|
1373
1451
|
/**
|
|
@@ -1410,11 +1488,27 @@ function walkUsedScopes(root, visit) {
|
|
|
1410
1488
|
if (visited.has(scopeRoot)) return;
|
|
1411
1489
|
visited.add(scopeRoot);
|
|
1412
1490
|
const statements = [];
|
|
1413
|
-
|
|
1491
|
+
const declarationPatterns = /* @__PURE__ */ new Set();
|
|
1492
|
+
const declaredHere = /* @__PURE__ */ new Set();
|
|
1493
|
+
collectReachableStatements(scopeRoot, statements, {
|
|
1494
|
+
declarationPatterns,
|
|
1495
|
+
declaredHere
|
|
1496
|
+
});
|
|
1414
1497
|
const functionsHere = /* @__PURE__ */ new Map();
|
|
1415
|
-
|
|
1498
|
+
const assignmentDefaultsHere = /* @__PURE__ */ new Map();
|
|
1499
|
+
for (const param of scopeFn?.params ?? []) {
|
|
1500
|
+
const names = [];
|
|
1501
|
+
collectBoundNames(param, names);
|
|
1502
|
+
for (const name of names) functionsHere.set(name, []);
|
|
1503
|
+
}
|
|
1504
|
+
const scopeDeclarations = new Set(scopeRoot.type === "BlockStatement" ? scopeRoot.body : []);
|
|
1505
|
+
for (const statement of statements) collectFunctionsByName(statement, functionsHere, assignmentDefaultsHere, declarationPatterns, declaredHere, scopeDeclarations);
|
|
1416
1506
|
const functionsByName = new Map(outerFunctionsByName);
|
|
1417
1507
|
for (const [name, functions] of functionsHere) functionsByName.set(name, functions);
|
|
1508
|
+
for (const [name, functions] of assignmentDefaultsHere) {
|
|
1509
|
+
const base = declaredHere.has(name) ? functionsHere.get(name) ?? [] : functionsByName.get(name) ?? [];
|
|
1510
|
+
functionsByName.set(name, [...base, ...functions]);
|
|
1511
|
+
}
|
|
1418
1512
|
visit({
|
|
1419
1513
|
fn: scopeFn,
|
|
1420
1514
|
statements,
|
|
@@ -1428,7 +1522,7 @@ function walkUsedScopes(root, visit) {
|
|
|
1428
1522
|
for (const fn of functions) reached.add(fn);
|
|
1429
1523
|
}
|
|
1430
1524
|
const held = /* @__PURE__ */ new Set();
|
|
1431
|
-
for (const functions of
|
|
1525
|
+
for (const bindings of [functionsHere, assignmentDefaultsHere]) for (const functions of bindings.values()) for (const fn of functions) held.add(fn);
|
|
1432
1526
|
for (const statement of statements) {
|
|
1433
1527
|
const nested = [];
|
|
1434
1528
|
collectNestedFunctions(statement, nested);
|
|
@@ -1670,7 +1764,11 @@ function fateOf(expression, analysis, shape = "promise") {
|
|
|
1670
1764
|
case "DoWhileStatement":
|
|
1671
1765
|
case "ForStatement": return DROPPED;
|
|
1672
1766
|
case "LogicalExpression":
|
|
1767
|
+
if (get(parent, "operator") === "&&" && get(parent, "left") === current) return DROPPED;
|
|
1768
|
+
current = parent;
|
|
1769
|
+
continue;
|
|
1673
1770
|
case "Property":
|
|
1771
|
+
if (get(parent, "computed") && get(parent, "key") === current) return DROPPED;
|
|
1674
1772
|
current = parent;
|
|
1675
1773
|
continue;
|
|
1676
1774
|
case "ObjectExpression":
|
|
@@ -1689,6 +1787,7 @@ function fateOf(expression, analysis, shape = "promise") {
|
|
|
1689
1787
|
continue;
|
|
1690
1788
|
}
|
|
1691
1789
|
case "MemberExpression": {
|
|
1790
|
+
if (get(parent, "computed") && get(parent, "property") === current) return DROPPED;
|
|
1692
1791
|
if (get(parent, "object") !== current) return HANDLED;
|
|
1693
1792
|
const call = parentOf(parent);
|
|
1694
1793
|
const name = memberName(parent);
|
|
@@ -1722,6 +1821,12 @@ function fateOf(expression, analysis, shape = "promise") {
|
|
|
1722
1821
|
if (name == null) return HANDLED;
|
|
1723
1822
|
return analysis.mentioned.has(name) ? HANDLED : DROPPED;
|
|
1724
1823
|
}
|
|
1824
|
+
case "AssignmentPattern": {
|
|
1825
|
+
if (get(parent, "right") !== current) return HANDLED;
|
|
1826
|
+
const name = getAssignmentTargetName(asNode(get(parent, "left")) ?? parent);
|
|
1827
|
+
if (name == null) return HANDLED;
|
|
1828
|
+
return analysis.mentioned.has(name) ? HANDLED : DROPPED;
|
|
1829
|
+
}
|
|
1725
1830
|
default: return HANDLED;
|
|
1726
1831
|
}
|
|
1727
1832
|
}
|
package/dist/oxlint.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_outbox_listener_delivery_required = require("./outbox-listener-delivery-required-
|
|
1
|
+
const require_outbox_listener_delivery_required = require("./outbox-listener-delivery-required-CWEUOlLf.cjs");
|
|
2
2
|
//#region src/oxlint.ts
|
|
3
3
|
const rules = {
|
|
4
4
|
[require_outbox_listener_delivery_required.RULE_IDS.actorIdMismatch]: require_outbox_listener_delivery_required.eslint$18,
|
package/dist/oxlint.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as name, C as eslint$5, D as eslint$11, E as eslint$10, O as eslint$21, S as eslint$4, T as eslint$13, _ as eslint$15, a as eslint$23, b as eslint$2, c as eslint$16, d as eslint$22, f as eslint$6, g as eslint$14, h as eslint$9, i as eslint$27, j as version, k as RULE_IDS, l as eslint$17, m as eslint$8, n as eslint$25, o as eslint$18, p as eslint$7, r as eslint$26, s as eslint$19, t as eslint$24, u as eslint$20, v as eslint$1, w as eslint$12, x as eslint$3, y as eslint } from "./outbox-listener-delivery-required-
|
|
1
|
+
import { A as name, C as eslint$5, D as eslint$11, E as eslint$10, O as eslint$21, S as eslint$4, T as eslint$13, _ as eslint$15, a as eslint$23, b as eslint$2, c as eslint$16, d as eslint$22, f as eslint$6, g as eslint$14, h as eslint$9, i as eslint$27, j as version, k as RULE_IDS, l as eslint$17, m as eslint$8, n as eslint$25, o as eslint$18, p as eslint$7, r as eslint$26, s as eslint$19, t as eslint$24, u as eslint$20, v as eslint$1, w as eslint$12, x as eslint$3, y as eslint } from "./outbox-listener-delivery-required-BcXW12PB.js";
|
|
2
2
|
//#region src/oxlint.ts
|
|
3
3
|
const rules = {
|
|
4
4
|
[RULE_IDS.actorIdMismatch]: eslint,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/lint",
|
|
3
|
-
"version": "2.4.0-dev.
|
|
3
|
+
"version": "2.4.0-dev.2129+c0ddb433",
|
|
4
4
|
"description": "Fedify linting rules and plugins",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fedify",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"eslint": ">=9.0.0",
|
|
54
|
-
"@fedify/fedify": "^2.4.0-dev.
|
|
54
|
+
"@fedify/fedify": "^2.4.0-dev.2129+c0ddb433"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"eslint": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"tsdown": "^0.22.0",
|
|
72
72
|
"typescript": "^6.0.0",
|
|
73
73
|
"@fedify/fixture": "2.0.0",
|
|
74
|
-
"@fedify/vocab": "2.4.0-dev.
|
|
74
|
+
"@fedify/vocab": "2.4.0-dev.2129+c0ddb433"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build:self": "tsdown",
|