tslint-eslint-rules
tslint-eslint-rules copied to clipboard
Missing newline rules to achieve consistent trailing comma handling
There are some missing rules in this repository regarding "newline", which are part of ESLint.
function-paren-newlineobject-curly-newlinearray-bracket-newlinearray-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?
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:
https://github.com/palantir/tslint/issues/3870
Is there something in that rule that doesn't allow you to have code style your project needs?
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?
Ah, I see what you are saying now. Yeah, the rules you mentioned above are necessary. PRs are welcome to any of these rules.