no-empty-class: disallow empty character classes in regular expressions

This rule was removed in ESLint v1.0 and replaced by the no-empty-character-class rule.

Empty character classes in regular expressions do not match anything and can result in code that may not work as intended.

var foo = /^abc[]/;

Rule Details

This rule is aimed at highlighting possible typos and unexpected behavior in regular expressions which may arise from the use of empty character classes.

Examples of incorrect code for this rule:

var foo = /^abc[]/;

/^abc[]/.test(foo);

bar.match(/^abc[]/);

Examples of correct code for this rule:

var foo = /^abc/;

var foo = /^abc[a-z]/;

var bar = new RegExp("^abc[]");

Version

This rule was introduced in ESLint 0.0.9 and removed in 1.0.0-rc-1.

Resources

Js中文网,专注分享前端最新技术、大厂面试题、聊点程序员轶事、职场感悟,做前端技术的传播者.

加入前端布道师交流群

扫描二维码回复 加群 学习,与大厂大佬讨论技术.

BAT面试题大全