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

Viewed 1294

I have this spaced-comment configuration in ESLint to enforce space in comment but it can not exception on VSCode's folding regions comments.

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.

My expect: ESLint allow me to comment VSCode folding regions and stop force me to add space between // and #region.

1 Answers

You can solve this by using markers instead of exceptions:

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