]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-space-before-semi.md
5e5052099bc81442a70083e24e0c37e6b896670a
[pve-eslint.git] / eslint / docs / src / rules / no-space-before-semi.md
1 ---
2 title: no-space-before-semi
3 layout: doc
4
5 related_rules:
6 - semi
7 - no-extra-semi
8 ---
9
10 Disallows spaces before semicolons.
11
12 (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [semi-spacing](semi-spacing) rule.
13
14 JavaScript allows for placing unnecessary spaces between an expression and the closing semicolon.
15
16 Space issues can also cause code to look inconsistent and harder to read.
17
18 ```js
19 var thing = function () {
20 var test = 12 ;
21 } ;
22 ```
23
24 ## Rule Details
25
26 This rule prevents the use of spaces before a semicolon in expressions.
27
28 Examples of **incorrect** code for this rule:
29
30 ::: incorrect
31
32 ```js
33 var foo = "bar" ;
34
35 var foo = function() {} ;
36
37 var foo = function() {
38 } ;
39
40 var foo = 1 + 2 ;
41 ```
42
43 :::
44
45 Examples of **correct** code for this rule:
46
47 ::: correct
48
49 ```js
50 ;(function(){}());
51
52 var foo = "bar";
53 ```
54
55 :::