Please sign in to comment.
Fix: Allow irregular whitespace in comments (fixes #5368)
The `no-irregular-whitespace` rule is unduly limiting "irregular" whitespace to string literals alone (despite a comment at the top of the file indicating otherwise). This prevents non-English speakers from commenting their code in their own language. For instance, French language mandates (half-width, but hey) unbreakable whitespace before two-part punctuation marks (in effect: `;`, `:`, `?` and `!`), and this rule prevents them from doing so. This commit fixes that. Technically, it required choosing a different parsing path as the existing use cases: apparently the rule infrastructure only triggers `'Program`' entities after any potential top-of-file comment block (or perhaps Esprima does this), and because of the way the `no-irregular-whitespace` rule is originally written, getting an initial `LineComment` or `BlockComment` node before the main `Program` node prevents us from then stripping these errors from the report. So we accrue comment nodes until `Program:exit`, then use them for error stripping at that final moment, right before contributing to the report. A `skipComments` option is introduced, boolean, defaulting to `true`, that gives users control over whether comments are, indeed, not checked for irregular whitespace. This was suggested by @nzakas when reviewing #5368. This also updates the docs and tests (all tests passing, checked).
- Loading branch information...
Showing with 308 additions and 11 deletions.
Oops, something went wrong.