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

Whitespace padding in object literals, destructuring assignment, and import statements #1044

Closed
leeavital opened this issue Mar 18, 2016 · 23 comments
Labels
Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier P2 Resolution: Declined Type: Rule Suggestion

Comments

@leeavital
Copy link
Contributor

Enforce whitespace padding in object literals:

{ myField } // good
{ myField: "hello" } // good
{myField} // bad
{myField: "hello"} //bad
@vsiao
Copy link

vsiao commented Apr 27, 2016

I assume the same style should apply to named imports.

@adidahiya adidahiya changed the title Padding in object literals Whitespace padding in object literals Sep 30, 2016
@adidahiya adidahiya changed the title Whitespace padding in object literals Whitespace padding in object literals and import statements Sep 30, 2016
@Diokuz
Copy link

Diokuz commented Oct 31, 2016

Any progress?

@filipsuk
Copy link

+1

1 similar comment
@byeval
Copy link

byeval commented Nov 29, 2016

+1

@giladgray
Copy link

an option for the same thing for arrays would be great too. [a, b] vs [ a, b ]

@glen-84
Copy link
Contributor

glen-84 commented Jun 15, 2017

I prefer it without the spaces, so an option for that would also be nice.

@danieljin
Copy link

+1

@adidahiya adidahiya changed the title Whitespace padding in object literals and import statements Whitespace padding in object literals, destructuring assignment, and import statements Sep 26, 2017
@blingerson
Copy link

blingerson commented Oct 13, 2017

It would also be nice if we could enforce spacing before and after the colon like

{ foo : 'bar' } //good

{ foo: 'bar' } //bad

{ foo:'bar' } //bad

@irek02
Copy link

irek02 commented Mar 21, 2018

Any progress on this? I would really like to use this in our projects at Acquia.

@js2me
Copy link

js2me commented Jul 20, 2018

OMG, it still open?

@pelotom
Copy link

pelotom commented Jul 21, 2018

photofunia-1532138160

@peterjwest
Copy link

peterjwest commented Jul 21, 2018

BTW tslint-eslint-rules supports this in nearly all cases (except object literal types) with the rule object-curly-spacing. Perhaps this could be ported to tslint?

@MarcusNoble
Copy link

we use the following to achieve this:

{
    "extends": [
        "tslint-eslint-rules"
    ],
    "rules": {
        "object-curly-spacing": true,
        "array-bracket-spacing": [
            true,
            "never"
        ]
    }
}

@micheleangioni
Copy link

Any update on this? :)

@js2me
Copy link

js2me commented Sep 18, 2018

@micheleangioni I'm just using eslint plugin for integration tslint with eslint and that solves my problem linked with this issue

@toupeira
Copy link

I tried out object-curly-spacing from tslint-eslint-rules but it doesn't seem to cover empty objects ({} vs. { }), unless I misconfigured something.

Would be great to have something like this in tslint proper!

@toupeira
Copy link

I see #4068 added a check for spaces after open braces, but it doesn't detect more than one space, and doesn't deal with closing braces and empty objects.

@JoshuaKGoldberg
Copy link
Contributor

Including #3092: if this goes in, it should also add for generics.

@Maximaximum
Copy link

Would be a great thing to have

@adidahiya adidahiya added the Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier label Feb 25, 2019
@adidahiya
Copy link
Contributor

There have been very few PRs submitted to address this issue, and it is not a priority for TSLint core (see #4534), so I'm going to close this. If you want to implement this whitespace check, it can happily live in a custom rule set outside this repo.

@puneet-sutar
Copy link

I was looking for the solution and a colleague suggested it is already part of TSlint.
https://palantir.github.io/tslint/rules/whitespace/

@joshi-anshul
Copy link

You just need to add below rules in tslint.json file:

"whitespace": { "options": [ "check-branch", "check-decl", "check-operator", "check-separator", "check-type", "check-typecast", "check-module", "check-rest-spread", "check-preblock", "check-postbrace" ] },
Here "check-preblock", "check-postbrace" this rules enforce to add white space after braces

@JoshuaKGoldberg
Copy link
Contributor

🤖 Beep boop! 👉 TSLint is deprecated 👈 and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

@palantir palantir locked and limited conversation to collaborators Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Formatting rule Relates to a rule which enforces code formatting and likely overlaps with prettier P2 Resolution: Declined Type: Rule Suggestion
Projects
None yet
Development

No branches or pull requests