@menapo/vi18n 0.1.0 → 0.1.2
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/README.md +14 -14
- package/dist/{apply-Bre-lY9J.js → apply-FAHl1R6T.js} +69 -89
- package/dist/{captured-Bj8bO6vd.js → captured-CTjjDF5o.js} +196 -217
- package/dist/{check-DyrAbv73.js → check-DwFwOB1d.js} +66 -84
- package/dist/cli.js +2 -3
- package/dist/{collect-Cx4_SKOe.js → collect-CYATDjdo.js} +1 -2
- package/dist/collisions-uMTuq36M.js +215 -0
- package/dist/compile-CEvH-6sY.js +240 -0
- package/dist/{compile-Cc97JaW2.js → compile-DqkofbiO.js} +376 -331
- package/dist/concurrency-BCY_4zcr.js +1 -0
- package/dist/concurrency-Dy2ny50V.js +107 -0
- package/dist/config.d.ts +1 -5
- package/dist/config.js +4 -5
- package/dist/{types-D3QGM8XO.js → diagnostics-1onDF6Ua.js} +26 -26
- package/dist/{dir-zw6bGMKQ.js → dir-TGLYuOZb.js} +34 -37
- package/dist/{duplicates-yuRljQ6h.js → duplicates-CsUXRX2J.js} +10 -27
- package/dist/engine-Bf7nVigL.js +556 -0
- package/dist/engine.d.ts +1 -5
- package/dist/engine.js +297 -168
- package/dist/exchange-DYG9RZoT.js +41 -0
- package/dist/{exclude-Du-Zd_qI.js → exclude-vMnm3lqU.js} +2 -3
- package/dist/{export-DGsMbcTZ.js → export-BYq0gfLd.js} +17 -38
- package/dist/{extract-Dujlsgnk.js → extract-CYtuEo8u.js} +114 -82
- package/dist/{formats-KPIg-08V.js → formats-ChV1LVH_.js} +352 -276
- package/dist/fs-ezCMZeDV.js +52 -0
- package/dist/i18next-1waHziMy.js +1 -0
- package/dist/i18next-D66Icz3L.js +1907 -0
- package/dist/{import-Cwdhcywt.js → import-BApbQlmm.js} +81 -75
- package/dist/index.d.ts +1 -13
- package/dist/index.js +14 -16
- package/dist/{init-BecCTvKi.js → init-J7AwwA5e.js} +466 -501
- package/dist/{library-D5CWvTQs.js → library-BfSOBeBd.js} +975 -451
- package/dist/lingui-Ee2farVo.js +902 -0
- package/dist/lint.d.ts +0 -4
- package/dist/lint.js +69 -82
- package/dist/{load-gW-oJt1Q.js → load-BFLLqY8x.js} +272 -147
- package/dist/{load-CQRz4PpM.js → load-CMwhukZ4.js} +1211 -1115
- package/dist/{locales-DX4MOBFE.js → locales-DxLDrx-h.js} +271 -237
- package/dist/{lsp-Cq1Nuu-Q.js → lsp-BC7xDGON.js} +4 -5
- package/dist/{match-BGr8EXB3.js → match-BLDcj610.js} +11 -4
- package/dist/{mcp-Cf0T7qPW.js → mcp-Cka8ywDF.js} +4 -5
- package/dist/{merge-driver-CpiiSVIc.js → merge-driver-B04Apm29.js} +138 -122
- package/dist/migrate-D7TNl6SD.js +2169 -0
- package/dist/migrate-khCY8TE0.js +1 -0
- package/dist/{openai-CTaMDcl-.js → openai-RWw0YlAx.js} +128 -87
- package/dist/{output-DsaHKHEt.js → output-CF9uvk_-.js} +15 -9
- package/dist/parse.d.ts +1 -3
- package/dist/parse.js +7 -8
- package/dist/{pipeline-wxS0SApG.js → pipeline-B30irGMD.js} +1 -1
- package/dist/{pipeline-C7g11THL.js → pipeline-sgl_q_op.js} +387 -359
- package/dist/project-DSzWKU3C.js +544 -0
- package/dist/{pseudo-DRv30iN5.js → pseudo-DNbNNVGP.js} +125 -3
- package/dist/{raw-C4Y6vyGY.js → raw-YsYZMS9n.js} +52 -29
- package/dist/react-intl-tzGIk6G3.js +634 -0
- package/dist/restore-BG_zMpSj.js +199 -0
- package/dist/rewrite-hAcRJwiZ.js +415 -0
- package/dist/{rich-DCUKl5HM.js → rich-ApY1Dm4S.js} +35 -28
- package/dist/rolldown-runtime-C1I3wEg2.js +43 -0
- package/dist/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-D8jQpDG7.js} +1 -2
- package/dist/run-CFzR3V93.js +647 -0
- package/dist/scan-worker.d.ts +2 -4
- package/dist/scan-worker.js +1 -1
- package/dist/{scoped-BMYpSthj.js → scoped-h3KE8XWW.js} +3 -4
- package/dist/{server-BDkykMjb.js → server-WlxZH0oX.js} +275 -330
- package/dist/{server-qv3mz70d.js → server-ceuzzkal.js} +292 -386
- package/dist/server.d.ts +1 -17
- package/dist/server.js +415 -381
- package/dist/{sitemap-DV3o8QD7.js → sitemap-796jJKUT.js} +21 -33
- package/dist/{sources-D19czDSA.js → sources-DuOdM02f.js} +712 -373
- package/dist/{status-DZArW5aE.js → status-CTH3qI-0.js} +30 -30
- package/dist/{stdio-FPOKQAgu.js → stdio-D9kTzyqB.js} +2 -4
- package/dist/{stdio-CVaJfxA7.js → stdio-FWIVU3P4.js} +1 -2
- package/dist/sync-CpL0Qsgw.js +1352 -0
- package/dist/{t-DC-c9zE5.js → t-gvEXx25s.js} +76 -53
- package/dist/test.d.ts +5 -16
- package/dist/test.js +77 -48
- package/dist/translate-BrfVRkjl.js +336 -0
- package/dist/{ts-BaU5yOf0.js → ts-BX6kwig5.js} +25 -14
- package/dist/{types-DtvQ7UdD.js → types-3kwyaCAm.js} +1 -2
- package/dist/{types-DsdWBG0b.d.ts → types-BaG1LboH.d.ts} +2 -6
- package/dist/{types-CgUCkFU1.d.ts → types-Cy2bPdSg.d.ts} +14 -20
- package/dist/types-Ds_vebja.js +41 -0
- package/dist/{units-CQ5Q99RC.js → units-VVLgQ7x7.js} +7 -16
- package/dist/{url-CRfCOhUI.js → url-Bpc6wLea.js} +24 -11
- package/dist/{url-CsBkRaJy.js → url-D2_VlEeH.js} +25 -12
- package/dist/{validate-D6DJepZv.js → validate-PGgMsasz.js} +3 -5
- package/dist/{validate-BxpupdAf.js → validate-zv4-IZyZ.js} +690 -377
- package/dist/{version-BlyLGlOa.js → version-BFs370Ce.js} +3 -5
- package/dist/{vite-scan-B_YW4X_a.js → vite-scan-DFKSGVE9.js} +87 -92
- package/dist/vite.d.ts +2 -6
- package/dist/vite.js +6482 -6018
- package/dist/vue-i18n-CBmZqHbG.js +806 -0
- package/dist/{which-C6PFI1Dm.js → which-BpyJyBkX.js} +44 -37
- package/dist/{worker-84U6uYB3.js → worker-BjzVqJVO.js} +454 -608
- package/package.json +8 -8
- package/dist/check-D34P-S--.js +0 -1
- package/dist/codec-DuvU2VQy.js +0 -207
- package/dist/collisions-CfpZU8e4.js +0 -217
- package/dist/compile-B5Mz6WJm.js +0 -245
- package/dist/concurrency-C9UUWuDC.js +0 -96
- package/dist/concurrency-DONL7t4V.js +0 -1
- package/dist/engine-B7p40M__.js +0 -531
- package/dist/i18next-CrUnKFfh.js +0 -1596
- package/dist/i18next-Rgo-v9l0.js +0 -1
- package/dist/lingui--PcOOYry.js +0 -833
- package/dist/messages-Cxa-5tR0.js +0 -166
- package/dist/migrate-CntqvrW4.js +0 -1
- package/dist/migrate-dPgq9uzy.js +0 -1484
- package/dist/project-Dwx7iPm6.js +0 -381
- package/dist/project-pXipT8iG.js +0 -1046
- package/dist/react-intl-CaBVwJ9u.js +0 -519
- package/dist/restore-Btq66Tid.js +0 -175
- package/dist/rewrite-CiTRAICl.js +0 -803
- package/dist/run-DYD_VXKy.js +0 -694
- package/dist/runtime-DTMmliT1.js +0 -64
- package/dist/sync-CcVzger_.js +0 -658
- package/dist/translate-DZR3MkSA.js +0 -299
- package/dist/types-wSh9fCBY.js +0 -11
- package/dist/vue-i18n-CEMnpv7k.js +0 -651
package/dist/lint.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/lint/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The slice of ESLint's rule API the `/lint` rules use, declared here: the
|
|
4
3
|
* entry ships no `eslint` dependency, and oxlint's JS plugins implement the
|
|
@@ -98,8 +97,5 @@ interface Plugin {
|
|
|
98
97
|
recommended: FlatConfig;
|
|
99
98
|
};
|
|
100
99
|
}
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/lint/plugin.d.ts
|
|
103
100
|
declare const plugin: Plugin;
|
|
104
|
-
//#endregion
|
|
105
101
|
export { plugin as default };
|
package/dist/lint.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as findCapturedValues } from "./captured-Bj8bO6vd.js";
|
|
1
|
+
import { t as VERSION } from "./version-BFs370Ce.js";
|
|
2
|
+
import { a as DEFAULT_IMPORT_SOURCES } from "./diagnostics-1onDF6Ua.js";
|
|
3
|
+
import { b as parseICU, f as createCodec, v as normalizeSource, x as quoteStarts } from "./validate-zv4-IZyZ.js";
|
|
4
|
+
import { C as langFromId, E as lineStartsOf, a as scanModule, l as findMarkers, r as sourceSpecifiers, u as isIgnored } from "./sources-DuOdM02f.js";
|
|
5
|
+
import { t as findCapturedValues } from "./captured-CTjjDF5o.js";
|
|
7
6
|
import { extname } from "node:path";
|
|
8
|
-
|
|
7
|
+
// src/lint/analysis.ts
|
|
9
8
|
/**
|
|
10
9
|
* What every `/lint` rule reads of a file, computed once per file: the
|
|
11
10
|
* settings, the marker comments, and the extraction scan itself, run on the
|
|
@@ -139,16 +138,6 @@ function scanTree(root, literals) {
|
|
|
139
138
|
function isNode(value) {
|
|
140
139
|
return value !== null && typeof value === "object" && typeof value.type === "string" && Array.isArray(value.range);
|
|
141
140
|
}
|
|
142
|
-
function langOf(filename) {
|
|
143
|
-
switch (extname(filename).toLowerCase()) {
|
|
144
|
-
case ".ts":
|
|
145
|
-
case ".mts":
|
|
146
|
-
case ".cts": return "ts";
|
|
147
|
-
case ".tsx": return "tsx";
|
|
148
|
-
case ".jsx": return "jsx";
|
|
149
|
-
default: return "js";
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
141
|
function commentsOf(context) {
|
|
153
142
|
return context.sourceCode.getAllComments().map((comment) => {
|
|
154
143
|
const range = comment.range ?? [comment.start ?? 0, comment.end ?? 0];
|
|
@@ -160,11 +149,6 @@ function commentsOf(context) {
|
|
|
160
149
|
};
|
|
161
150
|
});
|
|
162
151
|
}
|
|
163
|
-
function lineStartsOf(code) {
|
|
164
|
-
const starts = [0];
|
|
165
|
-
for (let i = code.indexOf("\n"); i !== -1; i = code.indexOf("\n", i + 1)) starts.push(i + 1);
|
|
166
|
-
return starts;
|
|
167
|
-
}
|
|
168
152
|
/** Whether a module's top level is module code: an export in an SFC script means `<script>` or `<script module>`. */
|
|
169
153
|
function exports(ast) {
|
|
170
154
|
return ast.body.some((statement) => statement.type === "ExportDefaultDeclaration" || statement.type === "ExportNamedDeclaration" || statement.type === "ExportAllDeclaration");
|
|
@@ -210,7 +194,7 @@ function analyse(context) {
|
|
|
210
194
|
const program = scanTree(sourceCode.ast, literals);
|
|
211
195
|
parsed = {
|
|
212
196
|
code,
|
|
213
|
-
lang:
|
|
197
|
+
lang: langFromId(context.filename),
|
|
214
198
|
program,
|
|
215
199
|
comments
|
|
216
200
|
};
|
|
@@ -239,7 +223,7 @@ function analyse(context) {
|
|
|
239
223
|
translating,
|
|
240
224
|
component: extension === ".astro" || sfc && !exports(sourceCode.ast),
|
|
241
225
|
framework: frameworkOf(settings, extension, imports.map((record) => record.specifier)),
|
|
242
|
-
lineStarts:
|
|
226
|
+
lineStarts: null
|
|
243
227
|
};
|
|
244
228
|
cache.set(sourceCode.ast, analysis);
|
|
245
229
|
return analysis;
|
|
@@ -255,10 +239,14 @@ const WRAPPERS = /* @__PURE__ */ new Set([
|
|
|
255
239
|
"TSTypeAssertion",
|
|
256
240
|
"ChainExpression"
|
|
257
241
|
]);
|
|
242
|
+
/** Whether the node only wraps its `expression`: a TypeScript-only wrapper or a `?.` chain. */
|
|
243
|
+
function isWrapper(node) {
|
|
244
|
+
return WRAPPERS.has(node.type);
|
|
245
|
+
}
|
|
258
246
|
/** The expression under TypeScript-only wrappers and `?.` chains. */
|
|
259
247
|
function unwrap(node) {
|
|
260
248
|
let current = node;
|
|
261
|
-
while (
|
|
249
|
+
while (isWrapper(current)) current = current.expression;
|
|
262
250
|
return current;
|
|
263
251
|
}
|
|
264
252
|
/** Whether the node is a call that renders a message (`t`, `rich*`, a translator's or an alias). */
|
|
@@ -268,6 +256,7 @@ function isTranslating(analysis, node) {
|
|
|
268
256
|
}
|
|
269
257
|
/** The offset of a 1-based line and column of `analysis.code`. */
|
|
270
258
|
function offsetOf(analysis, line, column) {
|
|
259
|
+
analysis.lineStarts ??= lineStartsOf(analysis.code);
|
|
271
260
|
return (analysis.lineStarts[line - 1] ?? 0) + column - 1;
|
|
272
261
|
}
|
|
273
262
|
/** Reports at an offset range of the file. */
|
|
@@ -283,17 +272,16 @@ function reportRange(context, range, messageId, data, fix) {
|
|
|
283
272
|
...fix === void 0 ? {} : { fix }
|
|
284
273
|
});
|
|
285
274
|
}
|
|
286
|
-
const DOCS = "https://github.com/menapo/
|
|
275
|
+
const DOCS = "https://github.com/menapo/kit/blob/main/packages/vi18n/docs/guide/lint.md";
|
|
287
276
|
/** Rule docs link: the guide's section of that rule. */
|
|
288
|
-
function docs(rule, description
|
|
277
|
+
function docs(rule, description) {
|
|
289
278
|
return {
|
|
290
279
|
description,
|
|
291
|
-
recommended,
|
|
280
|
+
recommended: true,
|
|
292
281
|
url: `${DOCS}#${rule}`
|
|
293
282
|
};
|
|
294
283
|
}
|
|
295
|
-
|
|
296
|
-
//#region src/lint/rules/no-concatenation.ts
|
|
284
|
+
// src/lint/rules/no-concatenation.ts
|
|
297
285
|
/**
|
|
298
286
|
* `no-concatenation`: translated text joined with other text in code, which
|
|
299
287
|
* fixes the word order for every language and splits one sentence into
|
|
@@ -343,7 +331,7 @@ const noConcatenation = {
|
|
|
343
331
|
BinaryExpression(node) {
|
|
344
332
|
if (node.operator !== "+") return;
|
|
345
333
|
let parent = node.parent;
|
|
346
|
-
while (parent &&
|
|
334
|
+
while (parent && isWrapper(parent)) parent = parent.parent;
|
|
347
335
|
if (isPlus(parent)) return;
|
|
348
336
|
const parts = [];
|
|
349
337
|
operands(node, parts);
|
|
@@ -391,8 +379,7 @@ const noConcatenation = {
|
|
|
391
379
|
};
|
|
392
380
|
}
|
|
393
381
|
};
|
|
394
|
-
|
|
395
|
-
//#region src/lint/rules/no-dynamic-message.ts
|
|
382
|
+
// src/lint/rules/no-dynamic-message.ts
|
|
396
383
|
const CODES = /* @__PURE__ */ new Set([
|
|
397
384
|
"extract-dynamic-message",
|
|
398
385
|
"extract-non-literal-option",
|
|
@@ -414,8 +401,11 @@ const noDynamicMessage = {
|
|
|
414
401
|
} };
|
|
415
402
|
}
|
|
416
403
|
};
|
|
417
|
-
|
|
418
|
-
|
|
404
|
+
// src/lint/jsx.ts
|
|
405
|
+
/**
|
|
406
|
+
* JSX helpers of the literal-text rules (`no-literal-string`,
|
|
407
|
+
* `translate-a11y-attrs`, PLAN §4.13, §4.16).
|
|
408
|
+
*/
|
|
419
409
|
/** Attributes assistive technology reads or browsers show as text (`translate-a11y-attrs`). */
|
|
420
410
|
const A11Y_ATTRIBUTES = [
|
|
421
411
|
"alt",
|
|
@@ -508,12 +498,28 @@ function renderedStrings(expression) {
|
|
|
508
498
|
stack.push(next.right);
|
|
509
499
|
if (next.operator !== "&&") stack.push(next.left);
|
|
510
500
|
break;
|
|
511
|
-
|
|
512
|
-
case "TSSatisfiesExpression":
|
|
513
|
-
case "TSNonNullExpression": stack.push(next.expression);
|
|
501
|
+
default: if (isWrapper(next)) stack.push(next.expression);
|
|
514
502
|
}
|
|
515
503
|
return out;
|
|
516
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* Reports, as `attribute`, each literal the attribute's value can render
|
|
507
|
+
* that `skip` does not excuse.
|
|
508
|
+
*/
|
|
509
|
+
function reportAttributeLiterals(context, attribute, name, skip) {
|
|
510
|
+
for (const literal of renderedStrings(attribute.value)) {
|
|
511
|
+
const text = literalText(literal);
|
|
512
|
+
if (skip(literal, text)) continue;
|
|
513
|
+
context.report({
|
|
514
|
+
node: literal,
|
|
515
|
+
messageId: "attribute",
|
|
516
|
+
data: {
|
|
517
|
+
name,
|
|
518
|
+
text: quote(text)
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}
|
|
517
523
|
/** The text of a literal `renderedStrings` returned. */
|
|
518
524
|
function literalText(node) {
|
|
519
525
|
if (node.type === "Literal") return node.value;
|
|
@@ -533,8 +539,7 @@ function quote(text) {
|
|
|
533
539
|
const flat = text.trim().replace(/\s+/g, " ");
|
|
534
540
|
return flat.length > 40 ? `${flat.slice(0, 39)}…` : flat;
|
|
535
541
|
}
|
|
536
|
-
|
|
537
|
-
//#region src/lint/rules/no-literal-string.ts
|
|
542
|
+
// src/lint/rules/no-literal-string.ts
|
|
538
543
|
/**
|
|
539
544
|
* `no-literal-string` (PLAN §4.13): text a JSX component renders without a
|
|
540
545
|
* translation call: JSX text, string children (`{"…"}`, either branch of a
|
|
@@ -550,6 +555,14 @@ const strings = {
|
|
|
550
555
|
items: { type: "string" },
|
|
551
556
|
uniqueItems: true
|
|
552
557
|
};
|
|
558
|
+
/** A user's `ignore` pattern; a bad one names the rule and the option instead of failing every file. */
|
|
559
|
+
function ignorePattern(source) {
|
|
560
|
+
try {
|
|
561
|
+
return new RegExp(source, "u");
|
|
562
|
+
} catch (error) {
|
|
563
|
+
throw new Error(`vi18n/no-literal-string: ignore pattern ${JSON.stringify(source)} is not a valid regular expression: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
564
|
+
}
|
|
565
|
+
}
|
|
553
566
|
const noLiteralString = {
|
|
554
567
|
meta: {
|
|
555
568
|
type: "suggestion",
|
|
@@ -572,7 +585,7 @@ const noLiteralString = {
|
|
|
572
585
|
const options = context.options[0] ?? {};
|
|
573
586
|
const attributes = new Set(options.attributes ?? ["label"]);
|
|
574
587
|
const elements = new Set(options.ignoreElements ?? IGNORED_ELEMENTS);
|
|
575
|
-
const patterns = (options.ignore ?? []).map(
|
|
588
|
+
const patterns = (options.ignore ?? []).map(ignorePattern);
|
|
576
589
|
const analysis = analyse(context);
|
|
577
590
|
const skip = (node, text) => !hasLetters(text) || patterns.some((pattern) => pattern.test(text.trim())) || ignored(analysis, node) || untranslatable(node, elements);
|
|
578
591
|
return {
|
|
@@ -598,23 +611,12 @@ const noLiteralString = {
|
|
|
598
611
|
const name = jsxName(node.name);
|
|
599
612
|
if (name === null || node.value === null) return;
|
|
600
613
|
if (!attributes.has(name) && !isButtonValue(node)) return;
|
|
601
|
-
|
|
602
|
-
const text = literalText(literal);
|
|
603
|
-
if (!skip(literal, text)) context.report({
|
|
604
|
-
node: literal,
|
|
605
|
-
messageId: "attribute",
|
|
606
|
-
data: {
|
|
607
|
-
name,
|
|
608
|
-
text: quote(text)
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
}
|
|
614
|
+
reportAttributeLiterals(context, node, name, skip);
|
|
612
615
|
}
|
|
613
616
|
};
|
|
614
617
|
}
|
|
615
618
|
};
|
|
616
|
-
|
|
617
|
-
//#region src/lint/rules/no-module-scope-t.ts
|
|
619
|
+
// src/lint/rules/no-module-scope-t.ts
|
|
618
620
|
/**
|
|
619
621
|
* `no-module-scope-t`: `extract-module-scope`, a `t()` call that runs when
|
|
620
622
|
* the module is imported (PLAN §5.3). The top level of a Vue or Svelte
|
|
@@ -639,8 +641,7 @@ const noModuleScopeT = {
|
|
|
639
641
|
} };
|
|
640
642
|
}
|
|
641
643
|
};
|
|
642
|
-
|
|
643
|
-
//#region src/lint/rules/prefer-full-sentence.ts
|
|
644
|
+
// src/lint/rules/prefer-full-sentence.ts
|
|
644
645
|
/**
|
|
645
646
|
* `prefer-full-sentence`: a message that reads as part of a sentence, which
|
|
646
647
|
* code then completes with other text or another message. Translators need
|
|
@@ -728,8 +729,7 @@ const preferFullSentence = {
|
|
|
728
729
|
} };
|
|
729
730
|
}
|
|
730
731
|
};
|
|
731
|
-
|
|
732
|
-
//#region src/lint/rules/t-result-captured.ts
|
|
732
|
+
// src/lint/rules/t-result-captured.ts
|
|
733
733
|
/**
|
|
734
734
|
* `t-result-captured`: a translation computed once and kept, which an
|
|
735
735
|
* in-place locale switch leaves in the old locale (PLAN §5.15). The same
|
|
@@ -759,8 +759,7 @@ const tResultCaptured = {
|
|
|
759
759
|
} };
|
|
760
760
|
}
|
|
761
761
|
};
|
|
762
|
-
|
|
763
|
-
//#region src/lint/rules/translate-a11y-attrs.ts
|
|
762
|
+
// src/lint/rules/translate-a11y-attrs.ts
|
|
764
763
|
/**
|
|
765
764
|
* `translate-a11y-attrs` (PLAN §4.16): literal text in the attributes
|
|
766
765
|
* screen readers announce and browsers show (`alt`, `aria-label`,
|
|
@@ -793,23 +792,11 @@ const translateA11yAttrs = {
|
|
|
793
792
|
return { JSXAttribute(node) {
|
|
794
793
|
const name = jsxName(node.name);
|
|
795
794
|
if (name === null || node.value === null || !attributes.has(name)) return;
|
|
796
|
-
|
|
797
|
-
const text = literalText(literal);
|
|
798
|
-
if (!hasLetters(text) || ignored(analysis, literal) || untranslatable(literal, NO_ELEMENTS)) continue;
|
|
799
|
-
context.report({
|
|
800
|
-
node: literal,
|
|
801
|
-
messageId: "attribute",
|
|
802
|
-
data: {
|
|
803
|
-
name,
|
|
804
|
-
text: quote(text)
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
}
|
|
795
|
+
reportAttributeLiterals(context, node, name, (literal, text) => !hasLetters(text) || ignored(analysis, literal) || untranslatable(literal, NO_ELEMENTS));
|
|
808
796
|
} };
|
|
809
797
|
}
|
|
810
798
|
};
|
|
811
|
-
|
|
812
|
-
//#region src/lint/rules/valid-icu.ts
|
|
799
|
+
// src/lint/rules/valid-icu.ts
|
|
813
800
|
/**
|
|
814
801
|
* `valid-icu`: the ICU checks `vite build` and `vi18n extract` run on every
|
|
815
802
|
* extracted message (INTERNALS §2.1.3): syntax, argument styles and
|
|
@@ -893,8 +880,7 @@ function apostropheFix(node, code) {
|
|
|
893
880
|
}
|
|
894
881
|
return `${quote}${body}${quote}`;
|
|
895
882
|
}
|
|
896
|
-
|
|
897
|
-
//#region src/lint/plugin.ts
|
|
883
|
+
// src/lint/plugin.ts
|
|
898
884
|
/**
|
|
899
885
|
* The `@menapo/vi18n/lint` plugin (PLAN §4.13, §5.21; INTERNALS §3.7): ESLint
|
|
900
886
|
* v9 rules that oxlint loads through `jsPlugins`, so they run inside `vp
|
|
@@ -925,12 +911,15 @@ const rules = {
|
|
|
925
911
|
const { range } = diagnostic;
|
|
926
912
|
if (!diagnostic.code.startsWith("icu-") || range === void 0) continue;
|
|
927
913
|
if (diagnostic.code !== "icu-apostrophe") reportRange(context, range, "icu", { message: diagnostic.message });
|
|
928
|
-
else if (!apostrophes.has(range[0])) apostrophes.set(range[0],
|
|
914
|
+
else if (!apostrophes.has(range[0])) apostrophes.set(range[0], {
|
|
915
|
+
diagnostic,
|
|
916
|
+
range
|
|
917
|
+
});
|
|
929
918
|
}
|
|
930
|
-
for (const [start, diagnostic] of apostrophes) {
|
|
919
|
+
for (const [start, { diagnostic, range }] of apostrophes) {
|
|
931
920
|
const literal = analysis.literals.get(start);
|
|
932
921
|
const fixed = literal === void 0 ? null : apostropheFix(literal, analysis.code);
|
|
933
|
-
reportRange(context,
|
|
922
|
+
reportRange(context, range, "icu", { message: diagnostic.message }, fixed === null || literal === void 0 ? void 0 : (fixer) => fixer.replaceTextRange(literal.range, fixed));
|
|
934
923
|
}
|
|
935
924
|
} };
|
|
936
925
|
}
|
|
@@ -959,13 +948,11 @@ const plugin = {
|
|
|
959
948
|
configs: { recommended }
|
|
960
949
|
};
|
|
961
950
|
recommended.plugins.vi18n = plugin;
|
|
962
|
-
|
|
963
|
-
//#region src/lint.ts
|
|
951
|
+
// src/lint.ts
|
|
964
952
|
/**
|
|
965
953
|
* `@menapo/vi18n/lint` (INTERNALS §3.7): the lint plugin, as the module's
|
|
966
954
|
* default export because ESLint flat configs and oxlint's `jsPlugins` both
|
|
967
955
|
* load a plugin that way.
|
|
968
956
|
*/
|
|
969
957
|
var lint_default = plugin;
|
|
970
|
-
//#endregion
|
|
971
958
|
export { lint_default as default };
|