Skip to content

Commit

Permalink
Nit: UpperCamelCase enum in noInvalidThisRule (palantir#4376)
Browse files Browse the repository at this point in the history
  • Loading branch information
amacleay authored and ericanderson committed Dec 12, 2018
1 parent ac70fab commit 412604b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/rules/noInvalidThisRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ export class Rule extends Lint.Rules.AbstractRule {
}
}

const enum parentType {
const enum ParentType {
None,
Class,
ClassMethod,
BoundRegularFunction,
UnboundRegularFunction,
}
const thisAllowedParents = new Set([parentType.ClassMethod, parentType.BoundRegularFunction]);
const thisAllowedParents = new Set([ParentType.ClassMethod, ParentType.BoundRegularFunction]);

function walk(ctx: Lint.WalkContext<boolean>): void {
const { sourceFile, options: checkFuncInMethod } = ctx;

let currentParent: parentType = parentType.None;
let currentParent: ParentType = ParentType.None;
let inClass = false;

ts.forEachChild(sourceFile, function cb(node: ts.Node) {
Expand All @@ -83,7 +83,7 @@ function walk(ctx: Lint.WalkContext<boolean>): void {
case ts.SyntaxKind.ClassDeclaration:
case ts.SyntaxKind.ClassExpression:
inClass = true;
currentParent = parentType.Class;
currentParent = ParentType.Class;
ts.forEachChild(node, cb);
currentParent = originalParent;
inClass = originalInClass;
Expand All @@ -96,16 +96,16 @@ function walk(ctx: Lint.WalkContext<boolean>): void {
case ts.SyntaxKind.PropertyDeclaration:
case ts.SyntaxKind.FunctionDeclaration:
case ts.SyntaxKind.FunctionExpression:
if (currentParent === parentType.Class) {
currentParent = parentType.ClassMethod;
if (currentParent === ParentType.Class) {
currentParent = ParentType.ClassMethod;
ts.forEachChild(node, cb);
currentParent = originalParent;
return;
} else {
currentParent
= (node as ts.FunctionLikeDeclaration).parameters.some(isThisParameter)
? parentType.BoundRegularFunction
: parentType.UnboundRegularFunction;
? ParentType.BoundRegularFunction
: ParentType.UnboundRegularFunction;
ts.forEachChild(node, cb);
currentParent = originalParent;
return;
Expand Down

0 comments on commit 412604b

Please sign in to comment.