]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-extra-semi.js
913290aaf85718b0272326bc01539b9f0abd3e38
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 } },
43 { code
: "export const x = 42;", parserOptions
: { ecmaVersion
: 6, sourceType
: "module" } },
44 { code
: "export default 42;", parserOptions
: { ecmaVersion
: 6, sourceType
: "module" } }
50 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
53 code
: "function foo(){};",
54 output
: "function foo(){}",
55 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
60 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
65 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
68 code
: "do;while(0);;",
69 output
: "do;while(0);",
70 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
73 code
: "for(a in b);;",
74 output
: "for(a in b);",
75 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
78 code
: "for(a of b);;",
79 output
: "for(a of b);",
80 parserOptions
: { ecmaVersion
: 6 },
81 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
86 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
89 code
: "if(true){} else;;",
90 output
: "if(true){} else;",
91 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
94 code
: "if(true){;} else {;}",
95 output
: "if(true){} else {}",
96 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }, { messageId
: "unexpected", type
: "EmptyStatement" }]
101 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
105 output
: "with(foo);",
106 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
109 code
: "with(foo){;}",
110 output
: "with(foo){}",
111 errors
: [{ messageId
: "unexpected", type
: "EmptyStatement" }]
116 code
: "class A { ; }",
117 output
: "class A { }",
118 parserOptions
: { ecmaVersion
: 6 },
119 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 11 }]
122 code
: "class A { /*a*/; }",
123 output
: "class A { /*a*/ }",
124 parserOptions
: { ecmaVersion
: 6 },
125 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 16 }]
128 code
: "class A { ; a() {} }",
129 output
: "class A { a() {} }",
130 parserOptions
: { ecmaVersion
: 6 },
131 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 11 }]
134 code
: "class A { a() {}; }",
135 output
: "class A { a() {} }",
136 parserOptions
: { ecmaVersion
: 6 },
137 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 17 }]
140 code
: "class A { a() {}; b() {} }",
141 output
: "class A { a() {} b() {} }",
142 parserOptions
: { ecmaVersion
: 6 },
143 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 17 }]
146 code
: "class A {; a() {}; b() {}; }",
147 output
: "class A { a() {} b() {} }",
148 parserOptions
: { ecmaVersion
: 6 },
150 { messageId
: "unexpected", type
: "Punctuator", column
: 10 },
151 { messageId
: "unexpected", type
: "Punctuator", column
: 18 },
152 { messageId
: "unexpected", type
: "Punctuator", column
: 26 }
156 code
: "class A { a() {}; get b() {} }",
157 output
: "class A { a() {} get b() {} }",
158 parserOptions
: { ecmaVersion
: 6 },
159 errors
: [{ messageId
: "unexpected", type
: "Punctuator", column
: 17 }]