i18next-cli 1.69.0 → 1.69.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.
package/dist/cjs/cli.js CHANGED
@@ -37,7 +37,7 @@ const program = new commander.Command();
37
37
  program
38
38
  .name('i18next-cli')
39
39
  .description('A unified, high-performance i18next CLI.')
40
- .version('1.69.0'); // This string is replaced with the actual version at build time by rollup
40
+ .version('1.69.1'); // This string is replaced with the actual version at build time by rollup
41
41
  // new: global config override option
42
42
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
43
43
  program
@@ -1049,9 +1049,26 @@ function findHardcodedStrings(ast, code, config) {
1049
1049
  }
1050
1050
  };
1051
1051
  walk(ast, []); // Run the walk to collect nodes
1052
- // --- PHASE 2: Find line numbers using a tracked search on the raw source code ---
1052
+ // --- PHASE 2: Resolve line numbers from the (already normalised) node spans,
1053
+ // falling back to a tracked text search when a span is unavailable. Searching
1054
+ // the raw source misreports short strings that also occur as a substring
1055
+ // earlier in the file (283: "in" inside "settings.scss"), which in turn breaks
1056
+ // the ignore directives, since those are correlated by line.
1053
1057
  let lastSearchIndex = 0;
1054
1058
  for (const node of nodesToLint) {
1059
+ const start = node?.span?.start;
1060
+ if (typeof start === 'number') {
1061
+ // A JSXText span starts right after the preceding tag, so skip its leading
1062
+ // whitespace to report the line the visible text actually sits on.
1063
+ const offset = node.type === 'JSXText' && typeof node.value === 'string'
1064
+ ? node.value.length - node.value.trimStart().length
1065
+ : 0;
1066
+ const pos = astUtils.lineColumnFromOffset(code, start + offset);
1067
+ if (pos) {
1068
+ issues.push({ text: node.value.trim(), line: pos.line, type: 'hardcoded' });
1069
+ continue;
1070
+ }
1071
+ }
1055
1072
  // For StringLiterals, the `raw` property includes the quotes ("..."), which is
1056
1073
  // much more unique for searching than the plain `value`.
1057
1074
  const searchText = node.raw ?? node.value;
package/dist/esm/cli.js CHANGED
@@ -31,7 +31,7 @@ const program = new Command();
31
31
  program
32
32
  .name('i18next-cli')
33
33
  .description('A unified, high-performance i18next CLI.')
34
- .version('1.69.0'); // This string is replaced with the actual version at build time by rollup
34
+ .version('1.69.1'); // This string is replaced with the actual version at build time by rollup
35
35
  // new: global config override option
36
36
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
37
37
  program
@@ -1047,9 +1047,26 @@ function findHardcodedStrings(ast, code, config) {
1047
1047
  }
1048
1048
  };
1049
1049
  walk(ast, []); // Run the walk to collect nodes
1050
- // --- PHASE 2: Find line numbers using a tracked search on the raw source code ---
1050
+ // --- PHASE 2: Resolve line numbers from the (already normalised) node spans,
1051
+ // falling back to a tracked text search when a span is unavailable. Searching
1052
+ // the raw source misreports short strings that also occur as a substring
1053
+ // earlier in the file (283: "in" inside "settings.scss"), which in turn breaks
1054
+ // the ignore directives, since those are correlated by line.
1051
1055
  let lastSearchIndex = 0;
1052
1056
  for (const node of nodesToLint) {
1057
+ const start = node?.span?.start;
1058
+ if (typeof start === 'number') {
1059
+ // A JSXText span starts right after the preceding tag, so skip its leading
1060
+ // whitespace to report the line the visible text actually sits on.
1061
+ const offset = node.type === 'JSXText' && typeof node.value === 'string'
1062
+ ? node.value.length - node.value.trimStart().length
1063
+ : 0;
1064
+ const pos = lineColumnFromOffset(code, start + offset);
1065
+ if (pos) {
1066
+ issues.push({ text: node.value.trim(), line: pos.line, type: 'hardcoded' });
1067
+ continue;
1068
+ }
1069
+ }
1053
1070
  // For StringLiterals, the `raw` property includes the quotes ("..."), which is
1054
1071
  // much more unique for searching than the plain `value`.
1055
1072
  const searchText = node.raw ?? node.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.69.0",
3
+ "version": "1.69.1",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {