Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

[bug] fixed no-empty-character-class rule (closes #289) #356

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rules/noEmptyCharacterClassRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class NoEmptyCharacterClassWalker extends Lint.RuleWalker {
}

private validateEmptyCharacterClass(node: ts.LiteralExpression) {
if (!(/^\/([^\\[]|\\.|\[([^\\\]]|\\.)+\])*\/[gim]*$/.test(node.text))) {
if (!(/^\/([^\\[]|\\.|\[([^\\\]]|\\.)+\])*\/[gimu]*$/.test(node.text))) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/rules/noEmptyCharacterClassRuleTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const scripts = {
'var foo = /[[]/;',
'var foo = /[\\[a-z[]]/;',
'var foo = /[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\^\\$\\|]/g;',
'var foo = /\\s*:\\s*/gim;'
'var foo = /\\s*:\\s*/gim;',
'var foo = /\u{1F4A9}/u;'
],
invalid: [
'var foo = /^abc[]/;',
Expand Down