vue-i18n-lint 0.2.0 → 0.2.1

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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/dist/cli.mjs +13 -4
  3. package/package.json +12 -12
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # vue-i18n-lint
2
2
 
3
+ [![NPM](https://img.shields.io/npm/v/vue-i18n-lint)](https://www.npmjs.com/package/vue-i18n-lint)
4
+
3
5
  Fast and accurate linting for Vue i18n. Detects missing and unused translation keys across your locale files and source
4
6
  code.
5
7
 
package/dist/cli.mjs CHANGED
@@ -622,7 +622,8 @@ function collectFromDirective(file, node, options) {
622
622
  const bodyPart = parseScript(file, content, {
623
623
  wrapInParens: true,
624
624
  offset: adjustedOffset,
625
- fileSource: options?.fileSource
625
+ fileSource: options?.fileSource,
626
+ lang: options?.lang
626
627
  }).body[0];
627
628
  if (!bodyPart || bodyPart.type !== "ExpressionStatement") return [];
628
629
  return walkDirective(bodyPart.expression, adjustedOffset);
@@ -650,7 +651,8 @@ function collectFromExpression(file, node, options) {
650
651
  return collectJsKeys(parseScript(file, content, {
651
652
  wrapInParens: true,
652
653
  offset: node.loc.start.offset - 1,
653
- fileSource: options?.fileSource
654
+ fileSource: options?.fileSource,
655
+ lang: options?.lang
654
656
  }), node.loc.start.offset - 1);
655
657
  }
656
658
  //#endregion
@@ -675,7 +677,13 @@ function collectFromVue(source, file) {
675
677
  if (errors.length > 0 && !descriptor.template && !descriptor.script && !descriptor.scriptSetup) throw new ParseError(`Failed to parse Vue file:\n${errors.map((e) => ` • ${e.message}`).join("\n")}`, file);
676
678
  const rawKeys = [];
677
679
  const templateAst = descriptor.template?.ast;
678
- if (templateAst) rawKeys.push(...collectVueKeys(file, templateAst, { fileSource: source }));
680
+ if (templateAst) {
681
+ const templateLang = [descriptor.script, descriptor.scriptSetup].reduce((lang, block) => lang ?? asLang(block?.lang), void 0);
682
+ rawKeys.push(...collectVueKeys(file, templateAst, {
683
+ fileSource: source,
684
+ lang: templateLang
685
+ }));
686
+ }
679
687
  for (const script of [descriptor.script, descriptor.scriptSetup]) {
680
688
  if (!script) continue;
681
689
  if (!TRANSLATION_CALL_REGEX.test(script.content)) continue;
@@ -888,7 +896,8 @@ const removeUnusedCommand = buildCommand({
888
896
  return;
889
897
  }
890
898
  if (!flags.dryRun) await Promise.all(localeFiles.map(async (localeFile) => {
891
- const stringifier = stringifiers[extname(localeFile.file)];
899
+ const ext = extname(localeFile.file);
900
+ const stringifier = stringifiers[ext];
892
901
  if (!stringifier) return;
893
902
  removeKeysFromData(localeFile.rawData, unusedSet);
894
903
  await writeFile(localeFile.file, stringifier(localeFile.rawData), "utf-8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-i18n-lint",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Fast and accurate linting for Vue i18n.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -27,16 +27,16 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@babel/code-frame": "^8.0.0",
30
- "@stricli/core": "^1.2.8",
30
+ "@stricli/core": "^1.2.9",
31
31
  "@toon-format/toon": "^2.3.0",
32
32
  "@vue/compiler-core": "^3.5.39",
33
33
  "@vue/compiler-sfc": "^3.5.39",
34
34
  "c12": "4.0.0-beta.5",
35
35
  "confbox": "^0.2.4",
36
36
  "defu": "^6.1.7",
37
- "globby": "^16.2.0",
37
+ "globby": "^16.2.1",
38
38
  "jiti": "^2.7.0",
39
- "oxc-parser": "^0.137.0",
39
+ "oxc-parser": "^0.139.0",
40
40
  "regexp.escape": "^2.0.1",
41
41
  "table": "^6.9.0",
42
42
  "zod": "^4.4.3"
@@ -44,17 +44,17 @@
44
44
  "devDependencies": {
45
45
  "@tsconfig/node22": "22.0.5",
46
46
  "@types/babel__code-frame": "7.27.0",
47
- "@types/node": "22.19.21",
47
+ "@types/node": "22.20.1",
48
48
  "@types/regexp.escape": "2.0.0",
49
- "@vitest/coverage-v8": "4.1.9",
49
+ "@vitest/coverage-v8": "4.1.10",
50
50
  "husky": "9.1.7",
51
51
  "lint-staged": "17.0.8",
52
- "oxfmt": "0.56.0",
53
- "oxlint": "1.71.0",
54
- "oxlint-tsgolint": "0.23.0",
55
- "tsdown": "0.22.3",
56
- "typescript": "7.0.1-rc",
57
- "vitest": "4.1.9"
52
+ "oxfmt": "0.58.0",
53
+ "oxlint": "1.73.0",
54
+ "oxlint-tsgolint": "0.24.0",
55
+ "tsdown": "0.22.5",
56
+ "typescript": "7.0.2",
57
+ "vitest": "4.1.10"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">=22"