forked from palantir/tslint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented fixer for member-ordering and added corresponding tests. (p…
…alantir#3935) * Implemented fixer for member-ordering and added corresponding tests. * Improved node boundary calculation so trivia remains attached to the correct nodes. * minor comment fixes.
- Loading branch information
1 parent
e3522f4
commit 0c0967a
Showing
22 changed files
with
586 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class X { | ||
a() { | ||
class A { | ||
e() {} | ||
f() {} | ||
} | ||
} | ||
b() { | ||
class B { | ||
c() {} | ||
d() {} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
test/rules/member-ordering/alphabetize-nested/test.ts.lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class X { | ||
b() { | ||
class B { | ||
d() {} | ||
c() {} | ||
~ ['c' should come alphabetically before 'd'] | ||
} | ||
} | ||
a() { | ||
~ ['a' should come alphabetically before 'b'] | ||
class A { | ||
f() {} | ||
e() {} | ||
~ ['e' should come alphabetically before 'f'] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"rules": { | ||
"member-ordering": [true, { | ||
"order": "fields-first", | ||
"alphabetize": true | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class X { | ||
// Different categories have alphabetization together. | ||
bar: number; | ||
foo: string; | ||
|
||
[Symbol.iterator]() {} | ||
// No ordering among computed properties | ||
[Symbol.alpherator]() {} | ||
|
||
// Computed properties must go at the beginning. | ||
[Symbol.zeterator]() {} | ||
|
||
0() {} | ||
1() {} | ||
2() {} | ||
bar() {} | ||
|
||
foo() {} | ||
"goo"() {} | ||
Hoo() {} | ||
ioo() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class C { | ||
static foo() {} | ||
protected static bar = 0; | ||
static baz(); | ||
|
||
static bang(); | ||
|
||
constructor(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class Good { | ||
constructor() {} | ||
bar = 5; | ||
static foo() {} | ||
private z = 12; | ||
private static zz = 10; | ||
} | ||
|
||
class Bad { | ||
constructor() {} | ||
private static a() {} | ||
static b() {} | ||
private c = 2; | ||
} | ||
|
||
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() {} | ||
}; | ||
|
||
function makeAClass() { | ||
const myClass = class { | ||
method(){} | ||
}; | ||
} |
Oops, something went wrong.