Skip to content

Commit

Permalink
fix: ignore function calls in report-message-format
Browse files Browse the repository at this point in the history
  • Loading branch information
FloEdelmann authored and aladdin-add committed Jul 19, 2023
1 parent 63966cb commit dea161d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rules/report-message-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ module.exports = {

if (suggest && suggest.type === 'ArrayExpression') {
suggest.elements
.flatMap((obj) => obj.properties)
.flatMap((obj) =>
obj.type === 'ObjectExpression' ? obj.properties : []
)
.filter(
(prop) =>
prop.type === 'Property' &&
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/report-message-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ ruleTester.run('report-message-format', rule, {
`,
options: ['^foo$'],
},
{
// Suggestion function
code: `
module.exports = {
create(context) {
context.report({node, suggest: [getSuggestion(node)]});
}
};
`,
options: ['^foo$'],
},
{
// Suggestion message
code: `
Expand Down

0 comments on commit dea161d

Please sign in to comment.