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 variables option in no-use-before-define (fixes #12986) #13017

Merged
merged 6 commits into from Mar 23, 2020
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
19 changes: 17 additions & 2 deletions docs/rules/no-use-before-define.md
Expand Up @@ -82,7 +82,7 @@ function g() {
Default is `true`.

This rule accepts `"nofunc"` string as an option.
`"nofunc"` is the same as `{ "functions": false, "classes": true }`.
`"nofunc"` is the same as `{ "functions": false, "classes": true, "variables": true }`.

### functions

Expand All @@ -95,6 +95,8 @@ f();
function f() {}
```

This option allows references to function declarations. For function expressions and arrow functions, please see the [`variables`](#variables) option.

### classes

Examples of **incorrect** code for the `{ "classes": false }` option:
Expand Down Expand Up @@ -131,6 +133,12 @@ Examples of **incorrect** code for the `{ "variables": false }` option:

console.log(foo);
var foo = 1;

f();
const f = () => {};

g();
const g = function() {};
```

Examples of **correct** code for the `{ "variables": false }` option:
Expand All @@ -141,6 +149,13 @@ Examples of **correct** code for the `{ "variables": false }` option:
function baz() {
console.log(foo);
}

var foo = 1;

const a = () => f();
function b() { return f(); }
const c = function() { return f(); }
const f = () => {};

const e = function() { return g(); }
const g = function() {}
```