@emailens/cli 0.11.0 → 0.13.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.
@@ -0,0 +1,645 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/project-config.ts
4
+ import { existsSync, readFileSync } from "fs";
5
+ import { dirname, join, parse } from "path";
6
+ var SEVERITIES = ["error", "warning", "info", "off"];
7
+ function parseRules(value) {
8
+ const rules = {};
9
+ const invalid = [];
10
+ if (!value || typeof value !== "object" || Array.isArray(value)) return { rules, invalid };
11
+ for (const [rule, severity] of Object.entries(value)) {
12
+ if (typeof severity === "string" && SEVERITIES.includes(severity)) {
13
+ rules[rule] = severity;
14
+ } else {
15
+ invalid.push(`${rule}: ${JSON.stringify(severity)}`);
16
+ }
17
+ }
18
+ return { rules, invalid };
19
+ }
20
+ function parseProjectConfig(source, from) {
21
+ let parsed;
22
+ try {
23
+ parsed = JSON.parse(source);
24
+ } catch {
25
+ return void 0;
26
+ }
27
+ if (!parsed || typeof parsed !== "object") return void 0;
28
+ const body = from === "package.json" ? parsed.emailens : parsed;
29
+ if (!body || typeof body !== "object") return void 0;
30
+ const config = { invalid: [] };
31
+ const skip = body.skip;
32
+ if (Array.isArray(skip) && skip.every((s) => typeof s === "string")) config.skip = skip;
33
+ const { rules, invalid } = parseRules(body.rules);
34
+ if (Object.keys(rules).length) config.rules = rules;
35
+ config.invalid = invalid;
36
+ return config.skip || config.rules || invalid.length ? config : void 0;
37
+ }
38
+ function loadProjectConfig(from = process.cwd()) {
39
+ const root = parse(from).root;
40
+ for (let dir = from; ; dir = dirname(dir)) {
41
+ for (const [name, kind] of [
42
+ [".emailensrc", "emailensrc"],
43
+ ["package.json", "package.json"]
44
+ ]) {
45
+ const path = join(dir, name);
46
+ if (!existsSync(path)) continue;
47
+ let body;
48
+ try {
49
+ body = readFileSync(path, "utf-8");
50
+ } catch {
51
+ continue;
52
+ }
53
+ const config = parseProjectConfig(body, kind);
54
+ if (config) return { ...config, source: path };
55
+ }
56
+ if (dir === root) return void 0;
57
+ }
58
+ }
59
+ function applySeverities(issues, rules) {
60
+ if (!rules || !Object.keys(rules).length) return issues;
61
+ const out = [];
62
+ for (const issue of issues) {
63
+ const severity = rules[issue.rule];
64
+ if (severity === "off") continue;
65
+ out.push(severity ? { ...issue, severity } : issue);
66
+ }
67
+ return out;
68
+ }
69
+
70
+ // src/commands/lint.ts
71
+ import { defineCommand } from "citty";
72
+ import pc from "picocolors";
73
+
74
+ // src/utils.ts
75
+ import { readFileSync as readFileSync2 } from "fs";
76
+ import { EMAIL_CLIENTS } from "@emailens/engine";
77
+ import { detectFormat } from "@emailens/engine/compile";
78
+ var VALID_FORMATS = /* @__PURE__ */ new Set(["html", "jsx", "mjml", "maizzle"]);
79
+ async function readInput(pathOrStdin) {
80
+ if (pathOrStdin === "-") {
81
+ try {
82
+ return readFileSync2("/dev/stdin", "utf-8");
83
+ } catch {
84
+ }
85
+ return new Promise((resolve2, reject) => {
86
+ const chunks = [];
87
+ process.stdin.resume();
88
+ process.stdin.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
89
+ process.stdin.on("end", () => {
90
+ const data = Buffer.concat(chunks).toString("utf-8");
91
+ if (!data.trim()) {
92
+ reject(new Error("No input received from stdin. Pipe HTML or provide a file path."));
93
+ } else {
94
+ resolve2(data);
95
+ }
96
+ });
97
+ process.stdin.on("error", () => {
98
+ reject(new Error("No input received from stdin. Pipe HTML or provide a file path."));
99
+ });
100
+ });
101
+ }
102
+ try {
103
+ return readFileSync2(pathOrStdin, "utf-8");
104
+ } catch (err) {
105
+ const message = err instanceof Error ? err.message : String(err);
106
+ throw new Error(`Failed to read file "${pathOrStdin}": ${message}`);
107
+ }
108
+ }
109
+ function resolveClients(ids) {
110
+ const validIds = new Set(EMAIL_CLIENTS.map((c) => c.id));
111
+ if (!ids) {
112
+ return EMAIL_CLIENTS.map((c) => c.id);
113
+ }
114
+ const requested = ids.split(",").map((s) => s.trim()).filter(Boolean);
115
+ const invalid = requested.filter((id) => !validIds.has(id));
116
+ if (invalid.length > 0) {
117
+ throw new Error(
118
+ `Unknown client ID(s): ${invalid.join(", ")}.
119
+ Valid IDs: ${Array.from(validIds).join(", ")}`
120
+ );
121
+ }
122
+ return requested;
123
+ }
124
+ function isVueSfc(source) {
125
+ return /<template[\s>]/i.test(source) && /<\/template>/i.test(source);
126
+ }
127
+ function resolveFormat(formatFlag, filePath, source) {
128
+ if (formatFlag) {
129
+ if (!VALID_FORMATS.has(formatFlag)) {
130
+ throw new Error(
131
+ `Unknown format "${formatFlag}". Valid formats: ${Array.from(VALID_FORMATS).join(", ")}`
132
+ );
133
+ }
134
+ return formatFlag;
135
+ }
136
+ if (filePath && filePath !== "-") {
137
+ return detectFormat(filePath);
138
+ }
139
+ if (source && isVueSfc(source)) return "maizzle";
140
+ return "html";
141
+ }
142
+ function toFramework(format) {
143
+ if (format === "jsx" || format === "mjml" || format === "maizzle") return format;
144
+ return void 0;
145
+ }
146
+ function positionsApply(format) {
147
+ return format === "html";
148
+ }
149
+ var TARGETING_POLICY_ARG = {
150
+ type: "string",
151
+ description: "Client-targeting policy: progressive (default), strict, or lenient"
152
+ };
153
+ function parseTargetingPolicy(raw) {
154
+ if (raw == null || raw === "") return void 0;
155
+ if (raw === "progressive" || raw === "strict" || raw === "lenient") return raw;
156
+ throw new Error(`Unknown targeting policy "${raw}". Valid: progressive, strict, lenient`);
157
+ }
158
+
159
+ // src/commands/lint.ts
160
+ import { compile } from "@emailens/engine/compile";
161
+ import {
162
+ auditEmail,
163
+ CompileError,
164
+ MAX_WARNING_LOCATIONS
165
+ } from "@emailens/engine";
166
+ import { readdir } from "fs/promises";
167
+ import { resolve, relative } from "path";
168
+ var VALID_SKIPS = /* @__PURE__ */ new Set([
169
+ "spam",
170
+ "links",
171
+ "accessibility",
172
+ "images",
173
+ "compatibility",
174
+ "inboxPreview",
175
+ "size",
176
+ "templateVariables",
177
+ "overflow",
178
+ "visual",
179
+ "darkContrast",
180
+ "mobileContrast",
181
+ "design",
182
+ "vml",
183
+ "styleSurvival",
184
+ "targeting"
185
+ ]);
186
+ var lint_default = defineCommand({
187
+ meta: {
188
+ name: "lint",
189
+ description: "Lint HTML emails for compatibility, spam, accessibility, and more. CI/CD-friendly with structured exit codes."
190
+ },
191
+ args: {
192
+ input: {
193
+ type: "positional",
194
+ description: "HTML file path or glob pattern",
195
+ required: true
196
+ },
197
+ format: {
198
+ type: "string",
199
+ alias: "f",
200
+ description: "Input format: html, jsx, mjml, maizzle"
201
+ },
202
+ json: {
203
+ type: "boolean",
204
+ description: "Output as JSON"
205
+ },
206
+ info: {
207
+ type: "boolean",
208
+ description: "List info findings too: safe fallbacks, not problems (counted, not listed, by default)"
209
+ },
210
+ failOnWarning: {
211
+ type: "boolean",
212
+ description: "Exit 2 if warnings found"
213
+ },
214
+ skip: {
215
+ type: "string",
216
+ description: "Comma-separated checks to skip: spam,links,accessibility,images,compatibility,inboxPreview,size,templateVariables,overflow,visual,vml,styleSurvival,targeting"
217
+ },
218
+ targetingPolicy: TARGETING_POLICY_ARG,
219
+ maxWarnings: {
220
+ type: "string",
221
+ description: "Fail if more than n warnings"
222
+ },
223
+ reporter: {
224
+ type: "string",
225
+ description: "Also print findings as GitHub Actions annotations, on the lines of the pull request: github"
226
+ },
227
+ quiet: {
228
+ type: "boolean",
229
+ alias: "q",
230
+ description: "Suppress decorations: no hosted-preview line after a failure"
231
+ }
232
+ },
233
+ async run({ args }) {
234
+ try {
235
+ if (args.format) resolveFormat(args.format);
236
+ if (args.reporter !== void 0 && args.reporter !== "github") {
237
+ throw new Error(`Unknown reporter "${args.reporter}". Valid: github`);
238
+ }
239
+ if (args.reporter && args.json) throw new Error("--reporter github cannot be combined with --json");
240
+ const project = loadProjectConfig();
241
+ if (project?.invalid.length && !args.json) {
242
+ console.error(
243
+ pc.yellow(
244
+ `${project.source}: ignoring ${project.invalid.join(", ")}, a severity must be "error", "warning", "info" or "off".`
245
+ )
246
+ );
247
+ }
248
+ const skip = [];
249
+ if (!args.skip) {
250
+ for (const s of project?.skip ?? []) {
251
+ if (VALID_SKIPS.has(s)) skip.push(s);
252
+ else if (!args.json) {
253
+ console.error(pc.yellow(`${project?.source}: unknown skip value "${s}", ignoring.`));
254
+ }
255
+ }
256
+ }
257
+ if (args.skip) {
258
+ for (const s of args.skip.split(",").map((s2) => s2.trim()).filter(Boolean)) {
259
+ if (!VALID_SKIPS.has(s)) {
260
+ throw new Error(`Unknown skip value "${s}". Valid: ${Array.from(VALID_SKIPS).join(", ")}`);
261
+ }
262
+ skip.push(s);
263
+ }
264
+ }
265
+ const maxWarningsRaw = args.maxWarnings !== void 0 ? parseInt(args.maxWarnings, 10) : void 0;
266
+ if (maxWarningsRaw !== void 0 && isNaN(maxWarningsRaw)) {
267
+ throw new Error(`--maxWarnings must be a number, got: ${args.maxWarnings}`);
268
+ }
269
+ const maxWarnings = maxWarningsRaw ?? Infinity;
270
+ const files = await resolveGlob(args.input);
271
+ if (files.length === 0) {
272
+ if (args.json) {
273
+ console.log(JSON.stringify({ files: [], totalErrors: 0, totalWarnings: 0 }));
274
+ } else {
275
+ console.error(pc.red(`No files found matching: ${args.input}`));
276
+ }
277
+ process.exit(1);
278
+ }
279
+ const results = [];
280
+ let totalErrors = 0;
281
+ let totalWarnings = 0;
282
+ for (const file of files) {
283
+ const source = await readInput(file);
284
+ const format = resolveFormat(args.format, file, source);
285
+ const html = await compile(source, format);
286
+ const framework = toFramework(format);
287
+ const positions = positionsApply(format);
288
+ const targetingPolicy = parseTargetingPolicy(args.targetingPolicy);
289
+ const report = auditEmail(html, {
290
+ framework,
291
+ skip,
292
+ positions,
293
+ targetingPolicy
294
+ });
295
+ const issues = applySeverities(flattenToLintIssues(report, skip), project?.rules);
296
+ const errors = issues.filter((i) => i.severity === "error").length;
297
+ const warnings = issues.filter((i) => i.severity === "warning").length;
298
+ results.push({ file: relative(process.cwd(), file), issues, errors, warnings });
299
+ totalErrors += errors;
300
+ totalWarnings += warnings;
301
+ }
302
+ if (args.reporter === "github") {
303
+ for (const line of githubAnnotations(results, { info: args.info })) console.log(line);
304
+ }
305
+ if (args.json) {
306
+ console.log(JSON.stringify({ files: results, totalErrors, totalWarnings }));
307
+ } else {
308
+ for (const result of results) {
309
+ console.log(pc.underline(result.file));
310
+ const shown = args.info ? result.issues : result.issues.filter((i) => i.severity !== "info");
311
+ const hidden = result.issues.length - shown.length;
312
+ if (shown.length === 0) {
313
+ console.log(` ${pc.green("pass")} No issues found`);
314
+ } else {
315
+ const width = shown.reduce(
316
+ (w, i) => i.loc ? Math.max(w, `${i.loc.line}:${i.loc.column}`.length) : w,
317
+ 0
318
+ );
319
+ for (const issue of shown) {
320
+ const sev = issue.severity === "error" ? pc.red("error") : issue.severity === "warning" ? pc.yellow("warn ") : pc.blue("info ");
321
+ const pos = width > 0 ? `${pc.dim((issue.loc ? `${issue.loc.line}:${issue.loc.column}` : "").padStart(width))} ` : "";
322
+ console.log(` ${sev} ${pos}${pc.dim(issue.category.padEnd(18))} ${pc.bold(issue.rule.padEnd(22))} ${issue.message}`);
323
+ }
324
+ }
325
+ if (hidden > 0) {
326
+ console.log(pc.dim(` ${hidden} info: safe fallbacks, not problems. --info lists them.`));
327
+ }
328
+ console.log();
329
+ }
330
+ const summary = [
331
+ `${files.length} file${files.length === 1 ? "" : "s"}`,
332
+ totalErrors > 0 ? pc.red(`${totalErrors} error${totalErrors === 1 ? "" : "s"}`) : null,
333
+ totalWarnings > 0 ? pc.yellow(`${totalWarnings} warning${totalWarnings === 1 ? "" : "s"}`) : null,
334
+ totalErrors === 0 && totalWarnings === 0 ? pc.green("all clean") : null
335
+ ].filter(Boolean).join(" | ");
336
+ console.log(summary);
337
+ }
338
+ let exitCode = 0;
339
+ let reason = null;
340
+ if (totalErrors > 0) {
341
+ exitCode = 1;
342
+ } else if (args.failOnWarning && totalWarnings > 0) {
343
+ exitCode = 2;
344
+ reason = pc.yellow(`
345
+ Failed: ${totalWarnings} warning${totalWarnings === 1 ? "" : "s"} found (--failOnWarning)`);
346
+ } else if (Number.isFinite(maxWarnings) && totalWarnings > maxWarnings) {
347
+ exitCode = 2;
348
+ reason = pc.red(`
349
+ Exceeded max warnings: ${totalWarnings} > ${maxWarnings}`);
350
+ }
351
+ if (!args.json) {
352
+ if (reason) console.error(reason);
353
+ const hint = failureHint(exitCode, { quiet: args.quiet });
354
+ if (hint) console.log(pc.dim(hint));
355
+ }
356
+ if (exitCode !== 0) process.exit(exitCode);
357
+ } catch (err) {
358
+ if (err instanceof CompileError) {
359
+ console.error(pc.red(`Compilation failed (${err.phase}): ${err.message}`));
360
+ } else {
361
+ console.error(pc.red(err.message));
362
+ }
363
+ process.exit(1);
364
+ }
365
+ }
366
+ });
367
+ var HOSTED_HINT = "See it rendered in Gmail, Outlook and Apple Mail, no signup: https://app.emailens.dev/try?utm_source=cli&utm_medium=lint";
368
+ function failureHint(exitCode, options = {}) {
369
+ if (exitCode === 0 || options.quiet) return null;
370
+ return HOSTED_HINT;
371
+ }
372
+ function githubAnnotations(results, options = {}) {
373
+ const root = options.root ?? process.env.GITHUB_WORKSPACE ?? process.cwd();
374
+ const level = { error: "error", warning: "warning", info: "notice" };
375
+ const data = (s) => s.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
376
+ const prop = (s) => data(s).replace(/:/g, "%3A").replace(/,/g, "%2C");
377
+ const lines = [];
378
+ for (const result of results) {
379
+ const file = relative(root, resolve(result.file)).split("\\").join("/");
380
+ for (const issue of result.issues) {
381
+ if (issue.severity === "info" && !options.info) continue;
382
+ const loc = issue.loc ?? issue.locs?.[0];
383
+ const props = [`file=${prop(file)}`];
384
+ if (loc) props.push(`line=${loc.line}`, `col=${loc.column}`);
385
+ props.push(`title=${prop(`emailens ${issue.category}: ${issue.rule}`)}`);
386
+ lines.push(`::${level[issue.severity]} ${props.join(",")}::${data(issue.message)}`);
387
+ }
388
+ }
389
+ return lines;
390
+ }
391
+ async function resolveGlob(pattern) {
392
+ if (!pattern.includes("*")) {
393
+ return [resolve(pattern)];
394
+ }
395
+ if (pattern.includes("**")) {
396
+ throw new Error("Recursive glob (**) is not supported. Use a single-level wildcard (e.g., src/*.html) or list files explicitly.");
397
+ }
398
+ const lastSep = Math.max(pattern.lastIndexOf("/"), pattern.lastIndexOf("\\"));
399
+ const dir = lastSep >= 0 ? pattern.slice(0, lastSep) : ".";
400
+ const glob = lastSep >= 0 ? pattern.slice(lastSep + 1) : pattern;
401
+ const regex = new RegExp("^" + glob.replace(/\*/g, ".*") + "$");
402
+ const entries = await readdir(resolve(dir), { withFileTypes: true });
403
+ return entries.filter((e) => e.isFile() && regex.test(e.name)).map((e) => resolve(dir, e.name)).sort();
404
+ }
405
+ function mergeLocs(into, from) {
406
+ if (!from) return false;
407
+ let truncated = false;
408
+ for (const loc of from) {
409
+ if (into.some((l) => l.offset === loc.offset)) continue;
410
+ if (into.length >= MAX_WARNING_LOCATIONS) {
411
+ truncated = true;
412
+ break;
413
+ }
414
+ into.push(loc);
415
+ }
416
+ into.sort((a, b) => a.offset - b.offset);
417
+ return truncated;
418
+ }
419
+ function flattenToLintIssues(report, skip) {
420
+ const issues = [];
421
+ if (!skip.includes("compatibility")) {
422
+ const seenProps = /* @__PURE__ */ new Map();
423
+ for (const w of report.compatibility.warnings) {
424
+ const key = `${w.property}\0${w.severity}`;
425
+ const existing = seenProps.get(key);
426
+ if (existing) {
427
+ existing.clients.push(w.client);
428
+ existing.loc ??= w.loc;
429
+ if (mergeLocs(existing.locs, w.locs)) existing.locsTruncated = true;
430
+ if (w.locsTruncated) existing.locsTruncated = true;
431
+ } else {
432
+ seenProps.set(key, {
433
+ severity: w.severity,
434
+ clients: [w.client],
435
+ message: w.message,
436
+ loc: w.loc,
437
+ locs: (w.locs ?? []).slice(0, MAX_WARNING_LOCATIONS),
438
+ ...w.locsTruncated ? { locsTruncated: true } : {}
439
+ });
440
+ }
441
+ }
442
+ for (const [key, val] of seenProps) {
443
+ const property = key.split("\0")[0];
444
+ issues.push({
445
+ severity: val.severity,
446
+ category: val.clients.slice(0, 3).join(",") + (val.clients.length > 3 ? `+${val.clients.length - 3}` : ""),
447
+ rule: property,
448
+ message: val.message,
449
+ ...val.loc ? { loc: val.loc } : {},
450
+ ...val.locs.length ? { locs: val.locs } : {},
451
+ ...val.locsTruncated ? { locsTruncated: true } : {}
452
+ });
453
+ }
454
+ }
455
+ if (!skip.includes("spam")) {
456
+ for (const issue of report.spam.issues) {
457
+ issues.push({
458
+ severity: issue.severity,
459
+ category: "spam",
460
+ rule: issue.rule,
461
+ message: issue.message,
462
+ detail: issue.detail,
463
+ ...issue.loc ? { loc: issue.loc } : {}
464
+ });
465
+ }
466
+ }
467
+ if (!skip.includes("links")) {
468
+ for (const issue of report.links.issues) {
469
+ issues.push({
470
+ severity: issue.severity,
471
+ category: "links",
472
+ rule: issue.rule,
473
+ message: issue.message,
474
+ ...issue.loc ? { loc: issue.loc } : {}
475
+ });
476
+ }
477
+ }
478
+ if (!skip.includes("accessibility")) {
479
+ for (const issue of report.accessibility.issues) {
480
+ issues.push({
481
+ severity: issue.severity,
482
+ category: "accessibility",
483
+ rule: issue.rule,
484
+ message: issue.message,
485
+ ...issue.loc ? { loc: issue.loc } : {}
486
+ });
487
+ }
488
+ }
489
+ if (!skip.includes("images")) {
490
+ for (const issue of report.images.issues) {
491
+ issues.push({
492
+ severity: issue.severity,
493
+ category: "images",
494
+ rule: issue.rule,
495
+ message: issue.message,
496
+ ...issue.loc ? { loc: issue.loc } : {}
497
+ });
498
+ }
499
+ }
500
+ if (!skip.includes("inboxPreview")) {
501
+ for (const issue of report.inboxPreview.issues) {
502
+ issues.push({
503
+ severity: issue.severity,
504
+ category: "inboxPreview",
505
+ rule: issue.rule,
506
+ message: issue.message,
507
+ ...issue.loc ? { loc: issue.loc } : {}
508
+ });
509
+ }
510
+ }
511
+ if (!skip.includes("size")) {
512
+ for (const issue of report.size.issues) {
513
+ issues.push({
514
+ severity: issue.severity,
515
+ category: "size",
516
+ rule: issue.rule,
517
+ message: issue.message,
518
+ ...issue.loc ? { loc: issue.loc } : {}
519
+ });
520
+ }
521
+ }
522
+ if (!skip.includes("templateVariables")) {
523
+ for (const issue of report.templateVariables.issues) {
524
+ issues.push({
525
+ severity: issue.severity,
526
+ category: "templateVars",
527
+ rule: issue.rule,
528
+ message: issue.message,
529
+ ...issue.loc ? { loc: issue.loc } : {}
530
+ });
531
+ }
532
+ }
533
+ if (!skip.includes("overflow")) {
534
+ for (const issue of report.overflow.issues) {
535
+ issues.push({
536
+ severity: issue.severity,
537
+ category: "overflow",
538
+ rule: issue.rule,
539
+ message: issue.message,
540
+ ...issue.loc ? { loc: issue.loc } : {}
541
+ });
542
+ }
543
+ }
544
+ if (!skip.includes("visual")) {
545
+ for (const issue of report.visual.issues) {
546
+ issues.push({
547
+ severity: issue.severity,
548
+ category: "visual",
549
+ rule: issue.rule,
550
+ message: issue.message,
551
+ ...issue.loc ? { loc: issue.loc } : {}
552
+ });
553
+ }
554
+ }
555
+ if (!skip.includes("darkContrast")) {
556
+ for (const issue of report.darkContrast) {
557
+ issues.push({
558
+ severity: issue.severity,
559
+ category: "darkContrast",
560
+ rule: issue.rule,
561
+ message: issue.message.replace(/^Dark mode: /, ""),
562
+ ...issue.loc ? { loc: issue.loc } : {}
563
+ });
564
+ }
565
+ }
566
+ if (!skip.includes("mobileContrast")) {
567
+ for (const issue of report.mobileContrast) {
568
+ issues.push({
569
+ severity: issue.severity,
570
+ category: "mobileContrast",
571
+ rule: issue.rule,
572
+ message: issue.message.replace(/^At mobile width: /, ""),
573
+ ...issue.loc ? { loc: issue.loc } : {}
574
+ });
575
+ }
576
+ }
577
+ if (!skip.includes("vml")) {
578
+ for (const issue of report.vml.issues) {
579
+ issues.push({
580
+ severity: issue.severity,
581
+ category: "vml",
582
+ rule: issue.rule,
583
+ message: issue.message,
584
+ detail: issue.detail,
585
+ ...issue.loc ? { loc: issue.loc } : {}
586
+ });
587
+ }
588
+ }
589
+ if (!skip.includes("styleSurvival")) {
590
+ for (const issue of report.styleSurvival.issues) {
591
+ const clients = issue.clients.length ? ` (${issue.clients.join(", ")})` : "";
592
+ issues.push({
593
+ severity: issue.severity,
594
+ category: "styleSurvival",
595
+ rule: issue.rule,
596
+ message: `${issue.message}${clients}`,
597
+ detail: issue.frameworkNote ?? issue.detail,
598
+ ...issue.loc ? { loc: issue.loc } : {}
599
+ });
600
+ }
601
+ }
602
+ if (!skip.includes("targeting")) {
603
+ for (const issue of report.targeting.warnings) {
604
+ issues.push({
605
+ severity: issue.severity,
606
+ category: "targeting",
607
+ rule: issue.property,
608
+ message: issue.message,
609
+ detail: issue.suggestion,
610
+ ...issue.loc ? { loc: issue.loc } : {},
611
+ ...issue.locs?.length ? { locs: issue.locs } : {},
612
+ ...issue.locsTruncated ? { locsTruncated: true } : {}
613
+ });
614
+ }
615
+ }
616
+ if (!skip.includes("design")) {
617
+ for (const issue of report.design.issues) {
618
+ issues.push({
619
+ severity: issue.severity,
620
+ category: "design",
621
+ rule: issue.rule,
622
+ message: issue.message,
623
+ detail: issue.detail
624
+ });
625
+ }
626
+ }
627
+ const order = { error: 0, warning: 1, info: 2 };
628
+ issues.sort((a, b) => order[a.severity] - order[b.severity]);
629
+ return issues;
630
+ }
631
+
632
+ export {
633
+ readInput,
634
+ resolveClients,
635
+ resolveFormat,
636
+ toFramework,
637
+ positionsApply,
638
+ TARGETING_POLICY_ARG,
639
+ parseTargetingPolicy,
640
+ loadProjectConfig,
641
+ applySeverities,
642
+ lint_default,
643
+ flattenToLintIssues
644
+ };
645
+ //# sourceMappingURL=chunk-KZ7WXQVF.js.map