@fedify/lint

中文文档
2.1.32发布于 2026/11/17MITTypeScriptESM + CJS构建来源已验证近 30 天下载 1万

Fedify linting rules and plugins

原始使用文档
文档目录20 节
  1. Deno Lint configuration example
  2. ESLint configuration example
  3. Features
  4. Actor validation rules
  5. Collection property rules
  6. Other rules
  7. Installation
  8. Usage (Deno Lint)
  9. Basic setup
  10. Custom configuration
  11. Running Deno Lint
  12. Usage (ESLint)
  13. Basic setup
  14. Custom configuration
  15. Using configurations
  16. Example
  17. Running the linter
  18. Deno Lint
  19. ESLint
  20. See also

@fedify/lint: ESLint plugin for Fedify

JSR npm Follow @fedify@hollo.social

This package is available since Fedify 2.0.0.

This package provides Deno Lint and ESLint plugin with lint rules specifically designed for Fedify applications. It helps you catch common mistakes and enforce best practices when building federated server apps with Fedify.

The plugin includes rules that check for:

  • Proper actor ID configuration
  • Required actor properties (inbox, outbox, followers, etc.)
  • Correct URL patterns for actor collections
  • Public key and assertion method requirements
  • Collection filtering implementation

Deno Lint configuration example

// deno.json

{
  "lint": {
    "plugins": {
      "@fedify/lint": "jsr:@fedify/lint"
    },
    "rules": {
      "@fedify/lint/actor-id-required": "error",
      "@fedify/lint/actor-id-mismatch": "error",
      "@fedify/lint/actor-inbox-property-required": "warn"
      // ... other rules
    }
  }
}

ESLint configuration example

// eslint.config.ts

import fedifyLint from "@fedify/lint";

export default fedifyLint;

Features

The @fedify/lint package provides comprehensive linting rules for Fedify federation code:

Actor validation rules

  • actor-id-required: Ensures all actors have an id property
  • actor-id-mismatch: Validates that actor IDs match the expected URI from Context.getActorUri()
  • actor-public-key-required: Ensures actors have public keys for HTTP Signatures
  • actor-assertion-method-required: Validates assertion methods for Object Integrity Proofs

Collection property rules

  • actor-inbox-property-required: Ensures inbox is defined when setInboxListeners is set
  • actor-inbox-property-mismatch: Validates inbox URI from getInboxUri
  • actor-outbox-property-required: Ensures outbox is defined when setOutboxDispatcher is set
  • actor-outbox-property-mismatch: Validates outbox URI from getOutboxUri
  • actor-followers-property-required: Ensures followers is defined when setFollowersDispatcher is set
  • actor-followers-property-mismatch: Validates followers URI from getFollowersUri
  • actor-following-property-required: Ensures following is defined when setFollowingDispatcher is set
  • actor-following-property-mismatch: Validates following URI from getFollowingUri
  • actor-liked-property-required: Ensures liked is defined when setLikedDispatcher is set
  • actor-liked-property-mismatch: Validates liked URI from getLikedUri
  • actor-featured-property-required: Ensures featured is defined when setFeaturedDispatcher is set
  • actor-featured-property-mismatch: Validates featured URI from getFeaturedUri
  • actor-featured-tags-property-required: Ensures featuredTags is defined when setFeaturedTagsDispatcher is set
  • actor-featured-tags-property-mismatch: Validates featuredTags URI from getFeaturedTagsUri
  • actor-shared-inbox-property-required: Ensures sharedInbox is defined when setInboxListeners is set
  • actor-shared-inbox-property-mismatch: Validates sharedInbox URI from getInboxUri

Other rules

  • collection-filtering-not-implemented: Warns about missing collection filtering implementation (setFollowersDispatcher only for now)

Installation

::: code-group

deno add jsr:@fedify/lint
npm add -D @fedify/lint
pnpm add -D @fedify/lint
yarn add -D @fedify/lint
bun add -D @fedify/lint

:::

Usage (Deno Lint)

Basic setup

Add the plugin to your deno.json configuration file:

{
  "lint": {
    "plugins": ["jsr:@fedify/lint"]
  }
}

By default, this enables all recommended rules.

Custom configuration

You can customize which rules to enable and their severity levels:

{
  "lint": {
    "plugins": ["jsr:@fedify/lint"],
    "rules": {
      "tags": ["recommended"],
      "include": [
        "@fedify/lint/actor-id-required",
        "@fedify/lint/actor-id-mismatch"
      ],
      "exclude": [
        "@fedify/lint/actor-featured-property-required"
      ]
    }
  }
}

Running Deno Lint

After setting up the configuration, run Deno's linter:

deno lint

You can also specify which files to lint:

deno lint federation.ts
deno lint src/federation/

Usage (ESLint)

Basic setup

Add the plugin to your ESLint configuration file (e.g., eslint.config.ts or eslint.config.js):

import fedifyLint from "@fedify/lint";

// If your `createFederation` code is in `federation.ts` or `federation/**.ts`
export default fedifyLint; 

// Or specify your own federation files
export default {
  ...fedifyLint,
  files: ["my-own-federation.ts"],
};

// If you use other ESLint configurations

export default [
  otherConfig,
  fedifyLint,
];

The default configuration applies recommended rules to files that match common federation-related patterns (e.g., federation.ts, federation/*.ts).

Custom configuration

You can customize which files to lint and which rules to enable:

import { plugin } from "@fedify/lint";

export default [{
  files: ["src/federation/**/*.ts"],  // Your federation code location
  plugins: {
    "@fedify/lint": plugin,
  },
  rules: {
    "@fedify/lint/actor-id-required": "error",
    "@fedify/lint/actor-id-mismatch": "error",
    "@fedify/lint/actor-inbox-property-required": "warn",
    // ... other rules
  },
}];

Using configurations

The plugin provides two preset configurations:

Enables critical rules as errors and optional rules as warnings:

import fedifyLint from "@fedify/lint";

export default fedifyLint;

Strict

Enables all rules as errors:

import { plugin } from "@fedify/lint";

export default [{
  files: ["**/*.ts"],
  ...plugin.configs.strict,
}];

Example

Here's an example of code that would trigger lint errors:

// ❌ Wrong: Using relative URL for actor ID
import { createFederation, Person } from "@fedify/fedify";

const federation = createFederation({ /* ... */ });

federation.setActorDispatcher(
  "/{identifier}",
  (_ctx, identifier) => {
    return new Person({
      id: new URL(`/${identifier}`),  // ❌ Should use ctx.getActorUri()
      name: "Example User",
    });
  },
);

Corrected version:

// ✅ Correct: Using Context.getActorUri() for actor ID
import { createFederation, Person } from "@fedify/fedify";

const federation = createFederation({ /* ... */ });

federation.setActorDispatcher(
  "/{identifier}",
  (ctx, identifier) => {
    return new Person({
      id: ctx.getActorUri(identifier),  // ✅ Correct
      name: "Example User",
      inbox: ctx.getInboxUri(identifier),
      outbox: ctx.getOutboxUri(identifier),
      followers: ctx.getFollowersUri(identifier),
      // ... other required properties
    });
  },
);

Running the linter

Deno Lint

Run Deno's linter with the plugin enabled:

deno lint

You can also specify which files or directories to lint:

deno lint federation.ts
deno lint src/federation/

ESLint

Set up your ESLint configuration as shown above and add a follwing script on package.json:

{
  "scripts": {
    "lint": "eslint ."
  }
}

After setting up the configuration, run ESLint on your codebase:

::: code-group

npm run lint
pnpm lint
yarn lint
bun lint

:::

or run the linter directly via command line:

::: code-group

npx eslint .
pnpx eslint .
yarn eslint .
bunx eslint .

:::

See also

版本与发布记录

@fedify/lint 共发布 571 个版本,首次发布于 2025/12/31;过去 12 个月发布了 571 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.32latest2026/11/17今天
2.0.362026/11/17今天
2.3.16-dev.28452026/11/17今天
2.5.0-dev.28442026/11/17今天
2.0.36-dev.28432026/11/17今天
2.3.16-dev.28412026/11/17今天

其他发布通道:pr-559 → 2.0.0-pr.559.6,pr-633 → 2.0.6-pr.633.9,pr-639 → 2.0.7-pr.639.14,pr-697 → 2.2.0-pr.697.18,pr-708 → 2.2.0-pr.708.19,pr-709 → 2.2.0-pr.709.20。

关于 @fedify/lint 的常见问题

@fedify/lint 是什么?

Fedify linting rules and plugins

如何安装 @fedify/lint?

在项目目录运行 npm install @fedify/lint,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@fedify/fedify(^2.1.32)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fedify/lint 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fedify/lint 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fedify/lint 可以商用吗?

@fedify/lint 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fedify/lint 的下载量有多少?

根据 npm 官方下载统计,@fedify/lint 在 2026/10/15 – 2026/11/13 这 30 天内被下载 10,058 次,日均约 335 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fedify/lint 还在维护吗?

最新版本 2.1.32 发布于 2026/11/17(今天);至今共发布 571 个版本,其中过去 12 个月发布了 571 个;首次发布于 2025/12/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。