]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-extra-semi.js
2 * @fileoverview Tests for no-extra-semi rule.
3 * @author Nicholas C. Zakas
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/no-extra-semi"),
13 { RuleTester
} = require("../../../lib/rule-tester");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 const ruleTester
= new RuleTester();
21 ruleTester
.run("no-extra-semi", rule
, {
29 { code
: "for(a of b);", parserOptions
: { ecmaVersion
: 6 } },
36 { code
: "class A { }", parserOptions
: { ecmaVersion
: 6 } },
37 { code
: "var A = class { };", parserOptions
: { ecmaVersion
: 6 } },
38 { code
: "class A { a() { this; } }", parserOptions
: { ecmaVersion
: 6 } },
39 { code
: "var A = class { a() { this; } };", parserOptions
: { ecmaVersion
: 6 } },
40 { code
: "class A { } a;", parserOptions
: { ecmaVersion
: 6 } },
41 { code
: "class A { field; }", parserOptions
: { ecmaVersion
: 2022 } },
42 { code
: "class A { field = 0; }", parserOptions
: { ecmaVersion
: 2022 } },
43 { code
: "class A { static { foo; } }", parserOptions
: { ecmaVersion
: 2022 } },
46 { code
: "export const x = 42;", parserOptions
: { ecmaVersion
: 6, sourceType
: "module" } },
47 { code
: "export default 42;", parserOptions
: { ecmaVersion
: 6, sourceType
: "module" } }
53 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
56 code
: "function foo(){};",
57 output
: "function foo(){}",
58 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
63 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
68 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
71 code
: "do;while(0);;",
72 output
: "do;while(0);",
73 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
76 code
: "for(a in b);;",
77 output
: "for(a in b);",
78 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
81 code
: "for(a of b);;",
82 output
: "for(a of b);",
83 parserOptions
: { ecmaVersion
: 6 },
84 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
89 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
92 code
: "if(true){} else;;",
93 output
: "if(true){} else;",
94 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
97 code
: "if(true){;} else {;}",
98 output
: "if(true){} else {}",
99 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }, { messageId
: "unexpected", type
: "EmptyStatement" }]
104 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
108 output
: "with(foo);",
109 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
112 code
: "with(foo){;}",
113 output
: "with(foo){}",
114 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
117 code
: "class A { static { ; } }",
118 output
: "class A { static { } }",
119 parserOptions
: { ecmaVersion
: 2022 },
120 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement", column
: 20 }]
123 code
: "class A { static { a;; } }",
124 output
: "class A { static { a; } }",
125 parserOptions
: { ecmaVersion
: 2022 },
126 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement", column
: 22 }]
131 code
: "class A { ; }",
132 output
: "class A { }",
133 parserOptions
: { ecmaVersion
: 6 },
134 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 11 }]
137 code
: "class A { /*a*/; }",
138 output
: "class A { /*a*/ }",
139 parserOptions
: { ecmaVersion
: 6 },
140 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 16 }]
143 code
: "class A { ; a() {} }",
144 output
: "class A { a() {} }",
145 parserOptions
: { ecmaVersion
: 6 },
146 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 11 }]
149 code
: "class A { a() {}; }",
150 output
: "class A { a() {} }",
151 parserOptions
: { ecmaVersion
: 6 },
152 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 17 }]
155 code
: "class A { a() {}; b() {} }",
156 output
: "class A { a() {} b() {} }",
157 parserOptions
: { ecmaVersion
: 6 },
158 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 17 }]
161 code
: "class A {; a() {}; b() {}; }",
162 output
: "class A { a() {} b() {} }",
163 parserOptions
: { ecmaVersion
: 6 },
165 { messageId
: "unexpected", type
: "Punctuator", column
: 10 },
166 { messageId
: "unexpected", type
: "Punctuator", column
: 18 },
167 { messageId
: "unexpected", type
: "Punctuator", column
: 26 }
171 code
: "class A { a() {}; get b() {} }",
172 output
: "class A { a() {} get b() {} }",
173 parserOptions
: { ecmaVersion
: 6 },
174 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 17 }]
177 code
: "class A { field;; }",
178 output
: "class A { field; }",
179 parserOptions
: { ecmaVersion
: 2022 },
180 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 17 }]
183 code
: "class A { static {}; }",
184 output
: "class A { static {} }",
185 parserOptions
: { ecmaVersion
: 2022 },
186 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 20 }]
189 code
: "class A { static { a; }; foo(){} }",
190 output
: "class A { static { a; } foo(){} }",
191 parserOptions
: { ecmaVersion
: 2022 },
192 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 24 }]