Skip to content

Commit

Permalink
[bug] fixed no-empty-character-class rule (closes buzinas#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulthreads committed Oct 3, 2018
1 parent ba7e332 commit f38c6c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
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

0 comments on commit f38c6c8

Please sign in to comment.