Skip to content

Commit

Permalink
improve(interface-sort-keys): key name info
Browse files Browse the repository at this point in the history
  • Loading branch information
paibamboo committed Oct 11, 2019
1 parent 07a979f commit 17e42d7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
"private": false,
"description": "",
"main": "./lib/index.js",
"config": {
"validate-commit-msg": {
"types": [
"cleanup",
"feat",
"unfeat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
"ci",
"chore",
"revert",
"followup",
"improve",
"mock"
]
}
},
"typings": "./lib/index",
"module": "./lib.es2015/index.js",
"jsnext:main": "./lib.es2015/index.js",
Expand Down
4 changes: 2 additions & 2 deletions src/interfaceSortKeysRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class InterfaceSortKeysRule extends Lint.RuleWalker {
if (unsortedIndex !== -1) {
const member = node.members[unsortedIndex];
if (ts.isIndexSignatureDeclaration(member)) {
this.addFailureAtNode(member.parameters[0], "This key is not sorted alphabetically");
this.addFailureAtNode(member.parameters[0], `The key "${member.parameters[0].getChildAt(0).getText()}" is not sorted alphabetically`);
} else if (ts.isPropertySignature(member)) {
this.addFailureAtNode(member.name, "This key is not sorted alphabetically");
this.addFailureAtNode(member.name, `The key "${member.name.getText()}" is not sorted alphabetically`);
} else {
throw new Error(`
Unknown Node Type!
Expand Down
10 changes: 5 additions & 5 deletions test/rules/interface-sort-keys/default/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface IAlphabet {
aaa: string;
bbb: string;
cccAaa: string;
~~~~~~ [This key is not sorted alphabetically]
~~~~~~ [The key "cccAaa" is not sorted alphabetically]
ccc: string;
cccc: string;
}
Expand All @@ -24,14 +24,14 @@ export interface IAlphabet {
bbb: string;
ccc: string;
cccc: string;
~~~~ [This key is not sorted alphabetically]
~~~~ [The key "cccc" is not sorted alphabetically]
cccAaa: string;
}

export interface IAlphabet {
aaa: string;
ddd: {
~~~ [This key is not sorted alphabetically]
~~~ [The key "ddd" is not sorted alphabetically]
dddAaa: string;
dddBbb: string;
}
Expand All @@ -43,14 +43,14 @@ export interface IAlphabet {
bbb: string;
ddd: {
dddBbb: string;
~~~~~~ [This key is not sorted alphabetically]
~~~~~~ [The key "dddBbb" is not sorted alphabetically]
dddAaa: string;
}
}

export interface ArrStr {
[key: string]: string | number; // Must accommodate all members
~~~~~~~~~~~ [This key is not sorted alphabetically]
~~~~~~~~~~~ [The key "key" is not sorted alphabetically]

[index: number]: string; // Can be a subset of string indexer

Expand Down

0 comments on commit 17e42d7

Please sign in to comment.