@fedify/lint 2.0.0-dev.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 ADDED
@@ -0,0 +1,726 @@
1
+ import { always, every, fromEntries, head, isEmpty, isObject, keys, map, negate, pipe, pipeLazy, prop, some, toArray, unless, when } from "@fxts/core";
2
+ import parser from "@typescript-eslint/parser";
3
+
4
+ //#region deno.json
5
+ var name = "@fedify/lint";
6
+ var version = "2.0.0";
7
+ var license = "MIT";
8
+ var exports = { ".": "./src/mod.ts" };
9
+ var imports = {
10
+ "eslint": "npm:eslint@^9.0.0",
11
+ "estree": "npm:@types/estree@^1.0.8"
12
+ };
13
+ var tasks = { "test": "deno test --allow-env" };
14
+ var deno_default = {
15
+ name,
16
+ version,
17
+ license,
18
+ exports,
19
+ imports,
20
+ tasks
21
+ };
22
+
23
+ //#endregion
24
+ //#region src/lib/const.ts
25
+ /**
26
+ * Mapping of actor property names to their corresponding Context method names
27
+ * and dispatcher methods.
28
+ * Used by lint rules to validate property existence and correct method usage.
29
+ */
30
+ const properties = {
31
+ id: {
32
+ name: "id",
33
+ path: ["id"],
34
+ getter: "getActorUri",
35
+ setter: "setActorDispatcher",
36
+ requiresIdentifier: true
37
+ },
38
+ following: {
39
+ name: "following",
40
+ path: ["following"],
41
+ getter: "getFollowingUri",
42
+ setter: "setFollowingDispatcher",
43
+ requiresIdentifier: true
44
+ },
45
+ followers: {
46
+ name: "followers",
47
+ path: ["followers"],
48
+ getter: "getFollowersUri",
49
+ setter: "setFollowersDispatcher",
50
+ requiresIdentifier: true
51
+ },
52
+ outbox: {
53
+ name: "outbox",
54
+ path: ["outbox"],
55
+ getter: "getOutboxUri",
56
+ setter: "setOutboxDispatcher",
57
+ requiresIdentifier: true
58
+ },
59
+ inbox: {
60
+ name: "inbox",
61
+ path: ["inbox"],
62
+ getter: "getInboxUri",
63
+ setter: "setInboxListeners",
64
+ requiresIdentifier: true
65
+ },
66
+ liked: {
67
+ name: "liked",
68
+ path: ["liked"],
69
+ getter: "getLikedUri",
70
+ setter: "setLikedDispatcher",
71
+ requiresIdentifier: true
72
+ },
73
+ featured: {
74
+ name: "featured",
75
+ path: ["featured"],
76
+ getter: "getFeaturedUri",
77
+ setter: "setFeaturedDispatcher",
78
+ requiresIdentifier: true
79
+ },
80
+ featuredTags: {
81
+ name: "featuredTags",
82
+ path: ["featuredTags"],
83
+ getter: "getFeaturedTagsUri",
84
+ setter: "setFeaturedTagsDispatcher",
85
+ requiresIdentifier: true
86
+ },
87
+ sharedInbox: {
88
+ name: "sharedInbox",
89
+ path: ["endpoints", "sharedInbox"],
90
+ getter: "getInboxUri",
91
+ setter: "setInboxListeners",
92
+ requiresIdentifier: false,
93
+ nested: {
94
+ parent: "endpoints",
95
+ wrapper: "Endpoints"
96
+ }
97
+ },
98
+ publicKey: {
99
+ name: "publicKey",
100
+ path: ["publicKey"],
101
+ getter: "getActorKeyPairs",
102
+ setter: "setKeyPairsDispatcher",
103
+ requiresIdentifier: true,
104
+ isKeyProperty: true
105
+ },
106
+ assertionMethod: {
107
+ name: "assertionMethod",
108
+ path: ["assertionMethod"],
109
+ getter: "getActorKeyPairs",
110
+ setter: "setKeyPairsDispatcher",
111
+ requiresIdentifier: true,
112
+ isKeyProperty: true
113
+ }
114
+ };
115
+ /**
116
+ * Rule IDs for all Fedify lint rules
117
+ */
118
+ const RULE_IDS = {
119
+ actorIdRequired: "actor-id-required",
120
+ actorFollowingPropertyRequired: "actor-following-property-required",
121
+ actorFollowersPropertyRequired: "actor-followers-property-required",
122
+ actorOutboxPropertyRequired: "actor-outbox-property-required",
123
+ actorLikedPropertyRequired: "actor-liked-property-required",
124
+ actorFeaturedPropertyRequired: "actor-featured-property-required",
125
+ actorFeaturedTagsPropertyRequired: "actor-featured-tags-property-required",
126
+ actorInboxPropertyRequired: "actor-inbox-property-required",
127
+ actorSharedInboxPropertyRequired: "actor-shared-inbox-property-required",
128
+ actorPublicKeyRequired: "actor-public-key-required",
129
+ actorAssertionMethodRequired: "actor-assertion-method-required",
130
+ actorIdMismatch: "actor-id-mismatch",
131
+ actorFollowingPropertyMismatch: "actor-following-property-mismatch",
132
+ actorFollowersPropertyMismatch: "actor-followers-property-mismatch",
133
+ actorOutboxPropertyMismatch: "actor-outbox-property-mismatch",
134
+ actorLikedPropertyMismatch: "actor-liked-property-mismatch",
135
+ actorFeaturedPropertyMismatch: "actor-featured-property-mismatch",
136
+ actorFeaturedTagsPropertyMismatch: "actor-featured-tags-property-mismatch",
137
+ actorInboxPropertyMismatch: "actor-inbox-property-mismatch",
138
+ actorSharedInboxPropertyMismatch: "actor-shared-inbox-property-mismatch",
139
+ collectionFilteringNotImplemented: "collection-filtering-not-implemented"
140
+ };
141
+
142
+ //#endregion
143
+ //#region src/lib/messages.ts
144
+ /**
145
+ * Generates error message for *-required rules.
146
+ * Used when a property is missing from the actor dispatcher return value.
147
+ *
148
+ * @param name - The property name (e.g., "id", "inbox", "following")
149
+ */
150
+ const actorPropertyRequired = ({ setter, path, getter, requiresIdentifier = true }) => `When \`${setter}\` is configured, the \`${path.join(".")}\` property is recommended. Use \`${getExpectedCall({
151
+ ctxName: "Context",
152
+ methodName: getter,
153
+ idName: "identifier",
154
+ path: path.join("."),
155
+ requiresIdentifier
156
+ })}\` for the \`${path.join(".")}\` property URI.`;
157
+ /**
158
+ * Generates error message for *-mismatch rules.
159
+ * Used when a property exists but uses the wrong context method.
160
+ *
161
+ * @param propertyName - The property name or path
162
+ * (e.g., "id", "endpoints.sharedInbox")
163
+ * @param expectedCall - The expected method call
164
+ * (e.g., "ctx.getActorUri(identifier)")
165
+ */
166
+ const actorPropertyMismatch = (context) => `Actor's \`${context.path}\` property must match \`${getExpectedCall(context)}\`. \
167
+ Ensure you're using the correct context method.`;
168
+ const getExpectedCall = ({ ctxName, methodName, requiresIdentifier, idName }) => requiresIdentifier ? `${ctxName}.${methodName}(${idName})` : `${ctxName}.${methodName}()`;
169
+ /**
170
+ * Error message for collection filtering not implemented.
171
+ */
172
+ const COLLECTION_FILTERING_NOT_IMPLEMENTED_ERROR = "Collection dispatcher should implement filtering to avoid large response payloads. Add a fourth parameter (filter) to handle filtering. See: https://fedify.dev/manual/collections#filtering-by-server";
173
+
174
+ //#endregion
175
+ //#region src/lib/utils.ts
176
+ const eq = (value) => (other) => value === other;
177
+ function cases(pred, ifTrue, ifFalse) {
178
+ return (value) => pred(value) ? ifTrue(value) : ifFalse(value);
179
+ }
180
+
181
+ //#endregion
182
+ //#region src/lib/pred.ts
183
+ function allOf(...predicates) {
184
+ return (value) => predicates.every((predicate) => predicate(value));
185
+ }
186
+ const anyOf = (...predicates) => (value) => predicates.some((predicate) => predicate(value));
187
+ /**
188
+ * Checks if a node is of a specific type.
189
+ */
190
+ const isNodeType = (type) => (node) => pipe(node, prop("type"), eq(type));
191
+ /**
192
+ * Checks if a node is of a specific name.
193
+ */
194
+ const isNodeName = (name$1) => (node) => pipe(node, prop("name"), eq(name$1));
195
+ /**
196
+ * Checks if a node's callee is a MemberExpression.
197
+ */
198
+ const hasMemberExpressionCallee = (node) => node.callee.type === "MemberExpression";
199
+ /**
200
+ * Checks if a node's callee property is an Identifier.
201
+ */
202
+ const hasIdentifierProperty = (node) => "callee" in node && "property" in node.callee && "type" in node.callee.property && node.callee.property.type === "Identifier";
203
+ /**
204
+ * Checks if a node's callee property name matches the given method name.
205
+ */
206
+ const hasMethodName = (methodName) => (node) => "callee" in node && "property" in node.callee && "name" in node.callee.property && node.callee.property.name === methodName;
207
+ /**
208
+ * Checks if a CallExpression has minimum required arguments.
209
+ */
210
+ const hasMinArguments = (min) => (node) => node.arguments.length >= min;
211
+ /**
212
+ * Checks if an expression is a function (arrow or regular).
213
+ */
214
+ const isFunction = (expr) => anyOf(isNodeType("ArrowFunctionExpression"), isNodeType("FunctionExpression"))(expr);
215
+ /**
216
+ * Checks if a CallExpression is a setActorDispatcher call with
217
+ * proper structure.
218
+ */
219
+ const isSetActorDispatcherCall = (node) => allOf(hasMemberExpressionCallee, hasIdentifierProperty, hasMethodName("setActorDispatcher"), hasMinArguments(2))(node);
220
+ /**
221
+ * Checks if a function has at least n parameters.
222
+ */
223
+ const hasMinParams = (min) => (fn) => fn.params.length >= min;
224
+
225
+ //#endregion
226
+ //#region src/lib/property-checker.ts
227
+ /**
228
+ * Checks if a node has a key with a specific name.
229
+ */
230
+ const hasKeyName = (propertyName) => (node) => pipe(node, prop("key"), allOf(isNodeType("Identifier"), pipeLazy(prop("name"), eq(propertyName))));
231
+ /**
232
+ * Checks if a node is a Property with an Identifier key of a specific name.
233
+ */
234
+ const isPropertyWithName = (propertyName) => (node) => allOf(isNodeType("Property"), hasKeyName(propertyName))(node);
235
+ /**
236
+ * Creates a predicate function that checks if a nested property exists.
237
+ * @param path Array of property names forming the path
238
+ * (e.g., ["endpoints", "sharedInbox"])
239
+ * @returns A predicate function that checks if the nested property exists
240
+ */
241
+ function createPropertyChecker(checker) {
242
+ const inner = ([first, ...rest]) => (node) => {
243
+ if (!isPropertyWithName(first)(node)) return false;
244
+ if (isEmpty(rest)) return checker(node.value);
245
+ if (isNodeType("NewExpression")(node.value)) {
246
+ if (node.value.arguments.length === 0) return false;
247
+ const firstArg = node.value.arguments[0];
248
+ if (!isNodeType("ObjectExpression")(firstArg)) return false;
249
+ return firstArg.properties.some(inner(rest));
250
+ }
251
+ return false;
252
+ };
253
+ return inner;
254
+ }
255
+ /**
256
+ * Checks if an ObjectExpression node contains a property.
257
+ * @param propertyChecker The predicate function to check properties
258
+ * @returns A function that checks the ObjectExpression
259
+ */
260
+ const checkObjectExpression = (propertyChecker) => (obj) => obj.properties.some(propertyChecker);
261
+ /**
262
+ * Checks if a ConditionalExpression (ternary operator) has the property in
263
+ * both branches.
264
+ * @param propertyChecker The predicate function to check properties
265
+ * @returns A function that checks the ConditionalExpression
266
+ */
267
+ const checkConditionalExpression = (propertyChecker) => (node) => [node.consequent, node.alternate].every(checkBranchWith(propertyChecker));
268
+ const checkBranchWith = (propertyChecker) => (branch) => pipe(branch, cases(isNodeType("ConditionalExpression"), checkConditionalExpression(propertyChecker), pipeLazy(extractObjectExpression, cases(isObject, checkObjectExpression(propertyChecker), always(false)))));
269
+ /**
270
+ * Extracts the first argument if it's an ObjectExpression.
271
+ */
272
+ const extractFirstObjectExpression = (node) => pipe(node, prop("arguments"), head, unless(isNodeType("ObjectExpression"), always(null)));
273
+ /**
274
+ * Extracts ObjectExpression from NewExpression.
275
+ */
276
+ const extractObjectExpression = cases(isNodeType("NewExpression"), extractFirstObjectExpression, always(null));
277
+ /**
278
+ * Checks if a ReturnStatement node contains a property.
279
+ * @param propertyChecker The predicate function to check properties
280
+ * @returns A function that checks the ReturnStatement
281
+ */
282
+ const checkReturnStatement = (propertyChecker) => (node) => pipe(node, prop("argument"), cases(isObject, checkBranchWith(propertyChecker), always(false)));
283
+ /**
284
+ * Creates a function that recursively checks for a property in an AST node.
285
+ * @param propertyChecker The predicate function to check properties
286
+ * @returns A recursive function that checks the AST node
287
+ */
288
+ const createPropertySearcher = (propertyChecker) => {
289
+ return (node) => {
290
+ switch (node.type) {
291
+ case "ReturnStatement": return checkReturnStatement(propertyChecker)(node);
292
+ case "BlockStatement": return checkAllReturnPaths(propertyChecker)(node);
293
+ case "NewExpression": return pipe(node, extractFirstObjectExpression, when(isObject, checkObjectExpression(propertyChecker)), Boolean);
294
+ default: return false;
295
+ }
296
+ };
297
+ };
298
+ const checkAllReturnPaths = (propertyChecker) => (node) => pipe(node, collectReturnPaths, cases(isEmpty, always(false), every(checkReturnStatement(propertyChecker))));
299
+ /**
300
+ * Collects all return statements from a node, traversing control flow.
301
+ * This handles if/else branches, loops, etc.
302
+ */
303
+ const collectReturnPaths = (node) => pipe(node, flatten, toArray);
304
+ function* flatten(node) {
305
+ switch (node.type) {
306
+ case "ReturnStatement":
307
+ yield node;
308
+ return;
309
+ case "IfStatement":
310
+ if (node.consequent) yield* flatten(node.consequent);
311
+ if (node.alternate) yield* flatten(node.alternate);
312
+ return;
313
+ case "BlockStatement":
314
+ for (const statement of node.body) yield* flatten(statement);
315
+ return;
316
+ case "SwitchStatement":
317
+ for (const switchCase of node.cases) for (const statement of switchCase.consequent) yield* flatten(statement);
318
+ return;
319
+ case "TryStatement":
320
+ yield* flatten(node.block);
321
+ if (node.handler) yield* flatten(node.handler.body);
322
+ if (node.finalizer) yield* flatten(node.finalizer);
323
+ return;
324
+ case "WhileStatement":
325
+ case "DoWhileStatement":
326
+ case "ForStatement":
327
+ case "ForInStatement":
328
+ case "ForOfStatement":
329
+ yield* flatten(node.body);
330
+ return;
331
+ case "LabeledStatement":
332
+ yield* flatten(node.body);
333
+ return;
334
+ case "WithStatement":
335
+ yield* flatten(node.body);
336
+ return;
337
+ default: return;
338
+ }
339
+ }
340
+
341
+ //#endregion
342
+ //#region src/lib/tracker.ts
343
+ /**
344
+ * Helper to track variable names that store the result of createFederation() or createFederationBuilder() calls
345
+ */
346
+ function trackFederationVariables() {
347
+ const federationVariables = /* @__PURE__ */ new Set();
348
+ const isFederationObject = (obj) => {
349
+ switch (obj.type) {
350
+ case "Identifier": return federationVariables.has(obj.name);
351
+ case "CallExpression":
352
+ if (isCreateFederation(obj)) return true;
353
+ if (obj.callee.type === "MemberExpression") return isFederationObject(obj.callee.object);
354
+ return false;
355
+ case "MemberExpression": return isFederationObject(obj.object);
356
+ }
357
+ return false;
358
+ };
359
+ return {
360
+ VariableDeclarator(node) {
361
+ const init = node.init;
362
+ const id = node.id;
363
+ if (init?.type === "CallExpression") {
364
+ if (isCreateFederation(init) && id.type === "Identifier") federationVariables.add(id.name);
365
+ }
366
+ },
367
+ isFederationVariable(name$1) {
368
+ return federationVariables.has(name$1);
369
+ },
370
+ isFederationObject
371
+ };
372
+ }
373
+ const isCreateFederation = (node) => node.callee.type === "Identifier" && /^create(Federation|FederationBuilder)$/i.test(node.callee.name);
374
+
375
+ //#endregion
376
+ //#region src/lib/required.ts
377
+ /**
378
+ * Checks if a CallExpression is a specific dispatcher method call.
379
+ */
380
+ const isDispatcherMethodCall = (methodName) => (node) => allOf(hasMemberExpressionCallee, hasIdentifierProperty, hasMethodName(methodName))(node);
381
+ /**
382
+ * Tracks dispatcher method calls on federation objects.
383
+ */
384
+ const createDispatcherTracker = (dispatcherMethod, federationTracker) => {
385
+ let dispatcherConfigured = false;
386
+ return {
387
+ isDispatcherConfigured: () => dispatcherConfigured,
388
+ checkDispatcherCall: (node) => {
389
+ if (isDispatcherMethodCall(dispatcherMethod)(node) && federationTracker.isFederationObject(node.callee.object)) dispatcherConfigured = true;
390
+ }
391
+ };
392
+ };
393
+ function createRequiredRule(config, description) {
394
+ return (context) => {
395
+ const federationTracker = trackFederationVariables();
396
+ const dispatcherTracker = createDispatcherTracker(config.setter, federationTracker);
397
+ const actorDispatchers = [];
398
+ const propertyChecker = createPropertyChecker(Boolean)(config.path);
399
+ const propertySearcher = createPropertySearcher(propertyChecker);
400
+ return {
401
+ VariableDeclarator: federationTracker.VariableDeclarator,
402
+ CallExpression(node) {
403
+ dispatcherTracker.checkDispatcherCall(node);
404
+ if (!isSetActorDispatcherCall(node)) return;
405
+ if (!federationTracker.isFederationObject(node.callee.object)) return;
406
+ const dispatcher = node.arguments[1];
407
+ if (isFunction(dispatcher)) actorDispatchers.push(dispatcher);
408
+ },
409
+ "Program:exit"() {
410
+ if (!dispatcherTracker.isDispatcherConfigured()) return;
411
+ for (const dispatcher of actorDispatchers) if (!propertySearcher(dispatcher.body)) context.report({
412
+ node: dispatcher,
413
+ ...description
414
+ });
415
+ }
416
+ };
417
+ };
418
+ }
419
+ /**
420
+ * Creates a required rule with the given property configuration.
421
+ */
422
+ function createRequiredRuleDeno(config) {
423
+ return { create: createRequiredRule(config, { message: actorPropertyRequired(config) }) };
424
+ }
425
+ /**
426
+ * Creates a required ESLint rule with the given property configuration.
427
+ */
428
+ function createRequiredRuleEslint(config) {
429
+ return {
430
+ meta: {
431
+ type: "suggestion",
432
+ docs: { description: `Ensure actor dispatcher returns ${config.path.join(".")} property.` },
433
+ schema: [],
434
+ messages: { required: "{{ message }}" }
435
+ },
436
+ create: createRequiredRule(config, {
437
+ messageId: "required",
438
+ data: { message: actorPropertyRequired(config) }
439
+ })
440
+ };
441
+ }
442
+
443
+ //#endregion
444
+ //#region src/rules/actor-assertion-method-required.ts
445
+ const deno$19 = createRequiredRuleDeno(properties.assertionMethod);
446
+ const eslint = createRequiredRuleEslint(properties.assertionMethod);
447
+
448
+ //#endregion
449
+ //#region src/lib/mismatch.ts
450
+ const isIdentifierWithName = (name$1) => (node) => allOf(isNodeType("Identifier"), isNodeName(name$1))(node);
451
+ /**
452
+ * Checks if a node is a CallExpression calling the expected context method.
453
+ */
454
+ const isExpectedMethodCall = ({ ctxName, idName, methodName, requiresIdentifier }) => (node) => {
455
+ if (!isNodeType("CallExpression")(node) || !hasMemberExpressionCallee(node) || !isIdentifierWithName(ctxName)(node.callee.object) || !isIdentifierWithName(methodName)(node.callee.property)) return false;
456
+ if (!requiresIdentifier) return isEmpty(node.arguments);
457
+ return allOf(negate(isEmpty), some(isIdentifierWithName(idName)))(node.arguments);
458
+ };
459
+ /**
460
+ * Extracts parameter names from a function.
461
+ */
462
+ const extractParams = (fn) => {
463
+ const params = fn.params;
464
+ if (params.length < 2) return [null, null];
465
+ return params.slice(0, 2).map(getNameIfIdentifier);
466
+ };
467
+ const getNameIfIdentifier = (node) => node?.type === "Identifier" ? node.name : null;
468
+ function createMismatchRule(config, describe) {
469
+ return (context) => {
470
+ const tracker = trackFederationVariables();
471
+ return {
472
+ VariableDeclarator: tracker.VariableDeclarator,
473
+ CallExpression(node) {
474
+ if (!isSetActorDispatcherCall(node) || !hasMemberExpressionCallee(node) || !tracker.isFederationObject(node.callee.object)) return;
475
+ const dispatcherArg = node.arguments[1];
476
+ if (!isFunction(dispatcherArg)) return;
477
+ const [ctxName, idName] = extractParams(dispatcherArg);
478
+ if (!ctxName || !idName) return;
479
+ const methodCallContext = {
480
+ path: config.path.join("."),
481
+ ctxName,
482
+ idName,
483
+ methodName: config.getter,
484
+ requiresIdentifier: config.requiresIdentifier
485
+ };
486
+ const existenceChecker = createPropertyChecker(Boolean)(config.path);
487
+ const hasProperty = createPropertySearcher(existenceChecker)(dispatcherArg.body);
488
+ if (!hasProperty) return;
489
+ const propertyChecker = createPropertyChecker(isExpectedMethodCall(methodCallContext))(config.path);
490
+ const propertySearcher = createPropertySearcher(propertyChecker);
491
+ if (!propertySearcher(dispatcherArg.body)) context.report({
492
+ node: dispatcherArg,
493
+ ...describe(methodCallContext)
494
+ });
495
+ }
496
+ };
497
+ };
498
+ }
499
+ /**
500
+ * Creates a lint rule that checks if a property uses
501
+ * the correct context method.
502
+ *
503
+ * @param config Property configuration containing name, getter, setter, and
504
+ * nested info
505
+ * @returns A Deno lint rule
506
+ */
507
+ const createMismatchRuleDeno = (config) => ({ create: createMismatchRule(config, (context) => ({ message: actorPropertyMismatch(context) })) });
508
+ const createMismatchRuleEslint = (config) => ({
509
+ meta: {
510
+ type: "problem",
511
+ docs: { description: `Ensure actor's ${config.path.join(".")} property uses correct context method` },
512
+ schema: [],
513
+ messages: { mismatch: "{{ message }}" }
514
+ },
515
+ create: createMismatchRule(config, (context) => ({
516
+ messageId: "mismatch",
517
+ data: { message: actorPropertyMismatch(context) }
518
+ }))
519
+ });
520
+
521
+ //#endregion
522
+ //#region src/rules/actor-featured-property-mismatch.ts
523
+ const deno$18 = createMismatchRuleDeno(properties.featured);
524
+ const eslint$1 = createMismatchRuleEslint(properties.featured);
525
+
526
+ //#endregion
527
+ //#region src/rules/actor-featured-property-required.ts
528
+ const deno$17 = createRequiredRuleDeno(properties.featured);
529
+ const eslint$2 = createRequiredRuleEslint(properties.featured);
530
+
531
+ //#endregion
532
+ //#region src/rules/actor-featured-tags-property-mismatch.ts
533
+ const deno$16 = createMismatchRuleDeno(properties.featuredTags);
534
+ const eslint$3 = createMismatchRuleEslint(properties.featuredTags);
535
+
536
+ //#endregion
537
+ //#region src/rules/actor-featured-tags-property-required.ts
538
+ const deno$15 = createRequiredRuleDeno(properties.featuredTags);
539
+ const eslint$4 = createRequiredRuleEslint(properties.featuredTags);
540
+
541
+ //#endregion
542
+ //#region src/rules/actor-followers-property-mismatch.ts
543
+ const deno$14 = createMismatchRuleDeno(properties.followers);
544
+ const eslint$5 = createMismatchRuleEslint(properties.followers);
545
+
546
+ //#endregion
547
+ //#region src/rules/actor-followers-property-required.ts
548
+ const deno$13 = createRequiredRuleDeno(properties.followers);
549
+ const eslint$6 = createRequiredRuleEslint(properties.followers);
550
+
551
+ //#endregion
552
+ //#region src/rules/actor-following-property-mismatch.ts
553
+ const deno$12 = createMismatchRuleDeno(properties.following);
554
+ const eslint$7 = createMismatchRuleEslint(properties.following);
555
+
556
+ //#endregion
557
+ //#region src/rules/actor-following-property-required.ts
558
+ const deno$11 = createRequiredRuleDeno(properties.following);
559
+ const eslint$8 = createRequiredRuleEslint(properties.following);
560
+
561
+ //#endregion
562
+ //#region src/rules/actor-id-mismatch.ts
563
+ const deno$10 = createMismatchRuleDeno(properties.id);
564
+ const eslint$9 = createMismatchRuleEslint(properties.id);
565
+
566
+ //#endregion
567
+ //#region src/rules/actor-id-required.ts
568
+ const deno$9 = createRequiredRuleDeno(properties.id);
569
+ const eslint$10 = createRequiredRuleEslint(properties.id);
570
+
571
+ //#endregion
572
+ //#region src/rules/actor-inbox-property-mismatch.ts
573
+ const deno$8 = createMismatchRuleDeno(properties.inbox);
574
+ const eslint$11 = createMismatchRuleEslint(properties.inbox);
575
+
576
+ //#endregion
577
+ //#region src/rules/actor-inbox-property-required.ts
578
+ const deno$7 = createRequiredRuleDeno(properties.inbox);
579
+ const eslint$12 = createRequiredRuleEslint(properties.inbox);
580
+
581
+ //#endregion
582
+ //#region src/rules/actor-liked-property-mismatch.ts
583
+ const deno$6 = createMismatchRuleDeno(properties.liked);
584
+ const eslint$13 = createMismatchRuleEslint(properties.liked);
585
+
586
+ //#endregion
587
+ //#region src/rules/actor-liked-property-required.ts
588
+ const deno$5 = createRequiredRuleDeno(properties.liked);
589
+ const eslint$14 = createRequiredRuleEslint(properties.liked);
590
+
591
+ //#endregion
592
+ //#region src/rules/actor-outbox-property-mismatch.ts
593
+ const deno$4 = createMismatchRuleDeno(properties.outbox);
594
+ const eslint$15 = createMismatchRuleEslint(properties.outbox);
595
+
596
+ //#endregion
597
+ //#region src/rules/actor-outbox-property-required.ts
598
+ const deno$3 = createRequiredRuleDeno(properties.outbox);
599
+ const eslint$16 = createRequiredRuleEslint(properties.outbox);
600
+
601
+ //#endregion
602
+ //#region src/rules/actor-public-key-required.ts
603
+ const deno$2 = createRequiredRuleDeno(properties.publicKey);
604
+ const eslint$17 = createRequiredRuleEslint(properties.publicKey);
605
+
606
+ //#endregion
607
+ //#region src/rules/actor-shared-inbox-property-mismatch.ts
608
+ const deno$1 = createMismatchRuleDeno(properties.sharedInbox);
609
+ const eslint$18 = createMismatchRuleEslint(properties.sharedInbox);
610
+
611
+ //#endregion
612
+ //#region src/rules/actor-shared-inbox-property-required.ts
613
+ const deno = createRequiredRuleDeno(properties.sharedInbox);
614
+ const eslint$19 = createRequiredRuleEslint(properties.sharedInbox);
615
+
616
+ //#endregion
617
+ //#region src/rules/collection-filtering-not-implemented.ts
618
+ /**
619
+ * The followers dispatcher method that supports filtering.
620
+ * Only setFollowersDispatcher uses the filter parameter for
621
+ * followers collection synchronization.
622
+ * See: https://fedify.dev/manual/collections#filtering-by-server
623
+ */
624
+ const FILTER_NEEDED = ["setFollowersDispatcher"];
625
+ /**
626
+ * Checks if a node is a setFollowersDispatcher call.
627
+ */
628
+ const isFollowersDispatcherCall = (node) => "callee" in node && node.callee && node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && FILTER_NEEDED.includes(node.callee.property.name);
629
+ /**
630
+ * Checks if a function node has the filter parameter (4th parameter).
631
+ * CollectionDispatcher signature: (context, identifier, cursor, filter?) => ...
632
+ */
633
+ const hasFilterParameter = hasMinParams(4);
634
+ const eslint$20 = {
635
+ meta: {
636
+ type: "suggestion",
637
+ docs: { description: "Ensure followers dispatcher implements filtering" },
638
+ schema: [],
639
+ messages: { filterRequired: COLLECTION_FILTERING_NOT_IMPLEMENTED_ERROR }
640
+ },
641
+ create(context) {
642
+ const federationTracker = trackFederationVariables();
643
+ return {
644
+ VariableDeclarator: federationTracker.VariableDeclarator,
645
+ CallExpression(node) {
646
+ if (!isFollowersDispatcherCall(node)) return;
647
+ if (!federationTracker.isFederationObject(node.callee.object)) return;
648
+ const dispatcherArg = node.arguments[1];
649
+ if (!isFunction(dispatcherArg)) return;
650
+ if (!hasFilterParameter(dispatcherArg)) context.report({
651
+ node: dispatcherArg,
652
+ messageId: "filterRequired"
653
+ });
654
+ }
655
+ };
656
+ }
657
+ };
658
+
659
+ //#endregion
660
+ //#region src/index.ts
661
+ const rules = {
662
+ [RULE_IDS.actorIdMismatch]: eslint$9,
663
+ [RULE_IDS.actorIdRequired]: eslint$10,
664
+ [RULE_IDS.actorFollowingPropertyRequired]: eslint$8,
665
+ [RULE_IDS.actorFollowingPropertyMismatch]: eslint$7,
666
+ [RULE_IDS.actorFollowersPropertyRequired]: eslint$6,
667
+ [RULE_IDS.actorFollowersPropertyMismatch]: eslint$5,
668
+ [RULE_IDS.actorOutboxPropertyRequired]: eslint$16,
669
+ [RULE_IDS.actorOutboxPropertyMismatch]: eslint$15,
670
+ [RULE_IDS.actorLikedPropertyRequired]: eslint$14,
671
+ [RULE_IDS.actorLikedPropertyMismatch]: eslint$13,
672
+ [RULE_IDS.actorFeaturedPropertyRequired]: eslint$2,
673
+ [RULE_IDS.actorFeaturedPropertyMismatch]: eslint$1,
674
+ [RULE_IDS.actorFeaturedTagsPropertyRequired]: eslint$4,
675
+ [RULE_IDS.actorFeaturedTagsPropertyMismatch]: eslint$3,
676
+ [RULE_IDS.actorInboxPropertyRequired]: eslint$12,
677
+ [RULE_IDS.actorInboxPropertyMismatch]: eslint$11,
678
+ [RULE_IDS.actorSharedInboxPropertyRequired]: eslint$19,
679
+ [RULE_IDS.actorSharedInboxPropertyMismatch]: eslint$18,
680
+ [RULE_IDS.actorPublicKeyRequired]: eslint$17,
681
+ [RULE_IDS.actorAssertionMethodRequired]: eslint,
682
+ [RULE_IDS.collectionFilteringNotImplemented]: eslint$20
683
+ };
684
+ const recommendedRuleIds = [RULE_IDS.actorIdMismatch, RULE_IDS.actorIdRequired];
685
+ /**
686
+ * Recommended configuration - enables all rules as warnings
687
+ */
688
+ const recommendedRules = pipe(rules, keys, map((key) => [`@fedify/lint/${key}`, recommendedRuleIds.includes(key) ? "error" : "warn"]), fromEntries);
689
+ /**
690
+ * Strict configuration - enables all rules as errors
691
+ */
692
+ const strictRules = pipe(rules, keys, map((key) => [`${deno_default.name}/${key}`, "error"]), fromEntries);
693
+ const plugin = {
694
+ meta: {
695
+ name: deno_default.name,
696
+ version: deno_default.version
697
+ },
698
+ rules,
699
+ configs: {
700
+ recommended: {
701
+ plugins: [deno_default.name],
702
+ rules: recommendedRules
703
+ },
704
+ strict: {
705
+ plugins: [deno_default.name],
706
+ rules: strictRules
707
+ }
708
+ }
709
+ };
710
+ const recommendedConfig = {
711
+ files: ["federation", "federation/*"].map((filename) => [
712
+ filename + ".ts",
713
+ filename + ".tsx",
714
+ filename + ".js",
715
+ filename + ".jsx",
716
+ filename + ".mjs",
717
+ filename + ".cjs"
718
+ ]).flat(),
719
+ languageOptions: { parser },
720
+ plugins: { [deno_default.name]: plugin },
721
+ rules: recommendedRules
722
+ };
723
+ var src_default = recommendedConfig;
724
+
725
+ //#endregion
726
+ export { src_default as default, plugin };