Skip to content

Commit f20c71b

Browse files
committed
remove casting from no-unused-message-ids
1 parent ead0948 commit f20c71b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/rules/no-unused-message-ids.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const rule: Rule.RuleModule = {
5656
contextIdentifiers = getContextIdentifiers(scopeManager, ast);
5757
},
5858

59-
'Program:exit'(ast) {
59+
'Program:exit'() {
6060
if (hasSeenUnknownMessageId || !hasSeenViolationReport) {
6161
/*
6262
Bail out when the rule is likely to have false positives.
@@ -107,21 +107,23 @@ const rule: Rule.RuleModule = {
107107
const values =
108108
messageId.type === 'Literal'
109109
? [messageId]
110-
: findPossibleVariableValues(
111-
messageId as Identifier,
110+
: messageId.type === 'Identifier'
111+
? findPossibleVariableValues(
112+
messageId,
112113
scopeManager,
113-
);
114+
) : [];
114115
if (
115116
values.length === 0 ||
116117
values.some((val) => val.type !== 'Literal')
117118
) {
118119
// When a dynamic messageId is used and we can't detect its value, disable the rule to avoid false positives.
119120
hasSeenUnknownMessageId = true;
120121
}
121-
values.forEach(
122-
(val) =>
123-
'value' in val && messageIdsUsed.add(val.value as string),
124-
);
122+
values
123+
.filter(value => value.type === 'Literal')
124+
.map(value => value.value)
125+
.filter(value => typeof value === 'string')
126+
.forEach(value => messageIdsUsed.add(value));
125127
}
126128
}
127129
},

0 commit comments

Comments
 (0)