question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-unused-vars errors with parameters when parameter marked used later

See original GitHub issue

Tell us about your environment

  • ESLint Version: 5.6.1
  • Node Version: v9.4.0
  • npm Version: 5.6.0

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint

Please show your full configuration:

Configuration
{
	"parser": "babel-eslint",
	"plugins": [
		"babel",
		"react"
	],
	"extends": ["plugin:react/recommended"],
	"rules": {
		"no-unused-vars": 1
	}
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

The eslint-plugin-react rule for jsx-uses-vars marks the Wrapped parameter as used. However, no-unused-vars doesn’t update the status of config. The default for no-unused-vars should not warn on parameters before the first used parameter.

import React from 'react';
import foo from 'foo';

export const AccessibilityDecorator = foo((config, Wrapped) => {
	return class t extends React.Component {
		render () {
			return <Wrapped />;
		}
	};
});
eslint .

What did you expect to happen?

No warnings.

What actually happened? Please include the actual, raw output from ESLint.

/Users/.../.../test.js
  4:44  warning  'config' is defined but never used  no-unused-vars

✖ 1 problem (0 errors, 1 warning)

Linked issue: yannickcr/eslint-plugin-react#2009

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Oct 10, 2018

Thanks @webOS101 for digging further! I think I rewrote that code some time ago and this was an oversight on my part.

I’ve relabeled this as a bug, in accordance with your investigation results.

0reactions
webOS101commented, Oct 10, 2018

I confirmed that works. I was able to create a test case that fails and passes with that fix. I still have never figured out how to use a locally linked eslint to test with either global or local installs. I guess I’ll figure it out someday. I’ll create a PR shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-unused-vars - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
ESLint - Configuring "no-unused-vars" for TypeScript
It seems that es lint is not properly configured. Try uninstalling and again adding eslint in your package. · I would be surprised...
Read more >
How to disable "no-unused-vars" in Visual Studio Code (or at ...
One thing that annoys the heck out of me, though, is Visual Studio Code's ESLint plugin marking any unused variable or argument as...
Read more >
Disallow unused variables and arguments ( no-unused-vars ...
This rule leverages the TypeScript compiler's unused variable checks to report. This means that with all rule options set to false , it...
Read more >
Unused function parameters should be removed
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code ... When arguments is used in the function body, no parameter is reported...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found