New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "no-irregular-whitespace" rule prevents proper typography in comments outside English. #5368

Closed
tdd opened this Issue Feb 22, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@tdd
Contributor

tdd commented Feb 22, 2016

Hey there,

So I moved to Standard, and am advocating it. It finally got me to jump ship on semicolons, and I use this despite the "space before function decl/expr opening parens" rule, which I find fugly.

So thanks a ton for this cool tool!

But… The no-irregular-whitespace rule is messing with my comments. I'm a trainer among other things, and many of my codebases are for teaching purposes, with my audience being mostly French. In French, double punctuation marks (;, :, ! and ?) take a non-breakable space before them. French quotes (« and ») also use such spaces inside them.

But because of this rule, I can't use such spaces in my comment texts. So either I collapse these spaces, which looks and feels very weird to any French reader, or I use regular spaces, with the virtual guarantee that at least some of these will get wrapped at the beginning of lines in annotated code, looking terrible.

Isn't there a way to relax this rule for comment text? I can't find this relaxing mode in ESLint, but perhaps you know of a way? I get the rule inside code (and btw, it's relaxed within String literals), but inside comments? Who gives a damn?

A PR is ready; just creating this issue so I can ref it in there, as per your guidelines.

tdd added a commit to tdd/eslint that referenced this issue Feb 22, 2016

Fix: Allow irregular whitespace in comments. Fixes eslint#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.

This also updates the docs and tests (all tests passing, checked).
@nzakas

This comment has been minimized.

Show comment
Hide comment
@nzakas

nzakas Feb 23, 2016

Member

If you want to add an option like "skipComments" to the rule, that would be fine.

Member

nzakas commented Feb 23, 2016

If you want to add an option like "skipComments" to the rule, that would be fine.

@tdd

This comment has been minimized.

Show comment
Hide comment
@tdd

tdd Feb 23, 2016

Contributor

Hey @nzakas had not remembered options were available. I'm going for a skipComments option defaulting to true (this seems sensible to me), si that alright?

Contributor

tdd commented Feb 23, 2016

Hey @nzakas had not remembered options were available. I'm going for a skipComments option defaulting to true (this seems sensible to me), si that alright?

@tdd

This comment has been minimized.

Show comment
Hide comment
@tdd

tdd Feb 23, 2016

Contributor

There, added it in my PR (#5367)

Contributor

tdd commented Feb 23, 2016

There, added it in my PR (#5367)

tdd added a commit to tdd/eslint that referenced this issue Feb 24, 2016

Fix: Allow irregular whitespace in comments (fixes eslint#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 eslint#5368.

This also updates the docs and tests (all tests passing, checked).

tdd added a commit to tdd/eslint that referenced this issue Feb 25, 2016

Fix: Allow irregular whitespace in comments (fixes eslint#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 eslint#5368.

This also updates the docs and tests (all tests passing, checked).

ilyavolodin added a commit that referenced this issue Feb 26, 2016

Merge pull request #5367 from tdd/allow-irregular-whitespace-in-comments
Fix: Allow irregular whitespace in comments. Fixes #5368.

@eslint eslint bot locked and limited conversation to collaborators Feb 6, 2018

@eslint eslint bot added the archived due to age label Feb 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.