diff --git a/lib/rules/no-mutating-props.js b/lib/rules/no-mutating-props.js index c4c8bf236..70559026b 100644 --- a/lib/rules/no-mutating-props.js +++ b/lib/rules/no-mutating-props.js @@ -204,16 +204,27 @@ module.exports = { object: node } + let target = node if ( - !node.parent || - node.parent.type !== 'VariableDeclarator' || - node.parent.init !== node + target.parent && + target.parent.type === 'CallExpression' && + target.parent.arguments[0] === target && + target.parent.callee.type === 'Identifier' && + target.parent.callee.name === 'withDefaults' + ) { + target = target.parent + } + + if ( + !target.parent || + target.parent.type !== 'VariableDeclarator' || + target.parent.init !== target ) { return } for (const { node: prop, path } of iteratePatternProperties( - node.parent.id, + target.parent.id, [] )) { verifyPropVariable(prop, path) diff --git a/tests/lib/rules/no-mutating-props.js b/tests/lib/rules/no-mutating-props.js index 210954a8e..2dcc68c5b 100644 --- a/tests/lib/rules/no-mutating-props.js +++ b/tests/lib/rules/no-mutating-props.js @@ -784,6 +784,26 @@ ruleTester.run('no-mutating-props', rule, { line: 6 } ] + }, + { + filename: 'test.vue', + code: ` + + `, + parserOptions: { + parser: require.resolve('@typescript-eslint/parser') + }, + errors: [ + { + message: 'Unexpected mutation of "value" prop.', + line: 6 + } + ] } ] })