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

variable-name: don't crash on syntax errors #3292

Merged
merged 1 commit into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;