@email-lint/react-email

中文文档
0.3.0发布于 2026/09/10MITTypeScriptESM + CJS近 30 天下载 1.5万

Lint 反应-电子邮件组件,用于使用电子邮件-lint实现客户端兼容性.

中文使用文档
文档目录5 节
  1. 安装
  2. API 密码
  3. lintComponent(element, config?)
  4. 用于测试
  5. 许可证

@ email-lint/ react- 电子邮件

林特 反应电子邮件 用于客户兼容的组件。 将您的组件渲染到 HTML 并对照 邮件 使用数据 @ email-lint/ core (韩语)。 。 。 .

import { lintComponent } from '@email-lint/react-email';
import { Welcome } from './emails/welcome';

const result = await lintComponent(<Welcome name="Jane" />);

console.log(result.success);      // true
console.log(result.errorCount);   // 0
console.log(result.diagnostics);  // LintDiagnostic[]

安装

npm install @email-lint/react-email

同伴依赖性 : react 财务报告和审定财务报表 @react-email/render。 。 。 .

API 密码

lintComponent(element, config?)

通过 HTML 将反应元素渲染到 HTML @react-email/render,然后将其涂入 email-lint。 。 。 .

默认情况下启用了框架感知过滤 —— React Email 内部导致的诊断(审查文本块,预装图像标记,强制) target="_blank")自动被压制. 过 framework: undefined 选择退出.

// Lint against specific clients
const result = await lintComponent(<Welcome />, { preset: 'gmail' });

// Disable framework filtering
const result = await lintComponent(<Welcome />, { framework: undefined });

// Keep suppressed diagnostics visible
const result = await lintComponent(<Welcome />, { showIgnored: true });

返回同样的 LintResult 类型为 @email-lint/core 看到了吗 @ email-lint/ 核心文档 用于完整类型参考.

用于测试

import { describe, it, expect } from 'vitest';
import { lintComponent } from '@email-lint/react-email';
import { Welcome } from './emails/welcome';

describe('email compatibility', () => {
  it('Welcome has no errors', async () => {
    const result = await lintComponent(<Welcome name="Jane" />);
    expect(result.errorCount).toBe(0);
  });

  it('Welcome passes Gmail checks', async () => {
    const result = await lintComponent(<Welcome name="Jane" />, { preset: 'gmail' });
    expect(result.success).toBe(true);
  });
});

许可证

麻省理工学院

版本与发布记录

@email-lint/react-email 共发布 3 个版本,首次发布于 2026/04/14;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.3.0latest2026/09/102 个月前
0.2.12026/04/146 个月前
0.2.02026/04/146 个月前

关于 @email-lint/react-email 的常见问题

@email-lint/react-email 是什么?

Lint 反应-电子邮件组件,用于使用电子邮件-lint实现客户端兼容性.

如何安装 @email-lint/react-email?

在项目目录运行 npm install @email-lint/react-email,或使用 pnpm add / yarn add / bun add。

@email-lint/react-email 支持 TypeScript 吗?

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

@email-lint/react-email 支持 ESM 还是 CommonJS?

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

@email-lint/react-email 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@email-lint/react-email 可以商用吗?

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

@email-lint/react-email 的下载量有多少?

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

@email-lint/react-email 还在维护吗?

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