@tolgee/cli 2.1.1 → 2.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.
@@ -7,20 +7,23 @@ function shouldBeIgnored(context, line) {
7
7
  }
8
8
  return isIgnore;
9
9
  }
10
- function keyInfoFromComment(context, line) {
10
+ function commentKeyInfoOnLine(context, line) {
11
11
  const commentAtLine = context.commentMap.get(line - 1);
12
12
  const isKeyInfo = commentAtLine?.type === 'MAGIC_COMMENT' && commentAtLine.kind === 'key';
13
13
  if (isKeyInfo) {
14
14
  context.unusedComments.delete(commentAtLine);
15
- return {
16
- keyName: commentAtLine.keyName,
17
- namespace: commentAtLine.namespace ?? context.options.defaultNamespace,
18
- defaultValue: commentAtLine.defaultValue,
19
- line: commentAtLine.line,
20
- };
15
+ return keyInfoFromComment(context, commentAtLine);
21
16
  }
22
17
  return undefined;
23
18
  }
19
+ function keyInfoFromComment(context, info) {
20
+ return {
21
+ keyName: info.keyName,
22
+ namespace: info.namespace ?? context.options.defaultNamespace,
23
+ defaultValue: info.defaultValue,
24
+ line: info.line,
25
+ };
26
+ }
24
27
  function reportKey(context, node, contextNs) {
25
28
  const { strictNamespace, defaultNamespace } = context.options;
26
29
  const { keys, warnings } = context;
@@ -28,7 +31,7 @@ function reportKey(context, node, contextNs) {
28
31
  if (shouldBeIgnored(context, line)) {
29
32
  return { keys, warnings };
30
33
  }
31
- const overrideInfo = keyInfoFromComment(context, node.line);
34
+ const overrideInfo = commentKeyInfoOnLine(context, node.line);
32
35
  if (overrideInfo) {
33
36
  // key info is overriten by comment
34
37
  keys.push(overrideInfo);
@@ -146,12 +149,7 @@ export function generateReport({ node, contextNs, comments, options, }) {
146
149
  context.warnings.push({ line: value.line, warning: value.kind });
147
150
  }
148
151
  else if (value.type === 'MAGIC_COMMENT' && value.kind === 'key') {
149
- context.keys.push({
150
- keyName: value.keyName,
151
- namespace: value.namespace,
152
- defaultValue: value.defaultValue,
153
- line: value.line,
154
- });
152
+ context.keys.push(keyInfoFromComment(context, value));
155
153
  }
156
154
  else if (value.type === 'MAGIC_COMMENT' && value.kind === 'ignore') {
157
155
  context.warnings.push({ line: value.line, warning: 'W_UNUSED_IGNORE' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolgee/cli",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "type": "module",
5
5
  "description": "A tool to interact with the Tolgee Platform through CLI",
6
6
  "repository": {