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

member-ordering: Support categories #2041

Merged
merged 2 commits into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.