/
no-block-scoped-variables.js
43 lines (41 loc) · 1.22 KB
/
no-block-scoped-variables.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const RuleTester = require("../../tester")
const rule = require("../../../lib/rules/no-block-scoped-variables.js")
new RuleTester().run("no-block-scoped-variables", rule, {
valid: [
"var a = 1",
"function f(a) {}",
"function f(a = 1) {}",
"try {} catch (e) {}",
],
invalid: [
{
code: "const a = 1",
errors: ["ES2015 block-scoped variables are forbidden."],
},
{
code: "let a = 1",
errors: ["ES2015 block-scoped variables are forbidden."],
},
{
code: "{ const a = 1 }",
errors: ["ES2015 block-scoped variables are forbidden."],
},
{
code: "{ let a = 1 }",
errors: ["ES2015 block-scoped variables are forbidden."],
},
{
code: "function wrap() { const a = 1 }",
errors: ["ES2015 block-scoped variables are forbidden."],
},
{
code: "function wrap() { let a = 1 }",
errors: ["ES2015 block-scoped variables are forbidden."],
},
],
})