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

Docs: Clarify the no-unused-vars docs #11195

Merged
merged 2 commits into from Dec 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/rules/no-unused-vars.md
Expand Up @@ -4,16 +4,16 @@ Variables that are declared and not used anywhere in the code are most likely an

## Rule Details

This rule is aimed at eliminating unused variables, functions, and parameters of functions.
This rule is aimed at eliminating unused variables, functions, and function parameters.

A variable is considered to be used if any of the following are true:
A variable `foo` is considered to be used if any of the following are true:

* It represents a function that is called (`doSomething()`)
* It is read (`var y = x`)
* It is passed into a function as an argument (`doSomething(x)`)
* It is called (`foo()`) or constructed (`new foo()`)
* It is read (`var bar = foo`)
* It is passed into a function as an argument (`doSomething(foo)`)
* It is read inside of a function that is passed to another function (`doSomething(function() { foo(); })`)

A variable is *not* considered to be used if it is only ever assigned to (`var x = 5`) or declared.
A variable is *not* considered to be used if it is only ever declared (`var foo = 5`) or assigned to (`foo = 7`).

Examples of **incorrect** code for this rule:

Expand Down