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

Add 'type-literal-delimiter' rule #2374

Merged
merged 3 commits into from
May 14, 2017

Conversation

andy-hanson
Copy link
Contributor

PR checklist

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

Overview of change:

Added the type-literal-delimiter rule, which prefers { x: number, y: string } over { x: number; y: string }.

CHANGELOG.md entry:

[new-rule] type-literal-delimiter

@@ -0,0 +1,28 @@
type T = {
Copy link
Contributor

Choose a reason for hiding this comment

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

does it handle space before/after delimiter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not currently, no. I think that would be more appropriate for the whitespace rule.

Copy link
Contributor

@nchen63 nchen63 May 13, 2017

Choose a reason for hiding this comment

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

I'm asking if it would erroneously flag { a: b , c: d } or { a: b, c: d }. Should probably have a unit test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, gotcha. Added a test.

@nchen63 nchen63 merged commit 3b6465c into palantir:master May 14, 2017
@andy-hanson andy-hanson deleted the type-literal-delimiter branch May 14, 2017 01:26
@adidahiya
Copy link
Contributor

wait, this feels pretty inconsistent with how we write out interfaces... users are going to be pretty confused when tslint recommends this format:

type Foo {
  a: number,
  b: number,
}

interface Bar {
  a: number;
  b: number;
}

can we please make the default config prefer semicolons?

@andy-hanson
Copy link
Contributor Author

@adidahiya If so, then the current trailing-comma wouldn't handle checking for the last token. Maybe trailing-comma should be updated to check for type literal delimiters too, regardless of the kind used?

@adidahiya
Copy link
Contributor

@andy-hanson no, I think we can leave trailing-comma as-is. I think this rule (type-literal-delimiter) should enforce the trailing semicolon.

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