@tolgee/cli 2.1.1 → 2.1.3
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/config/tolgeerc.js
CHANGED
@@ -21,8 +21,8 @@ function parseConfig(input, configDir) {
|
|
21
21
|
}
|
22
22
|
}
|
23
23
|
if (rc.projectId !== undefined) {
|
24
|
-
|
25
|
-
if (!Number.isInteger(projectId) || projectId <= 0) {
|
24
|
+
rc.projectId = Number(rc.projectId); // Number("") returns 0
|
25
|
+
if (!Number.isInteger(rc.projectId) || rc.projectId <= 0) {
|
26
26
|
throw new Error('Invalid config: projectId should be an integer representing your project Id');
|
27
27
|
}
|
28
28
|
}
|
@@ -7,20 +7,23 @@ function shouldBeIgnored(context, line) {
|
|
7
7
|
}
|
8
8
|
return isIgnore;
|
9
9
|
}
|
10
|
-
function
|
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 =
|
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' });
|