Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rules/no-unused-placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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
14 changes: 13 additions & 1 deletion tests/lib/rules/no-missing-placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,19 @@ ruleTester.run('no-missing-placeholders', rule, {
}
};
`,
errors: [error('bar', 'Literal')],
errors: [
error(
'bar',
'Literal',
// report on `message`
{
line: 6,
endLine: 6,
column: 24,
endColumn: 37,
}
),
],
},
{
code: `
Expand Down
20 changes: 16 additions & 4 deletions tests/lib/rules/no-unused-placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +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') {
function error(unusedKey, extra) {
return {
type,
type: 'Property', // The property in the report's `data` object for the unused placeholder.
message: `The placeholder {{${unusedKey}}} is unused (does not exist in the actual message).`,
...extra,
};
}

Expand Down Expand Up @@ -211,7 +212,18 @@ ruleTester.run('no-unused-placeholders', rule, {
}
};
`,
errors: [error('bar')],
errors: [
error(
'bar',
// report on property in data object
{
line: 7,
endLine: 7,
column: 23,
endColumn: 26,
}
),
],
},
{
// With `create` as variable.
Expand Down Expand Up @@ -241,7 +253,7 @@ ruleTester.run('no-unused-placeholders', rule, {
}
};
`,
errors: [error('bar', 'Identifier')],
errors: [error('bar')],
},
{
code: `
Expand Down