diff --git a/lib/rules/no-unused-vars.js b/lib/rules/no-unused-vars.js index 1ef1c3d..dc4f383 100644 --- a/lib/rules/no-unused-vars.js +++ b/lib/rules/no-unused-vars.js @@ -83,7 +83,9 @@ module.exports = ruleComposer.mapReports( return fixer.remove(parent); case "RestElement": case "Property": - if (!grand) { + + // https://github.com/aladdin-add/eslint-plugin-autofix/issues/48 + if (!(grand && grand.type === "ObjectPattern")) { return null; } diff --git a/tests/lib/rules/no-unused-vars.js b/tests/lib/rules/no-unused-vars.js index 2a00f7a..1c9f2c3 100644 --- a/tests/lib/rules/no-unused-vars.js +++ b/tests/lib/rules/no-unused-vars.js @@ -186,6 +186,12 @@ ruleTester.run("no-unused-vars", rule, { parserOptions: { ecmaVersion: 2018 }, errors: [{ type: "Identifier" }] }, + { + code: "function foo(...args){}", + output: null, + parserOptions: { ecmaVersion: 2018 }, + errors: [{ type: "Identifier" }, { type: "Identifier" }] + }, { code: "let {a} = b", output: "let {} = b",