Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Missing newline rules to achieve consistent trailing comma handling #343

Open
feedm3 opened this issue Aug 3, 2018 · 3 comments
Open

Missing newline rules to achieve consistent trailing comma handling #343

feedm3 opened this issue Aug 3, 2018 · 3 comments

Comments

@feedm3
Copy link

feedm3 commented Aug 3, 2018

There are some missing rules in this repository regarding "newline", which are part of ESLint.

  • function-paren-newline
  • object-curly-newline
  • array-bracket-newline
  • array-element-newline

All those rules are needed to have a consistent "Additional trailing comma" handling in our code.

Is there a reason why those rules are missing or a plan to add them? If not, is there an alternative to achieve the trailing comma handling?

@jmlopez-rod
Copy link
Collaborator

I've been using https://palantir.github.io/tslint/rules/trailing-comma/, and this is how I have configured it so that it can achieve the same style as airbnb.

"trailing-comma": [
      true,
      {
        "multiline": "always",
        "singleline": "never",
        "esSpecCompliant": true
      }
    ],

It does have a bug though:

palantir/tslint#3870

Is there something in that rule that doesn't allow you to have code style your project needs?

@feedm3
Copy link
Author

feedm3 commented Aug 28, 2018

Thanks for your reply!

That's what I'm currently using. The problem here is that I need additional rules, to make multiple parameters are forced to be multiline and not singleline.

For example function paramters:

// bad, but  valid
export function test(
  paramOne: string,
  paramTow: string) { 
  ...
}

// good
export function test(
  paramOne: string,
  paramTow: string,
  ) {
  ...
}

Or object declarations:

// bad, but valid
const object = { varOne: 'test', varTwo: 'test' };

// good
const object = {
  varOne: 'test',
  varTwo: 'test',
};

To make multiline mandatory I need the rules listed in my first post.

Do you know how I can enable these rules or know another solution for my problem?

@jmlopez-rod
Copy link
Collaborator

Ah, I see what you are saying now. Yeah, the rules you mentioned above are necessary. PRs are welcome to any of these rules.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants