disallow irregular whitespace (no-irregular-whitespace)

The "extends": "eslint:recommended" property in a configuration file enables this rule.

Invalid or irregular whitespace causes issues with ECMAScript 5 parsers and also makes code harder to debug in a similar nature to mixed tabs and spaces.

Various whitespace characters can be inputted by programmers by mistake for example from copying or keyboard shortcuts. Pressing Alt + Space on macOS adds in a non breaking space character for example.

Known issues these spaces cause:

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

Rule Details

This rule is aimed at catching invalid whitespace that is not a normal tab and space. Some of these characters may cause issues in modern browsers and others will be a debugging issue to spot.

This rule disallows the following characters except where the options allow: