Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Docs: clarify variables option in no-use-before-define (fixes #12986) (
…#13017)

* Docs: added fn decl example and details for variables option

* Docs: added more example for variables options

* Chore: refactore variables example

* Chore: removed extra EOF line

* Chore: update default for nofunc no-use-before-define

Co-Authored-By: Kai Cataldo <kai@kaicataldo.com>

Co-authored-by: Kai Cataldo <kai@kaicataldo.com>
  • Loading branch information
anikethsaha and kaicataldo committed Mar 23, 2020
1 parent aef9488 commit 3f7c9bf
Showing 1 changed file with 17 additions and 2 deletions.
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() {}
```

0 comments on commit 3f7c9bf

Please sign in to comment.