@fedify/lint

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

合并林化规则和插件

中文使用文档
文档目录20 节
  1. Deno Lint 配置实例
  2. ESLint 配置示例
  3. 特征
  4. 演员验证规则
  5. 财产征收规则
  6. 其他规则
  7. 安装
  8. 用法 (德诺林特)
  9. 基本设置
  10. 自定义配置
  11. 运行 Deno 林特
  12. 用法( ESLint)
  13. 基本设置
  14. 自定义配置
  15. 使用配置
  16. 示例
  17. 运行电线
  18. 德诺·林特
  19. ESLint 语录
  20. 另见

@ fedify/lint: 联邦化的ESLint插件

JSR npm Follow @fedify@hollo.social

此包自Fedify 2.0.

此软件包提供 德诺·林特 财务报告和审定财务报表 ESLint 语录 带有插件规则的插件 专为 联邦 应用。 它能帮助你找到常见的 在构建联邦服务器应用程序时错误并强制执行最佳做法 联邦.

插件包括检查 :

  • 适当的演员身份配置
  • 所需的演员属性( 收件箱、 发件箱、 追随者等)
  • 正确的演员收藏的 URL 模式
  • 公用钥匙和断言方法要求
  • 收集过滤执行

Deno Lint 配置实例

// 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 配置示例

// eslint.config.ts

import fedifyLint from "@fedify/lint";

export default fedifyLint;

特征

这个 @fedify/lint 软件包为联邦提供了全面的折叠规则 联邦代码 :

演员验证规则

  • actor-id-required:确保所有行动者 id 属性
  • actor-id-mismatch: 验证演员ID与预期的 URI 匹配 从 Context.getActorUri()
  • actor-public-key-required:确保行为者拥有用于 HTTP 签名
  • actor-assertion-method-required: 验证 对象完整性证明

财产征收规则

  • actor-inbox-property-required: 当 setInboxListeners 设定
  • actor-inbox-property-mismatch: 验证信箱 URI from getInboxUri
  • actor-outbox-property-required:确保当 setOutboxDispatcher 设定
  • actor-outbox-property-mismatch: 校验发件箱 URI 从 getOutboxUri
  • actor-followers-property-required: 确保在 setFollowersDispatcher 设定
  • actor-followers-property-mismatch: 验证追随者的 URI from getFollowersUri
  • actor-following-property-required: 当 setFollowingDispatcher 设定
  • actor-following-property-mismatch: URI 从 getFollowingUri
  • actor-liked-property-required: 在 setLikedDispatcher 设定
  • actor-liked-property-mismatch: 校验器喜欢来自 getLikedUri
  • actor-featured-property-required: 当 setFeaturedDispatcher 设定
  • actor-featured-property-mismatch: 校验显示 URI 从 getFeaturedUri
  • actor-featured-tags-property-required: 确保显示 标记被定义 何时 setFeaturedTagsDispatcher 设定
  • actor-featured-tags-property-mismatch: 显示的验证符 标记 URI 从 getFeaturedTagsUri
  • actor-shared-inbox-property-required: 确保共享信箱被定义 何时 setInboxListeners 设定
  • actor-shared-inbox-property-mismatch: 验证共享的Inbox URI 来源 getInboxUri

其他规则

  • collection-filtering-not-implemented: 关于丢失收藏的警告 过滤执行setFollowersDispatcher 暂时的)

安装

* :密码组

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

* :

用法 (德诺林特)

基本设置

将插件添加到您的 德诺·杰森 配置文件 :

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

默认情况下,这可以实现所有推荐的规则.

自定义配置

您可以自定义要启用哪些规则及其严重程度:

{
  "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"
      ]
    }
  }
}

运行 Deno 林特

设置配置后, 运行 Deno 的 linter :

deno lint

您也可以指定要插入的文件 :

deno lint federation.ts
deno lint src/federation/

用法( ESLint)

基本设置

将插件添加到您的 ESLint 配置文件( 例如, ), 互联网档案馆的存檔,存档日期2013-12-02 或者说 互联网档案馆的存檔,存档日期2013-12-02:

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,
];

默认配置对匹配的文件应用推荐规则 与联邦有关的共同模式(例如:, 联邦, (中文(简体) ), 联合会/*.ts) (中文(简体) ).

自定义配置

您可以自定义哪些文件可以擦出, 哪些规则可以启用 :

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
  },
}];

使用配置

该插件提供了两个预设配置:

允许将关键规则作为错误, 可选规则作为警告 :

import fedifyLint from "@fedify/lint";

export default fedifyLint;

严格

启用所有规则为错误 :

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

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

示例

这里有一个代码的例子会引发错误:

// ❌ 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",
    });
  },
);

已更正版本 :

// ✅ 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
    });
  },
);

运行电线

德诺·林特

用插件运行 Deno 的插件 :

deno lint

您也可以指定要提示的文件或目录 :

deno lint federation.ts
deno lint src/federation/

ESLint 语录

如上所示设置您的 ESLint 配置, 并添加一个 follwing 脚本 package.json数字 :

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

设置配置后, 在您的代码库上运行 ESLint :

* :密码组

npm run lint
pnpm lint
yarn lint
bun lint

* :

或直接通过命令行运行 :

* :密码组

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

* :

另见

版本与发布记录

@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/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 和提交记录判断。