[Typescript] Improvment for arrowParens rule
See original GitHub issueI’m opening this issue here as I believe it makes the most sense.
Basically I got a situation where I cannot get a combination to suit simultaneously both prettier and tslint rules.
Environments:
- Prettier Version: 1.16.4
- Running Prettier via: vscode
- Runtime: node 10.13.0
- Operating System: ubuntu
Steps to reproduce:
On a typescript based project, define a method such as:
const MockedRollbar = { error: err => { console.log('mocked rollbar error call', err) }, warn: err => { console.log('mocked rollbar warn call', err) }, }
the tslint.json has the following options:
"arrow-parens": false,
or
"arrow-parens": true,
or
“arrow-parens”: [true, “ban-single-arg-parens”]
Latter would be ideal as it would check for parentheses except for single argument parameters
However at .prettierrc I got just two options
“arrowParens”: “avoid | always”,
I cannot figure a way to use both plugins in a way that auto-formatting keep the tslint rules valid.
Expected behavior:
Provide more granular options to prettier so that one is not forced to wrap every single function with parentheses whilst keeping tslint rules valid
Actual behavior:
Upon formatting I get:
Expected parentheses around arrow function argument having a body with curly braces
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
I’m pretty sure that’s what
arrowParens: avoid
does.There we have it. If your whole team isn’t onboard with using Prettier, you’re unfortunately going to have a bad time using Prettier. You’ll always bump into some incompatibility with your team’s style guide (so far you’ve only had trouble with arrow-parens, it seems), and you’ll accidentally commit unnecessarily large diffs by reformatting other parts of the file.
prettier-tslint might help, though.