@fedify/lint 2.3.9-dev.2048 → 2.3.9
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 +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{outbox-listener-delivery-required-C1Ho3dCQ.cjs → outbox-listener-delivery-required-CiBWUvMt.cjs} +143 -28
- package/dist/{outbox-listener-delivery-required-CxugrN84.js → outbox-listener-delivery-required-DBgDh8Og.js} +143 -28
- package/dist/oxlint.cjs +1 -1
- package/dist/oxlint.js +1 -1
- package/package.json +2 -2
package/deno.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/lint",
|
|
3
|
-
"version": "2.3.9
|
|
3
|
+
"version": "2.3.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/mod.ts",
|
|
7
7
|
"./oxlint": "./src/oxlint.ts"
|
|
8
8
|
},
|
|
9
9
|
"imports": {
|
|
10
|
+
"@fedify/fixture": "jsr:@fedify/fixture@^2.2.14",
|
|
10
11
|
"eslint": "npm:eslint@^9.0.0",
|
|
11
12
|
"estree": "npm:@types/estree@^1.0.8",
|
|
12
13
|
"oxlint": "npm:oxlint@^1.66.0"
|
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-CiBWUvMt.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 { C as RULE_IDS, S as eslint$19, T as version, _ as eslint$5, a as eslint$18, b as eslint$10, c as eslint$8, d as eslint$15, f as eslint$1, g as eslint$4, h as eslint$3, i as eslint$17, l as eslint$9, m as eslint$2, n as eslint$20, o as eslint$6, p as eslint, r as eslint$16, s as eslint$7, t as eslint$21, u as eslint$14, v as eslint$12, w as name, x as eslint$11, y as eslint$13 } from "./outbox-listener-delivery-required-
|
|
1
|
+
import { C as RULE_IDS, S as eslint$19, T as version, _ as eslint$5, a as eslint$18, b as eslint$10, c as eslint$8, d as eslint$15, f as eslint$1, g as eslint$4, h as eslint$3, i as eslint$17, l as eslint$9, m as eslint$2, n as eslint$20, o as eslint$6, p as eslint, r as eslint$16, s as eslint$7, t as eslint$21, u as eslint$14, v as eslint$12, w as name, x as eslint$11, y as eslint$13 } from "./outbox-listener-delivery-required-DBgDh8Og.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
|
|
@@ -2,7 +2,7 @@ require("./index.cjs");
|
|
|
2
2
|
let _fxts_core = require("@fxts/core");
|
|
3
3
|
//#region deno.json
|
|
4
4
|
var name = "@fedify/lint";
|
|
5
|
-
var version = "2.3.9
|
|
5
|
+
var version = "2.3.9";
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/lib/const.ts
|
|
8
8
|
/**
|
|
@@ -596,7 +596,7 @@ const DELIVERY_METHOD_NAMES = new Set(["sendActivity", "forwardActivity"]);
|
|
|
596
596
|
const getMemberPropertyName = (expr) => {
|
|
597
597
|
if (expr.type !== "MemberExpression") return null;
|
|
598
598
|
const property = expr.property;
|
|
599
|
-
if (property.type === "Identifier") return property.name;
|
|
599
|
+
if (property.type === "Identifier" && !expr.computed) return property.name;
|
|
600
600
|
if (property.type === "Literal" && typeof property.value === "string") return property.value;
|
|
601
601
|
return null;
|
|
602
602
|
};
|
|
@@ -732,35 +732,139 @@ function buildContextExpressionPattern(contextName) {
|
|
|
732
732
|
const boundedName = String.raw`(?<![\w$])${name}(?![\w$])`;
|
|
733
733
|
return String.raw`(?:${boundedName}|\(\s*${boundedName}(?:\s+as\s+[^)]+)?\s*\))`;
|
|
734
734
|
}
|
|
735
|
-
const
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
735
|
+
const getParent = (node) => node.parent ?? null;
|
|
736
|
+
const isFunctionLike = (node) => node.type === "FunctionDeclaration" || isFunction(node);
|
|
737
|
+
function bindPattern(node, bindings) {
|
|
738
|
+
switch (node.type) {
|
|
739
|
+
case "Identifier":
|
|
740
|
+
bindings.set(node.name, { value: null });
|
|
741
|
+
break;
|
|
742
|
+
case "AssignmentPattern":
|
|
743
|
+
bindPattern(node.left, bindings);
|
|
744
|
+
break;
|
|
745
|
+
case "RestElement":
|
|
746
|
+
bindPattern(node.argument, bindings);
|
|
747
|
+
break;
|
|
748
|
+
case "ObjectPattern":
|
|
749
|
+
for (const property of node.properties) bindPattern(property.type === "Property" ? property.value : property, bindings);
|
|
750
|
+
break;
|
|
751
|
+
case "ArrayPattern":
|
|
752
|
+
for (const element of node.elements) if (element != null) bindPattern(element, bindings);
|
|
753
|
+
break;
|
|
745
754
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
755
|
+
}
|
|
756
|
+
function createBindingIndex() {
|
|
757
|
+
const scopes = /* @__PURE__ */ new Map();
|
|
758
|
+
const scopeBindings = (scope) => {
|
|
759
|
+
let bindings = scopes.get(scope);
|
|
760
|
+
if (bindings == null) {
|
|
761
|
+
bindings = /* @__PURE__ */ new Map();
|
|
762
|
+
scopes.set(scope, bindings);
|
|
763
|
+
if (isFunctionLike(scope)) {
|
|
764
|
+
if (scope.type === "FunctionExpression" && scope.id != null) bindings.set(scope.id.name, { value: scope });
|
|
765
|
+
for (const param of scope.params) bindPattern(param, bindings);
|
|
766
|
+
}
|
|
767
|
+
if (scope.type === "ClassExpression" && scope.id != null) bindings.set(scope.id.name, { value: null });
|
|
768
|
+
if (scope.type === "CatchClause" && scope.param != null) bindPattern(scope.param, bindings);
|
|
769
|
+
}
|
|
770
|
+
return bindings;
|
|
771
|
+
};
|
|
772
|
+
const enclosingScope = (node, functionScope = false) => {
|
|
773
|
+
let scope = getParent(node);
|
|
774
|
+
while (scope.type !== "Program" && scope.type !== "StaticBlock" && scope.type !== "TSModuleBlock" && !isFunctionLike(scope) && (functionScope || ![
|
|
775
|
+
"BlockStatement",
|
|
776
|
+
"ForStatement",
|
|
777
|
+
"ForInStatement",
|
|
778
|
+
"ForOfStatement",
|
|
779
|
+
"SwitchStatement",
|
|
780
|
+
"CatchClause"
|
|
781
|
+
].includes(scope.type))) scope = getParent(scope);
|
|
782
|
+
return scope;
|
|
783
|
+
};
|
|
784
|
+
const lookup = (node, name) => {
|
|
785
|
+
for (let scope = node; scope != null; scope = getParent(scope)) {
|
|
786
|
+
const binding = scopeBindings(scope).get(name);
|
|
787
|
+
if (binding != null) return binding;
|
|
788
|
+
}
|
|
789
|
+
return null;
|
|
790
|
+
};
|
|
791
|
+
return {
|
|
792
|
+
lookup,
|
|
793
|
+
declare(node, pattern, value, hoisted = false) {
|
|
794
|
+
const bindings = scopeBindings(enclosingScope(node, hoisted));
|
|
795
|
+
if (pattern.type === "Identifier") {
|
|
796
|
+
if (hoisted && value == null && bindings.has(pattern.name)) return;
|
|
797
|
+
if (node.type === "FunctionDeclaration" && bindings.get(pattern.name)?.initializedVariable) return;
|
|
798
|
+
bindings.set(pattern.name, {
|
|
799
|
+
value,
|
|
800
|
+
initializedVariable: node.type === "VariableDeclarator" && value != null
|
|
801
|
+
});
|
|
802
|
+
} else bindPattern(pattern, bindings);
|
|
756
803
|
}
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
const resolveBindingValue = (expr, bindings, seen = /* @__PURE__ */ new Set()) => {
|
|
807
|
+
if (expr.type !== "Identifier") return expr;
|
|
808
|
+
const binding = bindings.lookup(expr, expr.name);
|
|
809
|
+
if (binding == null || binding.value == null || seen.has(binding)) return null;
|
|
810
|
+
seen.add(binding);
|
|
811
|
+
return resolveBindingValue(binding.value, bindings, seen);
|
|
812
|
+
};
|
|
813
|
+
const resolveListenerReference = (expr, bindings) => {
|
|
814
|
+
const target = resolveBindingValue(expr, bindings);
|
|
815
|
+
if (target == null) return null;
|
|
816
|
+
if (isFunctionLike(target)) return target;
|
|
817
|
+
if (target.type !== "MemberExpression") return null;
|
|
818
|
+
const object = resolveBindingValue(target.object, bindings);
|
|
819
|
+
if (object?.type !== "ObjectExpression") return null;
|
|
820
|
+
const propertyName = getMemberPropertyName(target);
|
|
821
|
+
if (propertyName == null) return null;
|
|
822
|
+
for (const prop of object.properties) {
|
|
823
|
+
if (prop.type !== "Property") continue;
|
|
824
|
+
if ((prop.key.type === "Identifier" && !prop.computed ? prop.key.name : prop.key.type === "Literal" && typeof prop.key.value === "string" ? prop.key.value : null) !== propertyName) continue;
|
|
825
|
+
const value = resolveBindingValue(prop.value, bindings);
|
|
826
|
+
if (value != null && isFunctionLike(value)) return value;
|
|
757
827
|
}
|
|
758
828
|
return null;
|
|
759
829
|
};
|
|
760
|
-
|
|
830
|
+
function unwrapArgument(node) {
|
|
831
|
+
while (node.type === "TSAsExpression" || node.type === "TSTypeAssertion" || node.type === "TSNonNullExpression") node = node.expression;
|
|
832
|
+
return node;
|
|
833
|
+
}
|
|
834
|
+
function functionCallsDelivery(sourceCode, listener, bindings, calls, contextIndex = 0, visited = /* @__PURE__ */ new Map()) {
|
|
835
|
+
let indices = visited.get(listener);
|
|
836
|
+
if (indices?.has(contextIndex)) return false;
|
|
837
|
+
if (indices == null) visited.set(listener, indices = /* @__PURE__ */ new Set());
|
|
838
|
+
indices.add(contextIndex);
|
|
839
|
+
if (listenerCallsDeliveryMethod(sourceCode, listener, contextIndex)) return true;
|
|
840
|
+
const param = unwrapContextParam(listener.params[contextIndex]);
|
|
841
|
+
if (param?.type !== "Identifier") return false;
|
|
842
|
+
const contextBinding = bindings.lookup(listener, param.name);
|
|
843
|
+
for (const call of calls) {
|
|
844
|
+
let child = call;
|
|
845
|
+
let owner = getParent(child);
|
|
846
|
+
while (owner != null && !isFunctionLike(owner)) {
|
|
847
|
+
const field = owner;
|
|
848
|
+
if ((field.type === "PropertyDefinition" || field.type === "AccessorProperty") && !field.static && field.value === child) break;
|
|
849
|
+
child = owner;
|
|
850
|
+
owner = getParent(owner);
|
|
851
|
+
}
|
|
852
|
+
if (owner !== listener) continue;
|
|
853
|
+
const helper = resolveListenerReference(call.callee, bindings);
|
|
854
|
+
if (helper == null || "generator" in helper && helper.generator) continue;
|
|
855
|
+
for (const [index, argument] of call.arguments.entries()) {
|
|
856
|
+
if (argument.type === "SpreadElement") break;
|
|
857
|
+
const arg = unwrapArgument(argument);
|
|
858
|
+
if (arg.type !== "Identifier" || arg.name !== param.name || bindings.lookup(arg, arg.name) !== contextBinding || helper.params[index]?.type === "RestElement") continue;
|
|
859
|
+
if (functionCallsDelivery(sourceCode, helper, bindings, calls, index, visited)) return true;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return false;
|
|
863
|
+
}
|
|
864
|
+
const listenerCallsDeliveryMethod = (sourceCode, listener, contextIndex = 0) => {
|
|
761
865
|
const code = stripCommentsAndStrings(sourceCode.getText(listener));
|
|
762
866
|
const aliases = /* @__PURE__ */ new Set();
|
|
763
|
-
const contextParam = unwrapContextParam(listener.params[
|
|
867
|
+
const contextParam = unwrapContextParam(listener.params[contextIndex]);
|
|
764
868
|
const contextName = contextParam?.type === "Identifier" ? contextParam.name : null;
|
|
765
869
|
if (contextParam?.type === "ObjectPattern") for (const prop of contextParam.properties) {
|
|
766
870
|
if (!isNode(prop) || prop.type !== "Property") continue;
|
|
@@ -789,7 +893,7 @@ const listenerCallsDeliveryMethod = (sourceCode, listener) => {
|
|
|
789
893
|
function createRule(buildReport) {
|
|
790
894
|
return (context) => {
|
|
791
895
|
const federationTracker = trackFederationVariables();
|
|
792
|
-
const bindings =
|
|
896
|
+
const bindings = createBindingIndex();
|
|
793
897
|
const pendingCalls = [];
|
|
794
898
|
const sourceCode = context.sourceCode;
|
|
795
899
|
const inspectCall = (node) => {
|
|
@@ -798,7 +902,7 @@ function createRule(buildReport) {
|
|
|
798
902
|
const listener = node.arguments[1];
|
|
799
903
|
const resolvedListener = isNode(listener) && isFunction(listener) ? listener : isNode(listener) ? resolveListenerReference(listener, bindings) : null;
|
|
800
904
|
if (resolvedListener == null) return;
|
|
801
|
-
if (
|
|
905
|
+
if (functionCallsDelivery(sourceCode, resolvedListener, bindings, pendingCalls)) return;
|
|
802
906
|
context.report({
|
|
803
907
|
node: resolvedListener,
|
|
804
908
|
...buildReport
|
|
@@ -807,10 +911,21 @@ function createRule(buildReport) {
|
|
|
807
911
|
return {
|
|
808
912
|
VariableDeclarator(node) {
|
|
809
913
|
federationTracker.VariableDeclarator(node);
|
|
810
|
-
|
|
914
|
+
const declaration = getParent(node);
|
|
915
|
+
bindings.declare(node, node.id, node.init, declaration?.kind === "var");
|
|
811
916
|
},
|
|
812
917
|
FunctionDeclaration(node) {
|
|
813
|
-
if (node.id
|
|
918
|
+
if (node.id == null) return;
|
|
919
|
+
const parent = getParent(node);
|
|
920
|
+
const owner = parent == null ? null : getParent(parent);
|
|
921
|
+
const inVarBody = parent?.type === "BlockStatement" && owner != null && (owner.type === "StaticBlock" || isFunctionLike(owner) && owner.body === parent);
|
|
922
|
+
bindings.declare(node, node.id, node, inVarBody);
|
|
923
|
+
},
|
|
924
|
+
ImportDeclaration(node) {
|
|
925
|
+
for (const specifier of node.specifiers) bindings.declare(node, specifier.local, null);
|
|
926
|
+
},
|
|
927
|
+
ClassDeclaration(node) {
|
|
928
|
+
if (node.id != null) bindings.declare(node, node.id, null);
|
|
814
929
|
},
|
|
815
930
|
CallExpression(node) {
|
|
816
931
|
pendingCalls.push(node);
|
|
@@ -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.3.9
|
|
4
|
+
var version = "2.3.9";
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/lib/const.ts
|
|
7
7
|
/**
|
|
@@ -595,7 +595,7 @@ const DELIVERY_METHOD_NAMES = new Set(["sendActivity", "forwardActivity"]);
|
|
|
595
595
|
const getMemberPropertyName = (expr) => {
|
|
596
596
|
if (expr.type !== "MemberExpression") return null;
|
|
597
597
|
const property = expr.property;
|
|
598
|
-
if (property.type === "Identifier") return property.name;
|
|
598
|
+
if (property.type === "Identifier" && !expr.computed) return property.name;
|
|
599
599
|
if (property.type === "Literal" && typeof property.value === "string") return property.value;
|
|
600
600
|
return null;
|
|
601
601
|
};
|
|
@@ -731,35 +731,139 @@ function buildContextExpressionPattern(contextName) {
|
|
|
731
731
|
const boundedName = String.raw`(?<![\w$])${name}(?![\w$])`;
|
|
732
732
|
return String.raw`(?:${boundedName}|\(\s*${boundedName}(?:\s+as\s+[^)]+)?\s*\))`;
|
|
733
733
|
}
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
734
|
+
const getParent = (node) => node.parent ?? null;
|
|
735
|
+
const isFunctionLike = (node) => node.type === "FunctionDeclaration" || isFunction(node);
|
|
736
|
+
function bindPattern(node, bindings) {
|
|
737
|
+
switch (node.type) {
|
|
738
|
+
case "Identifier":
|
|
739
|
+
bindings.set(node.name, { value: null });
|
|
740
|
+
break;
|
|
741
|
+
case "AssignmentPattern":
|
|
742
|
+
bindPattern(node.left, bindings);
|
|
743
|
+
break;
|
|
744
|
+
case "RestElement":
|
|
745
|
+
bindPattern(node.argument, bindings);
|
|
746
|
+
break;
|
|
747
|
+
case "ObjectPattern":
|
|
748
|
+
for (const property of node.properties) bindPattern(property.type === "Property" ? property.value : property, bindings);
|
|
749
|
+
break;
|
|
750
|
+
case "ArrayPattern":
|
|
751
|
+
for (const element of node.elements) if (element != null) bindPattern(element, bindings);
|
|
752
|
+
break;
|
|
744
753
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
754
|
+
}
|
|
755
|
+
function createBindingIndex() {
|
|
756
|
+
const scopes = /* @__PURE__ */ new Map();
|
|
757
|
+
const scopeBindings = (scope) => {
|
|
758
|
+
let bindings = scopes.get(scope);
|
|
759
|
+
if (bindings == null) {
|
|
760
|
+
bindings = /* @__PURE__ */ new Map();
|
|
761
|
+
scopes.set(scope, bindings);
|
|
762
|
+
if (isFunctionLike(scope)) {
|
|
763
|
+
if (scope.type === "FunctionExpression" && scope.id != null) bindings.set(scope.id.name, { value: scope });
|
|
764
|
+
for (const param of scope.params) bindPattern(param, bindings);
|
|
765
|
+
}
|
|
766
|
+
if (scope.type === "ClassExpression" && scope.id != null) bindings.set(scope.id.name, { value: null });
|
|
767
|
+
if (scope.type === "CatchClause" && scope.param != null) bindPattern(scope.param, bindings);
|
|
768
|
+
}
|
|
769
|
+
return bindings;
|
|
770
|
+
};
|
|
771
|
+
const enclosingScope = (node, functionScope = false) => {
|
|
772
|
+
let scope = getParent(node);
|
|
773
|
+
while (scope.type !== "Program" && scope.type !== "StaticBlock" && scope.type !== "TSModuleBlock" && !isFunctionLike(scope) && (functionScope || ![
|
|
774
|
+
"BlockStatement",
|
|
775
|
+
"ForStatement",
|
|
776
|
+
"ForInStatement",
|
|
777
|
+
"ForOfStatement",
|
|
778
|
+
"SwitchStatement",
|
|
779
|
+
"CatchClause"
|
|
780
|
+
].includes(scope.type))) scope = getParent(scope);
|
|
781
|
+
return scope;
|
|
782
|
+
};
|
|
783
|
+
const lookup = (node, name) => {
|
|
784
|
+
for (let scope = node; scope != null; scope = getParent(scope)) {
|
|
785
|
+
const binding = scopeBindings(scope).get(name);
|
|
786
|
+
if (binding != null) return binding;
|
|
787
|
+
}
|
|
788
|
+
return null;
|
|
789
|
+
};
|
|
790
|
+
return {
|
|
791
|
+
lookup,
|
|
792
|
+
declare(node, pattern, value, hoisted = false) {
|
|
793
|
+
const bindings = scopeBindings(enclosingScope(node, hoisted));
|
|
794
|
+
if (pattern.type === "Identifier") {
|
|
795
|
+
if (hoisted && value == null && bindings.has(pattern.name)) return;
|
|
796
|
+
if (node.type === "FunctionDeclaration" && bindings.get(pattern.name)?.initializedVariable) return;
|
|
797
|
+
bindings.set(pattern.name, {
|
|
798
|
+
value,
|
|
799
|
+
initializedVariable: node.type === "VariableDeclarator" && value != null
|
|
800
|
+
});
|
|
801
|
+
} else bindPattern(pattern, bindings);
|
|
755
802
|
}
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
const resolveBindingValue = (expr, bindings, seen = /* @__PURE__ */ new Set()) => {
|
|
806
|
+
if (expr.type !== "Identifier") return expr;
|
|
807
|
+
const binding = bindings.lookup(expr, expr.name);
|
|
808
|
+
if (binding == null || binding.value == null || seen.has(binding)) return null;
|
|
809
|
+
seen.add(binding);
|
|
810
|
+
return resolveBindingValue(binding.value, bindings, seen);
|
|
811
|
+
};
|
|
812
|
+
const resolveListenerReference = (expr, bindings) => {
|
|
813
|
+
const target = resolveBindingValue(expr, bindings);
|
|
814
|
+
if (target == null) return null;
|
|
815
|
+
if (isFunctionLike(target)) return target;
|
|
816
|
+
if (target.type !== "MemberExpression") return null;
|
|
817
|
+
const object = resolveBindingValue(target.object, bindings);
|
|
818
|
+
if (object?.type !== "ObjectExpression") return null;
|
|
819
|
+
const propertyName = getMemberPropertyName(target);
|
|
820
|
+
if (propertyName == null) return null;
|
|
821
|
+
for (const prop of object.properties) {
|
|
822
|
+
if (prop.type !== "Property") continue;
|
|
823
|
+
if ((prop.key.type === "Identifier" && !prop.computed ? prop.key.name : prop.key.type === "Literal" && typeof prop.key.value === "string" ? prop.key.value : null) !== propertyName) continue;
|
|
824
|
+
const value = resolveBindingValue(prop.value, bindings);
|
|
825
|
+
if (value != null && isFunctionLike(value)) return value;
|
|
756
826
|
}
|
|
757
827
|
return null;
|
|
758
828
|
};
|
|
759
|
-
|
|
829
|
+
function unwrapArgument(node) {
|
|
830
|
+
while (node.type === "TSAsExpression" || node.type === "TSTypeAssertion" || node.type === "TSNonNullExpression") node = node.expression;
|
|
831
|
+
return node;
|
|
832
|
+
}
|
|
833
|
+
function functionCallsDelivery(sourceCode, listener, bindings, calls, contextIndex = 0, visited = /* @__PURE__ */ new Map()) {
|
|
834
|
+
let indices = visited.get(listener);
|
|
835
|
+
if (indices?.has(contextIndex)) return false;
|
|
836
|
+
if (indices == null) visited.set(listener, indices = /* @__PURE__ */ new Set());
|
|
837
|
+
indices.add(contextIndex);
|
|
838
|
+
if (listenerCallsDeliveryMethod(sourceCode, listener, contextIndex)) return true;
|
|
839
|
+
const param = unwrapContextParam(listener.params[contextIndex]);
|
|
840
|
+
if (param?.type !== "Identifier") return false;
|
|
841
|
+
const contextBinding = bindings.lookup(listener, param.name);
|
|
842
|
+
for (const call of calls) {
|
|
843
|
+
let child = call;
|
|
844
|
+
let owner = getParent(child);
|
|
845
|
+
while (owner != null && !isFunctionLike(owner)) {
|
|
846
|
+
const field = owner;
|
|
847
|
+
if ((field.type === "PropertyDefinition" || field.type === "AccessorProperty") && !field.static && field.value === child) break;
|
|
848
|
+
child = owner;
|
|
849
|
+
owner = getParent(owner);
|
|
850
|
+
}
|
|
851
|
+
if (owner !== listener) continue;
|
|
852
|
+
const helper = resolveListenerReference(call.callee, bindings);
|
|
853
|
+
if (helper == null || "generator" in helper && helper.generator) continue;
|
|
854
|
+
for (const [index, argument] of call.arguments.entries()) {
|
|
855
|
+
if (argument.type === "SpreadElement") break;
|
|
856
|
+
const arg = unwrapArgument(argument);
|
|
857
|
+
if (arg.type !== "Identifier" || arg.name !== param.name || bindings.lookup(arg, arg.name) !== contextBinding || helper.params[index]?.type === "RestElement") continue;
|
|
858
|
+
if (functionCallsDelivery(sourceCode, helper, bindings, calls, index, visited)) return true;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
const listenerCallsDeliveryMethod = (sourceCode, listener, contextIndex = 0) => {
|
|
760
864
|
const code = stripCommentsAndStrings(sourceCode.getText(listener));
|
|
761
865
|
const aliases = /* @__PURE__ */ new Set();
|
|
762
|
-
const contextParam = unwrapContextParam(listener.params[
|
|
866
|
+
const contextParam = unwrapContextParam(listener.params[contextIndex]);
|
|
763
867
|
const contextName = contextParam?.type === "Identifier" ? contextParam.name : null;
|
|
764
868
|
if (contextParam?.type === "ObjectPattern") for (const prop of contextParam.properties) {
|
|
765
869
|
if (!isNode(prop) || prop.type !== "Property") continue;
|
|
@@ -788,7 +892,7 @@ const listenerCallsDeliveryMethod = (sourceCode, listener) => {
|
|
|
788
892
|
function createRule(buildReport) {
|
|
789
893
|
return (context) => {
|
|
790
894
|
const federationTracker = trackFederationVariables();
|
|
791
|
-
const bindings =
|
|
895
|
+
const bindings = createBindingIndex();
|
|
792
896
|
const pendingCalls = [];
|
|
793
897
|
const sourceCode = context.sourceCode;
|
|
794
898
|
const inspectCall = (node) => {
|
|
@@ -797,7 +901,7 @@ function createRule(buildReport) {
|
|
|
797
901
|
const listener = node.arguments[1];
|
|
798
902
|
const resolvedListener = isNode(listener) && isFunction(listener) ? listener : isNode(listener) ? resolveListenerReference(listener, bindings) : null;
|
|
799
903
|
if (resolvedListener == null) return;
|
|
800
|
-
if (
|
|
904
|
+
if (functionCallsDelivery(sourceCode, resolvedListener, bindings, pendingCalls)) return;
|
|
801
905
|
context.report({
|
|
802
906
|
node: resolvedListener,
|
|
803
907
|
...buildReport
|
|
@@ -806,10 +910,21 @@ function createRule(buildReport) {
|
|
|
806
910
|
return {
|
|
807
911
|
VariableDeclarator(node) {
|
|
808
912
|
federationTracker.VariableDeclarator(node);
|
|
809
|
-
|
|
913
|
+
const declaration = getParent(node);
|
|
914
|
+
bindings.declare(node, node.id, node.init, declaration?.kind === "var");
|
|
810
915
|
},
|
|
811
916
|
FunctionDeclaration(node) {
|
|
812
|
-
if (node.id
|
|
917
|
+
if (node.id == null) return;
|
|
918
|
+
const parent = getParent(node);
|
|
919
|
+
const owner = parent == null ? null : getParent(parent);
|
|
920
|
+
const inVarBody = parent?.type === "BlockStatement" && owner != null && (owner.type === "StaticBlock" || isFunctionLike(owner) && owner.body === parent);
|
|
921
|
+
bindings.declare(node, node.id, node, inVarBody);
|
|
922
|
+
},
|
|
923
|
+
ImportDeclaration(node) {
|
|
924
|
+
for (const specifier of node.specifiers) bindings.declare(node, specifier.local, null);
|
|
925
|
+
},
|
|
926
|
+
ClassDeclaration(node) {
|
|
927
|
+
if (node.id != null) bindings.declare(node, node.id, null);
|
|
813
928
|
},
|
|
814
929
|
CallExpression(node) {
|
|
815
930
|
pendingCalls.push(node);
|
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-CiBWUvMt.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$12,
|
package/dist/oxlint.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as RULE_IDS, S as eslint$19, T as version, _ as eslint$5, a as eslint$18, b as eslint$10, c as eslint$8, d as eslint$15, f as eslint$1, g as eslint$4, h as eslint$3, i as eslint$17, l as eslint$9, m as eslint$2, n as eslint$20, o as eslint$6, p as eslint, r as eslint$16, s as eslint$7, t as eslint$21, u as eslint$14, v as eslint$12, w as name, x as eslint$11, y as eslint$13 } from "./outbox-listener-delivery-required-
|
|
1
|
+
import { C as RULE_IDS, S as eslint$19, T as version, _ as eslint$5, a as eslint$18, b as eslint$10, c as eslint$8, d as eslint$15, f as eslint$1, g as eslint$4, h as eslint$3, i as eslint$17, l as eslint$9, m as eslint$2, n as eslint$20, o as eslint$6, p as eslint, r as eslint$16, s as eslint$7, t as eslint$21, u as eslint$14, v as eslint$12, w as name, x as eslint$11, y as eslint$13 } from "./outbox-listener-delivery-required-DBgDh8Og.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.3.9
|
|
3
|
+
"version": "2.3.9",
|
|
4
4
|
"description": "Fedify linting rules and plugins",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fedify",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
],
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"eslint": ">=9.0.0",
|
|
57
|
-
"@fedify/fedify": "^2.3.9
|
|
57
|
+
"@fedify/fedify": "^2.3.9"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"eslint": {
|