Skip to content

Commit

Permalink
Revert "Revert recent member-ordering changes (palantir#2118)"
Browse files Browse the repository at this point in the history
This reverts commit aaa2319.
  • Loading branch information
andy-hanson committed Jan 26, 2017
1 parent f82ac79 commit 26e9030
Show file tree
Hide file tree
Showing 21 changed files with 407 additions and 274 deletions.
575 changes: 322 additions & 253 deletions src/rules/memberOrderingRule.ts

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions test/rules/member-ordering/custom-categories/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class C {
static foo() {}
protected static bar = 0;
static baz();

constructor();

static bang();
~~~~~~~~~~~~~~ [Declaration of static non-private not allowed after declaration of constructor. Instead, this should come at the beginning of the class/interface.]
}
18 changes: 18 additions & 0 deletions test/rules/member-ordering/custom-categories/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"rules": {
"member-ordering": [true, {
"order": [
{
"name": "static non-private",
"kinds": [
"public-static-field",
"protected-static-field",
"public-static-method",
"protected-static-method"
]
},
"constructor"
]
}]
}
}
12 changes: 12 additions & 0 deletions test/rules/member-ordering/omit-access-modifier/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class C {
private static x = 0;
static y = 1;

x = 0;
private y = 1;

constructor() {}

static z = 2;
~~~~~~~~~~~~~ [Declaration of static field not allowed after declaration of constructor. Instead, this should come at the beginning of the class/interface.]
}
9 changes: 9 additions & 0 deletions test/rules/member-ordering/omit-access-modifier/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"rules": {
"member-ordering": [true, { "order": [
"static-field",
"instance-field",
"constructor"
]}]
}
}
10 changes: 0 additions & 10 deletions test/rules/member-ordering/private/test.ts.lint

This file was deleted.

10 changes: 10 additions & 0 deletions test/rules/member-ordering/public-before-private/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Foo {
private x: number;
private bar(): any {
var bla: { a: string } = {a: '1'};
}
y: number;
~~~~~~~~~~ [0]
}

[0]: Declaration of public member not allowed after declaration of private member. Instead, this should come at the beginning of the class/interface.
10 changes: 10 additions & 0 deletions test/rules/member-ordering/static-before-instance/test.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Foo {
x: number;
static y: number;
~~~~~~~~~~~~~~~~~ [0]
constructor() {
// nothing to do
}
}

[0]: Declaration of static member not allowed after declaration of instance member. Instead, this should come at the beginning of the class/interface.
10 changes: 0 additions & 10 deletions test/rules/member-ordering/static/test.ts.lint

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,20 @@ class Constructor2 {
~~~~~~~~~~~~~~~~~ [0]
}

[0]: Declaration of public instance member variable not allowed to appear after declaration of public instance member function
// Works for type literal, just like interface
type T = {
x(): void;
y: number;
~~~~~~~~~~ [0]
}

// Works for class inside object literal
const o = {
foo: class C {
x(): void;
y: number;
~~~~~~~~~~ [0]
}
}

[0]: Declaration of field not allowed after declaration of method. Instead, this should come at the beginning of the class/interface.

0 comments on commit 26e9030

Please sign in to comment.