Skip to content

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

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

Closed
fbartho opened this issue Mar 20, 2019 · 1 comment
Closed
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin wontfix This will not be worked on

Comments

@fbartho
Copy link

fbartho commented Mar 20, 2019

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
@fbartho fbartho added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Mar 20, 2019
@bradzacher bradzacher added wontfix This will not be worked on and removed triage Waiting for team members to take a look labels Mar 20, 2019
@bradzacher
Copy link
Member

bradzacher commented Mar 20, 2019

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants