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

Feature request: Add rule for enforcing function parameter linebreak and indentation style #3746

Closed
samal-rasmussen opened this issue Feb 28, 2018 · 3 comments

Comments

@samal-rasmussen
Copy link

Feature request

There are several different types of styles for handling linebreaks and indentation for funtion parameters. Here are a few I could come up with:

function example1(arg1: string, arg2: number, arg3: boolean): number {
  return 123;
}

function example2(arg1: string,
                  arg2: number,
                  arg3: boolean): number {
  return 123;
}

function example3(
  arg1: string,
  arg2: number,
  arg3: boolean): number {
  return 123;
}

function example4(
  arg1: string,
  arg2: number,
  arg3: boolean,
): number {
  return 123;
}

I am personally partial to example4, as it enforces the shortest lines, but different people may want to enforce different styles in their codebases. The important part is that we can enforce a consistent style.

So I'm proposing a new rule, maybe called function-parameter-style or something like that. And then we need to come up with names for the different styles that we can set, or maybe we just number them.

@samal-rasmussen samal-rasmussen changed the title Feature request: Function parameter linebreak and indentation style Feature request: Add rule for enforcing function parameter linebreak and indentation style Feb 28, 2018
@JoshuaKGoldberg
Copy link
Contributor

@samal84 this already exists as the align rule.

@samal-rasmussen
Copy link
Author

I couldn't get what I wanted with the align parameters rule. The align parameters rule accepts all of my examples. I am proposing a rule that would only accept one of them.

@JoshuaKGoldberg
Copy link
Contributor

Gotcha. In that case, since there's a lot of overlap, I'd recommend putting this new rule in a separate repository and linking to it here. TSLint's been moving away from investing in whitespace rules: #628.

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

No branches or pull requests

3 participants