]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/no-extra-semi.md
import 8.3.0 source
[pve-eslint.git] / eslint / docs / rules / no-extra-semi.md
1 # disallow unnecessary semicolons (no-extra-semi)
2
3 Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.
4
5 ## Rule Details
6
7 This rule disallows unnecessary semicolons.
8
9 Examples of **incorrect** code for this rule:
10
11 ```js
12 /*eslint no-extra-semi: "error"*/
13
14 var x = 5;;
15
16 function foo() {
17 // code
18 };
19
20 class C {
21 field;;
22
23 method() {
24 // code
25 };
26
27 static {
28 // code
29 };
30 };
31 ```
32
33 Examples of **correct** code for this rule:
34
35 ```js
36 /*eslint no-extra-semi: "error"*/
37
38 var x = 5;
39
40 function foo() {
41 // code
42 }
43
44 var bar = function() {
45 // code
46 };
47
48 class C {
49 field;
50
51 method() {
52 // code
53 }
54
55 static {
56 // code
57 }
58 }
59 ```
60
61 ## When Not To Use It
62
63 If you intentionally use extra semicolons then you can disable this rule.
64
65 ## Related Rules
66
67 * [semi](semi.md)
68 * [semi-spacing](semi-spacing.md)