Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint: how to spaced-comment exceptions on VSCode folding regions comments

Tags:

eslint

I have spaced-comment in my configuration for ESLint to enforce spacing in comments but cannot determine how to add VSCode's folding regions comments to the exceptions array.

ESLint config:

"spaced-comment": [ "error", "always", {
    "line": {
        "exceptions": ["#region", "#endregion", "region", "endregion"]
    }
}]

Source code

//#region My region
//#endregion My region
or
//region My region
//endregion My region

Message from ESLint:

Expected exception block, space or tab after '//' in comment.

Expectation: ESLint should allow me to use commented VSCode folding regions without forcing me to add a space between // and #region.

like image 616
namgold Avatar asked Oct 31 '25 09:10

namgold


1 Answers

You can solve this by using markers instead of exceptions:

"spaced-comment": [ "error", "always", {
    "line": {
        "markers": ["#region", "#endregion", "region", "endregion"]
    }
}]
like image 85
h0b0 Avatar answered Nov 04 '25 07:11

h0b0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!