Skip to content

Commit

Permalink
loosen check to allow more than just this. (#4391)
Browse files Browse the repository at this point in the history
  • Loading branch information
timmorey committed Apr 11, 2024
1 parent 99e5bce commit acd8c3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 18 additions & 0 deletions packages/eslint-plugin-formatjs/tests/no-invalid-icu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ ruleTester.run(name, rule, {
`this.intl.formatMessage({
defaultMessage: '{count, plural, one {#} other {# more}}',
description: 'asd'
}, {count: 1})`,
`IntlStore.intl.formatMessage({
defaultMessage: '{count, plural, one {#} other {# more}}',
description: 'asd'
}, {count: 1})`,
`intl.formatMessage({
defaultMessage: '{count, plural, one {#} other {# more}}',
Expand Down Expand Up @@ -125,5 +129,19 @@ ruleTester.run(name, rule, {
},
],
},

{
code: `
IntlStore.intl.formatMessage({
defaultMessage: "{aDifferentKey, plur {#} other {# more}}" },
{ count: 1 }
)`,
errors: [
{
messageId: 'icuError',
data: {message: 'Error parsing ICU string: INVALID_ARGUMENT_TYPE'},
},
],
},
],
})
1 change: 0 additions & 1 deletion packages/eslint-plugin-formatjs/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export function isIntlFormatMessageCall(
((node.callee.object.type === 'Identifier' &&
node.callee.object.name === 'intl') ||
(node.callee.object.type === 'MemberExpression' &&
node.callee.object.object.type === 'ThisExpression' &&
node.callee.object.property.type === 'Identifier' &&
node.callee.object.property.name === 'intl')) &&
node.callee.property.type === 'Identifier' &&
Expand Down

0 comments on commit acd8c3f

Please sign in to comment.