question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Typescript] Improvment for arrowParens rule

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
j-f1commented, Feb 14, 2019

ban-single-arg-parens

I’m pretty sure that’s what arrowParens: avoid does.

1reaction
lydellcommented, Feb 14, 2019

since some folks in our team do not even use it [Prettier]

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

arrow-parens - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
arrow-parens - Rule
If ban-single-arg-parens is specified, then arrow functions with one parameter must not have parentheses if removing them is allowed by TypeScript.
Read more >
tslint | Yarn - Package Manager
An extensible static analysis linter for the TypeScript language ... Change Log. v6.1.3. [bugfix] add support for TypeScript 4.0 peer dependency (#4943) ...
Read more >
Disable Arrow-Parens Lint rule in XO and Prettier
Arrow functions can omit parentheses when they have exactly one parameter. In all other cases, the parameter(s) must be wrapped in parentheses.
Read more >
The area in patheticcockroach.com where the EEG isn't ...
The first was tslint, which probably every TypeScript developer has at ... Note that some ESLint rules have been enhanced with TypeScript ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found