Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle spread in context.report() in require-meta-fixable rule #288

Merged
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
7 changes: 3 additions & 4 deletions lib/rules/require-meta-fixable.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ module.exports = {
node.callee.property.name === 'report' &&
(node.arguments.length > 4 ||
(node.arguments.length === 1 &&
node.arguments[0].type === 'ObjectExpression' &&
node.arguments[0].properties.some(
(prop) => utils.getKeyName(prop) === 'fix'
)))
utils
.evaluateObjectProperties(node.arguments[0], scopeManager)
.some((prop) => utils.getKeyName(prop) === 'fix')))
) {
usesFixFunctions = true;
}
Expand Down
15 changes: 14 additions & 1 deletion tests/lib/rules/require-meta-fixable.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ ruleTester.run('require-meta-fixable', rule, {
`,
options: [{ catchNoFixerButFixableProperty: true }],
},
// Spread.
// Spread in meta.
`
const extra = { 'fixable': 'code' };
module.exports = {
Expand All @@ -199,6 +199,19 @@ ruleTester.run('require-meta-fixable', rule, {
}
};
`,
// Spread in report.
{
code: `
module.exports = {
meta: { fixable: 'code' },
create(context) {
const extra = { fix: foo };
context.report({node, message, ...extra});
}
};
`,
options: [{ catchNoFixerButFixableProperty: true }],
},
],

invalid: [
Expand Down