Skip to content
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

no-unused-state rule doesn't handle dynamic keys #1361

Closed
EvHaus opened this issue Aug 11, 2017 · 3 comments
Closed

no-unused-state rule doesn't handle dynamic keys #1361

EvHaus opened this issue Aug 11, 2017 · 3 comments

Comments

@EvHaus
Copy link
Collaborator

EvHaus commented Aug 11, 2017

@wbinnssmith The following code:

_handleUpdate = (stateName, active) => {
	this.setState({[stateName]: active});
};

Gives out an Unused state field: 'stateName' error from the no-unused-state rule.

I think it's probably best to have no-unused-state rule ignore dynamic object keys since it will be too difficult to detect whether or not they're really being used. But at the very least, it shouldn't use the variable name as the key to look for.

@EvHaus EvHaus added the bug label Aug 11, 2017
@ljharb
Copy link
Member

ljharb commented Aug 11, 2017

I agree that this is a bug - it should entirely ignore computed property keys when the contents aren't a string literal.

@jseminck
Copy link
Contributor

@EvHaus it seems like this can be closed? (linked PR is merged)

@EvHaus
Copy link
Collaborator Author

EvHaus commented Nov 16, 2017

@jseminck Indeed. Closing!

@EvHaus EvHaus closed this as completed Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants