ESLint v8.x reached end-of-life on 2024-10-05 and is no longer maintained. Upgrade or consider long-term support options
Versions

no-space-before-semi

Disallows spaces before semicolons.

JavaScript allows for placing unnecessary spaces between an expression and the closing semicolon.

Space issues can also cause code to look inconsistent and harder to read.

var thing = function () {
  var test = 12 ;
}  ;

Rule Details

This rule prevents the use of spaces before a semicolon in expressions.

Examples of incorrect code for this rule:

var foo = "bar" ;

var foo = function() {} ;

var foo = function() {
} ;

var foo = 1 + 2 ;

Examples of correct code for this rule:

;(function(){}());

var foo = "bar";

Version

This rule was introduced in ESLint v0.4.3 and removed in v1.0.0-rc-1.

Change Language