no-irregular-whitespace

禁止不规则空格

配置文件 中的 "extends": "eslint:recommended" 属性启用了该规则

无效或不规则的空格会导致 ECMAScript 5 解析器出现问题,并且还会使代码更难调试,类似于混合制表符和空格。

程序员可能会错误地输入各种空白字符,例如通过复制或键盘快捷键。例如,在 macOS 上按 Alt + Space 会添加一个不间断的空格字符。

解决此问题的一个简单方法是从头开始重写有问题的行。这也可能是文本编辑器引入的问题:如果重写行不能解决问题,请尝试使用不同的编辑器。

RXCmXB46Ja2TqpbJdjMhUjF9x1DtIKdSYMXOOieNl6v/825t7316vZaFaeSQYpd1

    Vb+ZFt2WcJu93IbgZf7jfKtipP4xoU1L0diwLjYO2mnOKT5khTKpcTHf7S1ig7VUH/P9eYIvWnpFGReMNRhYMHI5NwZ1NmEbcHq7gD7pg6+IZZ/9tuPOUxbZ5ymqs3Ey3uE2oASOwqBID5HWOdlIhjEODM0qBedh9WpskU5gS41nN1Tu3XZsgPsSKrEYE3jqaenQV1JOoMFcmOyaoD5uqcWseTaBbbpxtGJcAZcQRoRDBxI10YB7TWuTZUFzooSVRMp8YlmmxEY3+63a+vK4kZeeAn9M+OrB9m7ntoXh7bHxdoAJY5Ff6/vIVVhweFO03eoOsCISgNOEkHVP+4UgDnl5pREjm2xBV8blFzBj9xtKM/We0o4H4ar30C5CMXPAzllFadlz+aXvsQDLWvs/SLCuM0o/3eGk5TzI4MuxDXXpJhLJG77ZyBBn2L7jb9uO

规则详情

jwx0CINFSzDNiIDL6xeavF1ZFUxhM6/KgSdKx8dHnvGJJnxZqP35zUQbr9ef98eCc206zasVGyGao88722p4mIWycY3YSmbEDVqzyr16cneZUByoMMsXpaUuOG3w7k6d1/TF7H/x58ds+qqKMCrDXR0QX0iThFUKhZ4aQCqa6qMhuUzv7PkdnU7ggSxe9zitNU0/1YCMk7cXBJitInJVlkHMBOjXKv/y/LIT52YIDhRIaBC6xAVkQeTeX2ll5V76

FPAu1Gyddwm2lH16MAM1TsSSGzzJhKwNGkSJtCacbvwxUfAsGEjehUhdWlUOX56VQ73gF5t7TATPn0DHMMLbyg==

\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 - Three-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

选项

lagSbevXYrfbXbjPe46SgW22L86IpTVwBxymJxZJw7vmhVCyyU6J1rOoAu1ucQnr

    yjkXr+BiapLOCcq+ao2bOx4Ebk7AZODc/9KRMs1eGixj+qs1vOIAUjffHvZ5ncoq53UOyXaV6UESNmbr4mVuye+aS3rW4GffqHhm7pcZLGN4gwYDPahQFHXodBimSFq9iqrodfv9L/kvys/p6C6015IXd2dCUpWUz6mj7mnec1wzajBpqo6hliDTAa29sgQ3quSgmhFWITJd9vkcDGHd8JSsSw6sUmme2xV212LM42bK1FvfrWmyjsKiW5cxyJBOrGJuEyHPLksKmAna6xqLApbp6Ozv3tIa6OBtY1lqr+hraBjn2zp7780Hd89scCiDNgy2Go+iziVXpYbwJChJmPfTxPLV+SbQZM2WED8SFJxlGmflQD6hO++cAWWHto594yXXiilxu4mXKoiXHNlc3QzpMvtNqY4UZw96JlIwFjoT056u5fmTX91Ycr/Co5ZQfwFdP7Df1a/Auqut0FtDWYWqffEjPIX6sTKVMNrnpoA=

skipStrings

vGUxWBhIHkIwFaCplge828HXQWXBGZyjVNoKgCfAb4kcdK9aXJEZwNnJLfalH0PNG0Z2AJDNhlsYJlm65ISUi21bovJYsRcVEYLn78YG4dUfjPTD8JOC1afY9qjikOzA

/*eslint no-irregular-whitespace: "error"*/

function thing() /*<NBSP>*/{
    return 'test';
}

function thing( /*<NBSP>*/){
    return 'test';
}

function thing /*<NBSP>*/(){
    return 'test';
}

function thing᠎/*<MVS>*/(){
    return 'test';
}

function thing() {
    return 'test'; /*<ENSP>*/
}

function thing() {
    return 'test'; /*<NBSP>*/
}

function thing() {
    // Description <NBSP>: some descriptive text
}

/*
Description <NBSP>: some descriptive text
*/

function thing() {
    return / <NBSP>regexp/;
}

/*eslint-env es6*/
function thing() {
    return `template <NBSP>string`;
}

vGUxWBhIHkIwFaCplge828HXQWXBGZyjVNoKgCfAb4kcdK9aXJEZwNnJLfalH0PNG0Z2AJDNhlsYJlm65ISUi5Rn6mbmD9crpAlyVqmCZ44ovpfbwdbxE2abCp8iaKbw

/*eslint no-irregular-whitespace: "error"*/

function thing() {
    return ' <NBSP>thing';
}

function thing() {
    return '​<ZWSP>thing';
}

function thing() {
    return 'th <NBSP>ing';
}

skipComments

qVCMgjR5tKUNSBmRY5fDOVFUXKd8DzqCoYEECGFl8IBg7XqdtJHHZmS2x/p2aUyvzDtu7KVyL7zF4/rUxK/WGeFuzE6ZGSByT/MObDaJRQHhYt4VJBYU9WUHYIgBkLxP

/*eslint no-irregular-whitespace: ["error", { "skipComments": true }]*/

function thing() {
    // Description <NBSP>: some descriptive text
}

/*
Description <NBSP>: some descriptive text
*/

skipRegExps

qVCMgjR5tKUNSBmRY5fDOcmQ1JZMpHJ6MpxVlSH4Xfsf24I5CuU3CaJxjdF7FccaYIK6fvbCJn3VRVkimUguGhC1UJ3JsSQiycR/+QbhE/pUavNr4xdckjHhMKRppe2K

/*eslint no-irregular-whitespace: ["error", { "skipRegExps": true }]*/

function thing() {
    return / <NBSP>regexp/;
}

skipTemplates

qVCMgjR5tKUNSBmRY5fDOVJGKCHFeFyxvm3cXmg4GhZpVdUE4BQaiG7nH5iOqMMHXwGChsY1V4KeLcrzAS9NZZKdLWxJsJ/RG+vOO1e3rh4hsZ4odxWMQTArR1l1Dc84

/*eslint no-irregular-whitespace: ["error", { "skipTemplates": true }]*/
/*eslint-env es6*/

function thing() {
    return `template <NBSP>string`;
}

何时不使用

CDs2yT9NyaDJVjjIW3S4pfjaSlSVZ6TrPiyZY6XcXi1fXC6/N35L6LV2Jss0FvbLYWqrUqn+IvhLQfU3pkoR5NCbS0hubcKq9XN6YkUSfQWSc1dyCSswuYUHMlrsxrz7