"await" should not be used redundantly

In Javascript/Typescript RSPEC-4326 it is declared that returning an awaited promise is redundant code smell.
However in the case that the promise may throw and there is a surrounding try/catch expression, eliminating the await will also bypass the try-catch error handling leading to a bug.
It seems an issue to micro-optimize over proper maintainable code. it would be better to warn of methods that return promises that are not awaited which would be a more typical issue.
If the code is as simplistic as the example then it should probably not be async in the first place and just directly return the promise.

hello @steam,

thanks for reporting. Could you please include short code snippet demonstrating the bug you are describing to be sure I understand what you mean?

I have to assume this has been addressed in some way that is not mentioned in the rule itself as testing the lint on example code did not report on the cases where the return was inside a try-catch block. The risk of maintaining the rule still exists if the method is refactored later without noticing the method is not awaiting the promise.

function testThrows() {
    return Promise.reject(new Error("test throw message"));
}

// Does not work as expected. No rules detect this issue.
async function test4() {
    try {
        return testThrows();
    } catch (error) {
        return "error: " + error;
    }
}

// Works as expected, Surprisingly not reported as S4326
async function test3() {
    try {
        return await testThrows();
    } catch (error) {
        return "error: " + error;
    }
}

// Triggers the rule S4326 in sonarlint as expected.
async function test1() {
    return await testThrows();
}

For the Typescript case there appears to be an improvement to the rules via S4822 which would at least note the issue, after refactoring is done later, that introduced try-catch without await. However the text and examples of the rule do not distinguish from a method that isn’t awaited and the return foo() case from S4326

function testThrows(): Promise<never> {
    return Promise.reject(new Error("test throw message"));
}

// Does not work as expected.
// Does report typescript:S4822 catching the coding issue.
export async function test4(): Promise<string|undefined> {
    try {
        return testThrows();
    } catch (error) {
        return "error: " + error;
    }
}

// Works as expected
// Surprisingly does not report typescript:S4326
export async function test3(): Promise<string|undefined> {
    try {
        return await testThrows();
    } catch (error) {
        return "error: " + error;
    }
}

// Triggers the rule in sonarlint.
export async function test1(): Promise<never> {
    return await testThrows();
}