semi-style

The --fix option on the command line can automatically fix some of the problems reported by this rule.

Enforces location of semicolons.

Generally, semicolons are at the end of lines. However, in semicolon-less style, semicolons are at the beginning of lines. This rule enforces that semicolons are at the configured location.

Rule Details

This rule reports line terminators around semicolons.

This rule has an option.

{
    "semi-style": ["error", "last"],
}

Examples of incorrect code for this rule with "last" option:

/*eslint semi-style: ["error", "last"]*/

foo()
;[1, 2, 3].forEach(bar)

for (
    var i = 0
    ; i < 10
    ; ++i
) {
    foo()
}

class C {
    static {
        foo()
        ;bar()
    }
}

Examples of correct code for this rule with "last" option:

/*eslint semi-style: ["error", "last"]*/

foo();
[1, 2, 3].forEach(bar)

for (
    var i = 0;
    i < 10;
    ++i
) {
    foo()
}

class C {
    static {
        foo();
        bar()
    }
}

Examples of incorrect code for this rule with "first" option:

/*eslint semi-style: ["error", "first"]*/

foo();
[1, 2, 3].forEach(bar)

for (
    var i = 0
    ; i < 10
    ; ++i
) {
    foo()
}

class C {
    static {
        foo();
        bar()
    }
}

Examples of correct code for this rule with "first" option:

/*eslint semi-style: ["error", "first"]*/

foo()
;[1, 2, 3].forEach(bar)

for (
    var i = 0;
    i < 10;
    ++i
) {
    foo()
}

class C {
    static {
        foo()
        ;bar()
    }
}

When Not To Use It

If you don't want to notify the location of semicolons, then it's safe to disable this rule.

Version

This rule was introduced in ESLint 4.0.0-beta.0.

Resources