```js
/*eslint no-use-before-define: "error"*/
-/*eslint-env es6*/
alert(a);
var a = 10;
alert(c);
let c = 1;
}
+
+{
+ class C extends C {}
+}
+
+{
+ class C {
+ static x = "foo";
+ [C.x]() {}
+ }
+}
+
+{
+ const C = class {
+ static x = C;
+ }
+}
+
+{
+ const C = class {
+ static {
+ C.x = "foo";
+ }
+ }
+}
```
Examples of **correct** code for this rule:
```js
/*eslint no-use-before-define: "error"*/
-/*eslint-env es6*/
var a;
a = 10;
let c;
c++;
}
+
+{
+ class C {
+ static x = C;
+ }
+}
+
+{
+ const C = class C {
+ static x = C;
+ }
+}
+
+{
+ const C = class {
+ x = C;
+ }
+}
+
+{
+ const C = class C {
+ static {
+ C.x = "foo";
+ }
+ }
+}
```
## Options
```json
{
- "no-use-before-define": ["error", { "functions": true, "classes": true }]
+ "no-use-before-define": ["error", { "functions": true, "classes": true, "variables": true }]
}
```
```js
/*eslint no-use-before-define: ["error", { "classes": false }]*/
-/*eslint-env es6*/
new A();
class A {
}
+
+{
+ class C extends C {}
+}
+
+{
+ class C extends D {}
+ class D {}
+}
+
+{
+ class C {
+ static x = "foo";
+ [C.x]() {}
+ }
+}
+
+{
+ class C {
+ static {
+ new D();
+ }
+ }
+ class D {}
+}
```
Examples of **correct** code for the `{ "classes": false }` option:
```js
/*eslint no-use-before-define: ["error", { "classes": false }]*/
-/*eslint-env es6*/
function foo() {
return new A();
g();
const g = function() {};
+
+{
+ const C = class {
+ static x = C;
+ }
+}
+
+{
+ const C = class {
+ static x = foo;
+ }
+ const foo = 1;
+}
+
+{
+ class C {
+ static {
+ this.x = foo;
+ }
+ }
+ const foo = 1;
+}
```
Examples of **correct** code for the `{ "variables": false }` option:
const e = function() { return g(); }
const g = function() {}
+
+{
+ const C = class {
+ x = foo;
+ }
+ const foo = 1;
+}
```