@mscode-pl/email-lint 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +274 -3
- package/data/LICENSE-caniemail +21 -0
- package/data/caniemail.json +1 -0
- package/dist/cli/colors.d.ts +13 -0
- package/dist/cli/colors.js +23 -0
- package/dist/cli/config.d.ts +11 -0
- package/dist/cli/config.js +56 -0
- package/dist/cli/files.d.ts +7 -0
- package/dist/cli/files.js +44 -0
- package/dist/cli/format.d.ts +23 -0
- package/dist/cli/format.js +204 -0
- package/dist/cli/interactive.d.ts +1 -0
- package/dist/cli/interactive.js +154 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +142 -0
- package/dist/core/baseline.d.ts +1 -0
- package/dist/core/baseline.js +24 -0
- package/dist/core/clients.d.ts +22 -0
- package/dist/core/clients.js +65 -0
- package/dist/core/data.d.ts +20 -0
- package/dist/core/data.js +6 -0
- package/dist/core/lint.d.ts +27 -0
- package/dist/core/lint.js +217 -0
- package/dist/core/rules.d.ts +23 -0
- package/dist/core/rules.js +164 -0
- package/dist/core/selectors.d.ts +15 -0
- package/dist/core/selectors.js +47 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +6 -0
- package/dist/mcp/fixes.d.ts +16 -0
- package/dist/mcp/fixes.js +48 -0
- package/dist/mcp/server.d.ts +19 -0
- package/dist/mcp/server.js +118 -0
- package/dist/mcp/tools.d.ts +83 -0
- package/dist/mcp/tools.js +161 -0
- package/package.json +70 -6
- package/skills/email-lint/SKILL.md +68 -0
- package/skills/email-lint/references/fixes.md +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MSCode
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,274 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset=".github/banner-dark.svg">
|
|
4
|
+
<img src=".github/banner-light.svg" alt="email-lint: find what Outlook will break before you hit send" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://www.npmjs.com/package/@mscode-pl/email-lint"><img src="https://badges.mscode.pl/npm/v/@mscode-pl/email-lint" alt="npm version"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@mscode-pl/email-lint"><img src="https://badges.mscode.pl/npm/dm/@mscode-pl/email-lint" alt="npm downloads"></a>
|
|
11
|
+
<a href="https://github.com/mscode-pl/email-lint/actions/workflows/ci.yml"><img src="https://badges.mscode.pl/github/actions/mscode-pl/email-lint/ci.yml?branch=master&label=tests" alt="Tests"></a>
|
|
12
|
+
<img src="https://badges.mscode.pl/badge/node/22+/339933?icon=nodejs" alt="Node 22+">
|
|
13
|
+
<a href="LICENSE"><img src="https://badges.mscode.pl/npm/l/@mscode-pl/email-lint" alt="License"></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
email-lint reads your email HTML and points at every CSS property, selector, HTML element and image format that Gmail, Outlook, Apple Mail, Yahoo and 18 other clients do not support, with the line it is on. The support data comes from <a href="https://www.caniemail.com">caniemail.com</a> and ships with the package, so it runs offline and in CI.
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="#try-it">Try it</a> · <a href="#works-with-your-stack">Stacks</a> · <a href="#use-it-in-ci">CI</a> · <a href="#options">Options</a> · <a href="#use-it-from-code">API</a> · <a href="#use-it-from-an-ai-agent">AI agents</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<p align="center">
|
|
25
|
+
<img src="docs/screenshot.svg" alt="email-lint output: display:flex, gap and border-radius flagged as unsupported in Outlook for Windows, each with its line number" width="920">
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
## Try it
|
|
29
|
+
|
|
30
|
+
Run it with no arguments and it walks you through the check: it finds the HTML in your project, asks which clients matter, shows the results and can save a report.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx @mscode-pl/email-lint
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or check a folder in one command:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx @mscode-pl/email-lint emails/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
It needs Node 22 or newer, no account and no API key, and it sends nothing over the network.
|
|
43
|
+
|
|
44
|
+
## Why
|
|
45
|
+
|
|
46
|
+
Email clients render a small and uneven slice of CSS. Outlook for Windows still uses Word to draw HTML, so `display: flex`, `border-radius` and `max-width` on a `<div>` quietly do nothing there. Gmail drops your `<style>` block for some accounts. The usual way to find out is a customer screenshot, or a paid rendering service on every change.
|
|
47
|
+
|
|
48
|
+
caniemail.com already tracks which client supports what. email-lint applies that table to your actual templates, so the answer is a list of lines to fix instead of 308 feature pages to read.
|
|
49
|
+
|
|
50
|
+
## What you get
|
|
51
|
+
|
|
52
|
+
| Feature | Details |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| **Line numbers for every problem** | In inline styles, `<style>` blocks and attributes alike. |
|
|
55
|
+
| **306 of 308 caniemail features** | CSS properties and values, selectors and pseudo-classes, at-rules and media features, units and functions, HTML elements and attributes, image formats. BIMI and HDR images cannot be seen in HTML. |
|
|
56
|
+
| **Errors that mean something** | An error is a feature at least one of your clients does not support at all. A warning is partial support, and `--verbose` prints caniemail's note on what is missing. |
|
|
57
|
+
| **Outlook conditionals understood** | Content inside `<!--[if !mso]><!-->` is hidden from Outlook for Windows, so it is not blamed for it. That is the hybrid layout most email frameworks generate. |
|
|
58
|
+
| **Low noise by default** | `<body>`, `<style>`, tables, class selectors, `role` and `aria-*` are not reported, because the only fix would be removing them. `--strict` shows everything. |
|
|
59
|
+
| **Reports you can share** | Markdown for a pull request, JSON for scripts, GitHub annotations on the pull request. |
|
|
60
|
+
| **GitHub Action and MCP server** | One pull request comment that updates itself, and two tools your AI agent can call while it writes the email. |
|
|
61
|
+
|
|
62
|
+
## Works with your stack
|
|
63
|
+
|
|
64
|
+
email-lint checks rendered HTML, so it works with any tool that produces it:
|
|
65
|
+
|
|
66
|
+
| Stack | Command |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| Plain HTML | `npx @mscode-pl/email-lint emails/` |
|
|
69
|
+
| React Email | `npx email export --outDir out && npx @mscode-pl/email-lint out/` |
|
|
70
|
+
| MJML | `npx mjml "emails/*.mjml" -o out/ && npx @mscode-pl/email-lint out/` |
|
|
71
|
+
| Maizzle | `npx maizzle build production`, then lint the output folder |
|
|
72
|
+
| [laravel-react-email](https://github.com/mscode-pl/laravel-react-email) | `php artisan react-email:build && npx @mscode-pl/email-lint "resources/views/react-email/**/*.blade.php"` |
|
|
73
|
+
|
|
74
|
+
Blade syntax such as `{{ $name }}` and `@if` is read as text and does not trigger false reports.
|
|
75
|
+
|
|
76
|
+
## Pick your clients
|
|
77
|
+
|
|
78
|
+
The default set is Gmail, Outlook, Apple Mail, Yahoo, Samsung Email and Thunderbird. Narrow it down to what your audience uses:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
email-lint emails/ --clients gmail,apple-mail # consumer newsletter
|
|
82
|
+
email-lint emails/ --clients outlook.windows # one platform of one client
|
|
83
|
+
email-lint emails/ --clients all # every client caniemail tests
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
A typo fails with the list of valid names instead of silently checking nothing.
|
|
87
|
+
|
|
88
|
+
<details>
|
|
89
|
+
<summary>All 22 clients</summary>
|
|
90
|
+
|
|
91
|
+
`gmail`, `outlook`, `apple-mail`, `yahoo`, `samsung-email`, `thunderbird`, `protonmail`, `fastmail`, `hey`, `aol`, `wp-pl`, `gmx`, `web-de`, `t-online-de`, `orange`, `sfr`, `free-fr`, `laposte`, `mail-ru`, `ionos-1and1`, `rainloop`, `microsoft`
|
|
92
|
+
|
|
93
|
+
</details>
|
|
94
|
+
|
|
95
|
+
## Use it in CI
|
|
96
|
+
|
|
97
|
+
Commit a config file so everyone on the team runs the same check:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"files": ["emails/**/*.html"],
|
|
102
|
+
"clients": ["gmail", "outlook", "apple-mail"],
|
|
103
|
+
"ignore": ["css-border-radius"],
|
|
104
|
+
"failOn": "error"
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Save it as `email-lint.config.json`, and `email-lint` with no arguments uses it. The interactive mode can write it for you.
|
|
109
|
+
|
|
110
|
+
### GitHub Action
|
|
111
|
+
|
|
112
|
+
The action marks every finding on the line it is on in the pull request diff, and posts the full report as one comment that it updates on every push instead of adding a new one. When the issues are fixed, the comment says so.
|
|
113
|
+
|
|
114
|
+
```yaml
|
|
115
|
+
name: Emails
|
|
116
|
+
|
|
117
|
+
on: pull_request
|
|
118
|
+
|
|
119
|
+
permissions:
|
|
120
|
+
contents: read
|
|
121
|
+
pull-requests: write
|
|
122
|
+
|
|
123
|
+
jobs:
|
|
124
|
+
email-lint:
|
|
125
|
+
runs-on: ubuntu-latest
|
|
126
|
+
steps:
|
|
127
|
+
- uses: actions/checkout@v4
|
|
128
|
+
# Build your templates first, e.g. npx email export --outDir out
|
|
129
|
+
- uses: mscode-pl/email-lint@v1
|
|
130
|
+
with:
|
|
131
|
+
files: out
|
|
132
|
+
clients: gmail,outlook,apple-mail
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
| Input | Default | |
|
|
136
|
+
| --- | --- | --- |
|
|
137
|
+
| `files` | `files` from the config | Files, folders or globs, separated by spaces or new lines |
|
|
138
|
+
| `clients` | config, then the defaults | Comma separated, e.g. `gmail,outlook.windows` |
|
|
139
|
+
| `ignore` | | Feature slugs to skip, comma separated |
|
|
140
|
+
| `strict` | `false` | Also report baseline features |
|
|
141
|
+
| `fail-on` | config, then `error` | `error`, `warning` or `never` |
|
|
142
|
+
| `config` | `email-lint.config.json` | Config file to read |
|
|
143
|
+
| `comment` | `true` | Post the report as a pull request comment |
|
|
144
|
+
| `github-token` | `github.token` | Token for the comment |
|
|
145
|
+
| `version` | the action's release | email-lint version from npm |
|
|
146
|
+
|
|
147
|
+
Outputs: `report` (path to the Markdown report, also shown in the job summary) and `exit-code`. The step needs Node 22; on an older runner the action installs it. Pull requests from forks get a read-only token, so they get the annotations and the job summary but no comment. GitHub shows at most 10 annotations of each level per step, and the comment lists the rest.
|
|
148
|
+
|
|
149
|
+
### Any other CI
|
|
150
|
+
|
|
151
|
+
`--format github` prints GitHub annotations, `-o report.md` saves a Markdown report:
|
|
152
|
+
|
|
153
|
+
```yaml
|
|
154
|
+
- run: npx @mscode-pl/email-lint --format github -o email-report.md
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The exit code is `1` when there are errors (or warnings with `--fail-on warning`), `0` otherwise, and `2` for bad arguments or no matching files.
|
|
158
|
+
|
|
159
|
+
## Options
|
|
160
|
+
|
|
161
|
+
| Option | Default | |
|
|
162
|
+
| --- | --- | --- |
|
|
163
|
+
| `-c, --clients <list>` | see above | Clients to check |
|
|
164
|
+
| `-i, --ignore <list>` | | Feature slugs to skip, e.g. `css-display-flex` |
|
|
165
|
+
| `--strict` | off | Also report baseline features and Gmail in a mobile browser |
|
|
166
|
+
| `-f, --format <type>` | `text` | `text`, `json`, `markdown` or `github` |
|
|
167
|
+
| `-o, --output <file>` | | Also save a full report; `.json` and `.md` pick the format |
|
|
168
|
+
| `--verbose` / `-q, --quiet` | off | caniemail notes and links / errors only |
|
|
169
|
+
| `--fail-on <level>` | `error` | `error`, `warning` or `never` |
|
|
170
|
+
| `--config <file>` | `email-lint.config.json` | Config file to read |
|
|
171
|
+
| `--stdin` | | Read HTML from stdin |
|
|
172
|
+
|
|
173
|
+
## Use it from code
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
import { lint } from '@mscode-pl/email-lint';
|
|
177
|
+
|
|
178
|
+
const { issues, errors } = lint(html, { clients: ['gmail', 'outlook'] });
|
|
179
|
+
|
|
180
|
+
for (const issue of issues) {
|
|
181
|
+
console.log(issue.lines, issue.level, issue.title, issue.clients);
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`lint` is synchronous and does no I/O beyond reading the bundled dataset once. Every issue carries the caniemail slug, its URL, the affected lines and, per client and platform, the support status and notes.
|
|
186
|
+
|
|
187
|
+
## Use it from an AI agent
|
|
188
|
+
|
|
189
|
+
### MCP server
|
|
190
|
+
|
|
191
|
+
`email-lint mcp` starts an [MCP](https://modelcontextprotocol.io) server on stdio, so Claude, Cursor, VS Code and other MCP clients can check a template while they write it. It has two read-only tools:
|
|
192
|
+
|
|
193
|
+
| Tool | What it does |
|
|
194
|
+
| --- | --- |
|
|
195
|
+
| `lint_email` | Lints `html` passed inline or a `path` (file, folder or glob) and returns every issue with its line, the affected clients and caniemail's notes. With neither, it lints the files from `email-lint.config.json`. |
|
|
196
|
+
| `explain_feature` | For one slug, says which clients lack support, whether that breaks the email or only drops decoration, and how to fix it. |
|
|
197
|
+
|
|
198
|
+
Paths are relative to the folder the client starts the server in, usually your project, and `email-lint.config.json` there sets the default clients and ignored features.
|
|
199
|
+
|
|
200
|
+
Claude Code:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
claude mcp add email-lint -- npx -y @mscode-pl/email-lint mcp
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Cursor, VS Code, Claude Desktop and others take the same command in their MCP config:
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"mcpServers": {
|
|
211
|
+
"email-lint": {
|
|
212
|
+
"command": "npx",
|
|
213
|
+
"args": ["-y", "@mscode-pl/email-lint", "mcp"]
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
To lint a folder that is named `mcp`, write it as `./mcp`.
|
|
220
|
+
|
|
221
|
+
### Agent Skill
|
|
222
|
+
|
|
223
|
+
The repo ships an [Agent Skill](skills/email-lint/SKILL.md) for Claude Code, Codex, Cursor and other agents. It runs email-lint on your templates, sorts the findings into must-fix and acceptable degradation, and proposes fixes in your source files (a table instead of flexbox, VML for rounded Outlook buttons, PNG instead of WebP).
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npx skills add mscode-pl/email-lint
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## How support is judged
|
|
230
|
+
|
|
231
|
+
- Each client platform (Gmail on iOS, Outlook on Windows) is judged by the newest version caniemail tested.
|
|
232
|
+
- Gmail opened in a mobile browser is left out by default. It drops `<style>` entirely and would flag nearly every email; name it with `--clients gmail.mobile-webmail` to include it.
|
|
233
|
+
- email-lint reads markup, it does not render it. It tells you a feature is used where a client ignores it, not how the result looks. For pixel checks you still need a real client or a rendering service.
|
|
234
|
+
|
|
235
|
+
## Updating the data
|
|
236
|
+
|
|
237
|
+
The dataset in `data/caniemail.json` is a trimmed copy of caniemail's API, dated in `email-lint --version`. To refresh it:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
pnpm update-data
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Contributing
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
pnpm install
|
|
247
|
+
pnpm test
|
|
248
|
+
pnpm build && node dist/cli/main.js examples
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
`pnpm screenshot` regenerates `docs/screenshot.svg` from the real CLI output.
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
MIT. Support data from [caniemail](https://github.com/hteumeuleu/caniemail) by Rémi Parmentier, MIT License, see [data/LICENSE-caniemail](data/LICENSE-caniemail).
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
<p align="center">
|
|
260
|
+
<a href="https://mscode.pl">
|
|
261
|
+
<picture>
|
|
262
|
+
<source media="(prefers-color-scheme: dark)" srcset=".github/mscode-logo-white.svg">
|
|
263
|
+
<img src=".github/mscode-logo-black.svg" alt="MSCode" height="28">
|
|
264
|
+
</picture>
|
|
265
|
+
</a>
|
|
266
|
+
</p>
|
|
267
|
+
|
|
268
|
+
<p align="center">
|
|
269
|
+
Built and maintained by <a href="https://mscode.pl">MSCode</a>, a Polish software house that makes websites and web and mobile apps.
|
|
270
|
+
</p>
|
|
271
|
+
|
|
272
|
+
<p align="center">
|
|
273
|
+
<a href="https://mscode.pl">mscode.pl</a> · <a href="https://github.com/mscode-pl">More packages</a> · <a href="https://github.com/mscode-pl/email-lint/issues">Report an issue</a>
|
|
274
|
+
</p>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Rémi Parmentier
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|