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

no-unnecessary-initializer: Convert to function #2707

Merged
merged 2 commits into from
May 8, 2017

Conversation

andy-hanson
Copy link
Contributor

@andy-hanson andy-hanson commented May 7, 2017

PR checklist

  • Addresses an existing issue: #0000
  • New feature, bugfix, or enhancement
    • Includes tests
  • Documentation update

Overview of change:

Just a refactor. EDIT: Also a bugfix.

CHANGELOG.md entry:

[bugfix]: no-unnecessary-initializer: Handle BindingElement anywhere, not just in a VariableDeclaration.

case ts.SyntaxKind.VariableDeclaration: {
const { name } = node as ts.VariableDeclaration;
if (utils.isBindingPattern(name)) {
for (const elem of name.elements) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this must be recursive.
I'd suggest to remove the special handling of BindingPattern here and add a case for BindingElement to the switch. That way you also handle destructuring in ParameterDeclaration

@nchen63 nchen63 merged commit 0645b9f into palantir:master May 8, 2017
@andy-hanson andy-hanson deleted the no-unnecessary-initializer branch May 8, 2017 05:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants