Skip to content

Commit

Permalink
fix: reporting location for no-unused-placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Aug 4, 2022
1 parent e2f3deb commit 909186e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-unused-placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module.exports = {
const key = utils.getKeyName(prop);
if (!placeholdersInMessage.has(key)) {
context.report({
node: message,
node: prop,
messageId: 'placeholderUnused',
data: { unusedKey: key },
});
Expand Down
9 changes: 6 additions & 3 deletions tests/lib/rules/no-unused-placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ const RuleTester = require('eslint').RuleTester;
* @param {string} unusedKey The placeholder that is unused
* @returns {object} An expected error
*/
function error(unusedKey, type = 'Literal') {
return { type, message: `The placeholder {{${unusedKey}}} is unused.` };
function error(unusedKey) {
return {
type: 'Property', // The property in the report's `data` object for the unused placeholder.
message: `The placeholder {{${unusedKey}}} is unused.`,
};
}

// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -238,7 +241,7 @@ ruleTester.run('no-unused-placeholders', rule, {
}
};
`,
errors: [error('bar', 'Identifier')],
errors: [error('bar')],
},
{
code: `
Expand Down

0 comments on commit 909186e

Please sign in to comment.