@email-lint/react-email

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

Lint react-email components for client compatibility using email-lint.

原始使用文档
文档目录5 节
  1. Install
  2. API
  3. lintComponent(element, config?)
  4. Use in tests
  5. License

@email-lint/react-email

Lint React Email components for client compatibility. Renders your component to HTML and validates it against caniemail data using @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[]

Install

npm install @email-lint/react-email

Peer dependencies: react and @react-email/render.

API

lintComponent(element, config?)

Renders a React element to HTML via @react-email/render, then lints it with email-lint.

Framework-aware filtering is enabled by default — diagnostics caused by React Email internals (preview text blocks, preload image tags, forced target="_blank") are automatically suppressed. Pass framework: undefined to opt out.

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

Returns the same LintResult type as @email-lint/core — see @email-lint/core docs for the full type reference.

Use in tests

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);
  });
});

License

MIT

版本与发布记录

@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 react-email components for client compatibility using email-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 和提交记录判断。