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

Commit

Permalink
member-ordering: Support categories (#2041)
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-hanson authored and nchen63 committed Jan 19, 2017
1 parent 2ce15c7 commit 18e7604
Show file tree
Hide file tree
Showing 21 changed files with 347 additions and 187 deletions.
442 changes: 277 additions & 165 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 @@ -68,5 +68,4 @@ const o = {
}
}

[0]: Declaration of public instance member variable not allowed to appear after declaration of public instance member function

[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 18e7604

Please sign in to comment.