Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
variable-name: don't crash on syntax errors (#3292)
Browse files Browse the repository at this point in the history
[bugfix] `variable-name` fixed crash on empty variable name
Fixes: #3288
  • Loading branch information
ajafff authored and adidahiya committed Oct 19, 2017
1 parent d197ee3 commit e406628
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rules/variableNameRule.ts
Expand Up @@ -151,7 +151,7 @@ function walk(ctx: Lint.WalkContext<Options>): void {
return;
}

if (!isCamelCase(text, options) && !isUpperCase(text)) {
if (text.length !== 0 && !isCamelCase(text, options) && !isUpperCase(text)) {
ctx.addFailureAtNode(name, formatFailure());
}
}
Expand Down
5 changes: 5 additions & 0 deletions test/rules/variable-name/allow-pascal-case/test.ts.lint
Expand Up @@ -43,3 +43,8 @@ let optionallyValid_ = "bar";
~~~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE]
let _$httpBackend_ = "leading and trailing";
~~~~~~~~~~~~~~ [variable name must be in lowerCamelCase, PascalCase or UPPER_CASE]

// don't crash on syntax errors

class {}
let {bar:} = foo;

0 comments on commit e406628

Please sign in to comment.