Skip to content

[no-unused-vars] false-positive for variables unpacked with spread operator #368

Closed
@fbartho

Description

@fbartho

Repro

module.exports = {
	parser: "@typescript-eslint/parser",
	extends: [
		"plugin:@typescript-eslint/recommended",
		"prettier",
		"prettier/@typescript-eslint",
	],
	plugins: [
		"@typescript-eslint",
		"prettier",
		"react",
		"react-hooks",
		"react-native",
	],
	parserOptions: {
		project: "./tsconfig.json",
		tsconfigRootDir: "./",
		ecmaVersion: 8,
		ecmaFeatures: {
			spread: true,
			modules: true,
		},
		sourceType: "module",
	},
	rules: {
		"prettier/prettier": "error",
		"comma-dangle": ["error", "only-multiline"],

		"@typescript-eslint/camelcase": "off",
		"@typescript-eslint/explicit-function-return-type": "off", // Inferred return types is too handy today
		"@typescript-eslint/explicit-member-accessibility": "off",
		"@typescript-eslint/no-empty-interface": "off",
		"@typescript-eslint/no-explicit-any": "off", // We should try to enable this rule

		// https://reactjs.org/docs/hooks-rules.html
		"react-hooks/rules-of-hooks": "error",
		"react-hooks/exhaustive-deps": "warn",
	},
};
// Note: in my real use case there were defined interfaces, and many more fields
const extractLeftRight = (args: { marginTop: number, marginBottom: number, marginLeft: number, marginRight: number} ) => {
  const { marginTop, marginBottom, ...result } = args;
  return result;
}

Expected Result

No ESLint issues

Actual Result

Warning that marginTop/marginBottom are unused.

Additional Info

Maybe related: #179

#122 comments suggest that we should maybe disable this rule?

Versions

package version
@typescript-eslint/eslint-plugin 1.5.1
@typescript-eslint/parser 1.5.1
TypeScript 3.3.3333
ESLint 5.15.3
node 10.15.3
yarn 1.12.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions