Git Product home page Git Product logo

Comments (8)

JoshuaKGoldberg avatar JoshuaKGoldberg commented on June 18, 2024

Heh, I personally prefer this, but have memories of people getting ✨ very upset ✨ over it. Maybe we should put it in strict to start?

from typescript-eslint.

Josh-Cena avatar Josh-Cena commented on June 18, 2024

What did people get upset about with return-await? Returning an unawaited promise inside a try catch seems to invite for troubles. I also don't know why people ever want to return unawaited promises, except for very simple wrappersβ€”fun fact, awaiting the promise does not make anything slower; it may actually make code faster than if you return the promise directly!

from typescript-eslint.

JoshuaKGoldberg avatar JoshuaKGoldberg commented on June 18, 2024

I don't have many primary resources that I can find in 5 minutes of searching 😞 but vaguely:

it may actually make code faster than if you return the promise directly!

Do you have references?

Maybe relevant: eslint/eslint#18166

from typescript-eslint.

kirkwaiblinger avatar kirkwaiblinger commented on June 18, 2024

I'm big +1 to this, but, I am also concerned that the current rule is too opinionated, and would cause a lot of unnecessary flagging in existing codebases. I'd propose we have an unopinionated option that only flags on the parts of the rule that impact correctness, if we are to add the rule to recommended; see #9030. Note that all the disagreements center around the portion of the rule that I'm proposing to disable.

from typescript-eslint.

bradzacher avatar bradzacher commented on June 18, 2024

and would cause a lot of unnecessary flagging in existing codebases

The rule has an autofixer for any cases that aren't any/unknown - so why is extra initial flagging bad?
It brings the codebase into a consistent style immediately. Anecdotally I've found people generally don't write return await so I don't think it would flag much.

from typescript-eslint.

JoshuaKGoldberg avatar JoshuaKGoldberg commented on June 18, 2024

people generally don't write return await

...but they should! If you return myPromise instead of return await myPromise the call stack doesn't include the intermediary step.

I'm +1 to this provided the caveats Kirk mentioned are accounted for.

from typescript-eslint.

kirkwaiblinger avatar kirkwaiblinger commented on June 18, 2024

so why is extra initial flagging bad?

Mostly, it's just that I would be scared we'd not get the rule into a recommended preset at all if we reawaken the opinion-charged conversations referenced in #8667 (comment). The thought is that, strategically speaking, we could sidestep all that and still get the most important benefits (IMO) of return-await.

It brings the codebase into a consistent style immediately. Anecdotally I've found people generally don't write return await so I don't think it would flag much.

I completely agree that full consistency (whether in-try-catch or, my preference, always) should be the correct end goal for any codebases. Maybe this could be in a strict or stylistic config?

from typescript-eslint.

kirkwaiblinger avatar kirkwaiblinger commented on June 18, 2024

If backlash that it's too opinionated where it doesn't affect the outcome of execution is not a concern, then everything I've said is moot! πŸ™‚

from typescript-eslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.