# no-irregular-whitespace

Disallow weird/irregular whitespace.

ECMAScript allows a wide selection of unicode whitespace, they are however known to cause issues with various parsers, therefore they should never be used.

A lot of the whitespace is invisible, therefore is hard to detect, it may have been inserted by accident.

Whitespace such as line separator causes issues since line separators are not valid JSON which may cause many issues.

This rule disallows the following whitespace:

\u000B - Line Tabulation (\v) - <VT>
\u000C - Form Feed (\f) - <FF>
\u00A0 - No-Break Space - <NBSP>
\u0085 - Next Line
\u1680 - Ogham Space Mark
\u180E - Mongolian Vowel Separator - <MVS>
\ufeff - Zero Width No-Break Space - <BOM>
\u2000 - En Quad
\u2001 - Em Quad
\u2002 - En Space - <ENSP>
\u2003 - Em Space - <EMSP>
\u2004 - Tree-Per-Em
\u2005 - Four-Per-Em
\u2006 - Six-Per-Em
\u2007 - Figure Space
\u2008 - Punctuation Space - <PUNCSP>
\u2009 - Thin Space
\u200A - Hair Space
\u200B - Zero Width Space - <ZWSP>
\u2028 - Line Separator
\u2029 - Paragraph Separator
\u202F - Narrow No-Break Space
\u205f - Medium Mathematical Space
\u3000 - Ideographic Space

# Config

Name Type Description
skipStrings bool Whether to allow any whitespace in string literals (true by default)
skipComments bool Whether to allow any whitespace in comments (false by default)
skipRegex bool Whether to allow any whitespace in regular expressions (false by default)
skipTemplates bool Whether to allow any whitespace in template literals (false by default)
More incorrect examples
var any  = 'thing';
var any  = 'thing';
var any   = 'thing';
var any  = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
var any 
 = 'thing';
var any 
 = 'thing';
var any   = 'thing';
var any   = 'thing';
var any   = 'thing';
More correct examples
'\u{000B}';
'\u{000C}';
'\u{0085}';
'\u{00A0}';
'\u{180E}';
'\u{feff}';
'\u{2000}';
'\u{2001}';
'\u{2002}';
'\u{2003}';
'\u{2004}';
'\u{2005}';
'\u{2006}';
'\u{2007}';
'\u{2008}';
'\u{2009}';
'\u{200A}';
'\u{200B}';
'\u{2028}';
'\u{2029}';
'\u{202F}';
'\u{205f}';
'\u{3000}';
'';
'';
'
';
' ';
'᠎';
'';
' ';

Source (opens new window)

Last Updated: 11/18/2020, 9:36:33 PM