Skip to content

Commit

Permalink
docs: Update no-irregular-whitespace and fix examples (#17626)
Browse files Browse the repository at this point in the history
Update `no-irregular-whitespace` docs
  • Loading branch information
fasttime committed Oct 9, 2023
1 parent 6b8acfb commit 392305b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
7 changes: 7 additions & 0 deletions docs/src/_data/further_reading_links.json
Expand Up @@ -740,5 +740,12 @@
"logo": "https://v8.dev/favicon.ico",
"title": "RegExp v flag with set notation and properties of strings · V8",
"description": "The new RegExp `v` flag enables `unicodeSets` mode, unlocking support for extended character classes, including Unicode properties of strings, set notation, and improved case-insensitive matching."
},
"https://codepoints.net/U+1680": {
"domain": "codepoints.net",
"url": "https://codepoints.net/U+1680",
"logo": "https://codepoints.net/favicon.ico",
"title": "U+1680 OGHAM SPACE MARK:   – Unicode – Codepoints",
"description": " , codepoint U+1680 OGHAM SPACE MARK in Unicode, is located in the block “Ogham”. It belongs to the Ogham script and is a Space Separator."
}
}
19 changes: 13 additions & 6 deletions docs/src/rules/no-irregular-whitespace.md
Expand Up @@ -4,6 +4,7 @@ rule_type: problem
further_reading:
- https://es5.github.io/#x7.2
- https://web.archive.org/web/20200414142829/http://timelessrepo.com/json-isnt-a-javascript-subset
- https://codepoints.net/U+1680
---


Expand All @@ -16,11 +17,17 @@ A simple fix for this problem could be to rewrite the offending line from scratc

Known issues these spaces cause:

* Ogham Space Mark
* Is a valid token separator, but is rendered as a visible glyph in most typefaces, which may be misleading in source code.
* Mongolian Vowel Separator
* Is no longer considered a space separator since Unicode 6.3. It will result in a syntax error in current parsers when used in place of a regular token separator.
* Line Separator and Paragraph Separator
* These have always been valid whitespace characters and line terminators, but were considered illegal in string literals prior to ECMAScript 2019.
* Zero Width Space
* Is NOT considered a separator for tokens and is often parsed as an `Unexpected token ILLEGAL`
* Is NOT shown in modern browsers making code repository software expected to resolve the visualization
* Line Separator
* Is NOT a valid character within JSON which would cause parse errors
* Is NOT considered a separator for tokens and is often parsed as an `Unexpected token ILLEGAL`.
* Is NOT shown in modern browsers making code repository software expected to resolve the visualization.

In JSON, none of the characters listed as irregular whitespace by this rule may appear outside of a string.

## Rule Details

Expand Down Expand Up @@ -86,7 +93,7 @@ var thing = function /*<NBSP>*/(){
return 'test';
}

var thing = function/*<MVS>*/(){
var thing = function/*<Ogham Space Mark>*/(){
return 'test';
}

Expand Down Expand Up @@ -204,7 +211,7 @@ Examples of additional **correct** code for this rule with the `{ "skipJSXText":
/*eslint-env es6*/

function Thing() {
return <div>text in<NBSP>JSX</div>;
return <div>text inJSX</div>; // <NBSP> before `JSX`
}
```

Expand Down

0 comments on commit 392305b

Please sign in to comment.