-
Notifications
You must be signed in to change notification settings - Fork 889
Fixed object-literal-sort-keys rule ignores quoted keys #1512 #1516
Conversation
Thanks for your interest in palantir/tslint, @bolatovumar! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
…tax-walker Added JSX Spread Attribute case statement (#1514)
@@ -62,7 +62,7 @@ class ObjectLiteralSortKeysWalker extends Lint.RuleWalker { | |||
if (sortedState) { | |||
const lastSortedKey = this.lastSortedKeyStack[this.lastSortedKeyStack.length - 1]; | |||
const keyNode = node.name; | |||
if (keyNode.kind === ts.SyntaxKind.Identifier) { | |||
if (keyNode.kind === ts.SyntaxKind.Identifier || keyNode.kind === ts.SyntaxKind.StringLiteral) { | |||
const key = (<ts.Identifier> keyNode).text; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this type assertion is no longer accurate with the change in the line above. I suggest refactoring into a type guard
function isIdentifierOrStringLiteral(node: ts.Node): node is (ts.Identifier | ts.StringLiteral) {
return node.kind === ts.SyntaxKind.Identifier || node.kind === ts.SyntaxKind.StringLiteral;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix.
@adidahiya Fixing this issue breaks the build as many files in the source code have quoted keys which are not in alphabetical order. What would the ideal resolution be here? Should I position them alphabetically and create a separate pull request? Or submit everything as one pull request? Something else entirely? |
Doing it as a separate PR sounds good to me 👍 |
Issue a new pull request here |
No description provided.