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

Refactor object-literal-key-quotes rule #1874

Merged
merged 2 commits into from
Dec 18, 2016

Conversation

andy-hanson
Copy link
Contributor

@andy-hanson andy-hanson commented Dec 15, 2016

PR checklist

What changes did you make?

Rewrote object-literal-key-quotes to process all properties at once instead of using state on the Walker object. It no longer stores failures in an array, instead adding them immediately.

Is there anything you'd like reviewers to focus on?

The line node.properties.filter(({ kind }) => kind !== ts.SyntaxKind.MethodDeclaration); is just for backwards-compatibility. Not sure when it would be OK to introduce a breaking change of this kind, but I don't see why MethodDeclarations should be an exception to the rule. It seems like a result of the fact that the previous implementation used visitPropertyAssignment, skipping over MethodDeclarations implicitly.

Copy link
Contributor

@nchen63 nchen63 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code looks so much better after refactoring. Just remove the filter and we're good

let previousState = this.currentState;
this.currentState = state;
// For backwards-compatibility only. Old versions of this rule did nothing for method declarations.
const properties = node.properties.filter(({ kind }) => kind !== ts.SyntaxKind.MethodDeclaration);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this filter anymore

@nchen63 nchen63 merged commit 552ad84 into palantir:master Dec 18, 2016
@nchen63
Copy link
Contributor

nchen63 commented Dec 18, 2016

@andy-hanson thanks!

@andy-hanson andy-hanson deleted the object_literal_key_quotes branch December 20, 2016 03:24
@andy-hanson andy-hanson mentioned this pull request Dec 31, 2016
5 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants