Skip to content

Commit

Permalink
make declaration rule slightly more strict
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Aug 3, 2023
1 parent db6d01c commit d9df38b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/lint/rules/variable-use-def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,15 @@ class Scope {
mayBeShadowed: boolean = false
): void {
if (this.declared(name)) {
if (!mayBeShadowed) {
for (const scope of this.strictScopes) {
if (scope.has(name)) {
this.report({
ruleId: 're-declaration',
message: `${JSON.stringify(name)} is already declared`,
line: nameNode!.location.start.line,
column: nameNode!.location.start.column,
});
return;
}
for (const scope of this.strictScopes) {
if (scope.has(name)) {
this.report({
ruleId: 're-declaration',
message: `${JSON.stringify(name)} is already declared`,
line: nameNode!.location.start.line,
column: nameNode!.location.start.column,
});
return;
}
}
} else {
Expand Down

0 comments on commit d9df38b

Please sign in to comment.