From f38c6c8b59390707c4538b596c6b55744abee270 Mon Sep 17 00:00:00 2001 From: Anton Lobashev Date: Wed, 3 Oct 2018 15:37:38 +0400 Subject: [PATCH] [bug] fixed no-empty-character-class rule (closes #289) --- src/rules/noEmptyCharacterClassRule.ts | 2 +- src/test/rules/noEmptyCharacterClassRuleTests.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rules/noEmptyCharacterClassRule.ts b/src/rules/noEmptyCharacterClassRule.ts index 6985987..5a8754b 100644 --- a/src/rules/noEmptyCharacterClassRule.ts +++ b/src/rules/noEmptyCharacterClassRule.ts @@ -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)); } } diff --git a/src/test/rules/noEmptyCharacterClassRuleTests.ts b/src/test/rules/noEmptyCharacterClassRuleTests.ts index 8ad6161..68ce377 100644 --- a/src/test/rules/noEmptyCharacterClassRuleTests.ts +++ b/src/test/rules/noEmptyCharacterClassRuleTests.ts @@ -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[]/;',