Skip to content

Commit

Permalink
Fix bug in member-ordering rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Killian committed May 11, 2016
1 parent 600e6da commit 4d686b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/rules/memberOrderingRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ export class MemberOrderingWalker extends Lint.RuleWalker {
// don't call super from here -- we want to skip the property declarations in type literals
}

public visitObjectLiteralExpression(node: ts.ObjectLiteralExpression) {
// again, don't call super here - object literals can have methods,
// and we don't wan't to check these
}

/* start old code */
private resetPreviousModifiers() {
this.previousMember = {
Expand Down
14 changes: 14 additions & 0 deletions test/rules/member-ordering/order/custom/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ class Bad {
static b() {}
~~~~~~~~~~~~~ [Declaration of public static method not allowed after declaration of private instance field. Instead, this should come at the beginning of the class/interface.]
}

class AlsoOkay {
constructor() {
const bar = {
someMethod() {}
};
}
private z = 10;
}

const foo = {
// TS treats this as a method, but we should be careful not to
someMethod() {}
};

0 comments on commit 4d686b8

Please sign in to comment.