False Positive on "Promises should not be misused (typescript:S6544)" Rule

Operating system: Windows 11 with WSL running Ubuntu 22.04 LTS
IDE: Visual Studio Code


I’ve been encountering an issue with SonarLint while working on a React project, specifically in a form submission handler. The SonarLint TypeScript rule “Promises should not be misused (typescript:S6544)” is flagging a piece of code that seems to handle Promises correctly.

Here’s the function causing the warning:

async function handleSubmitForm(e: React.FormEvent) {

  // Validate Data
  if (!formData.email || !formData.password) {
    toast.error('Please check the fields!');

  try {
    await handleLogin(formData, selectedProfile);
  } catch (error) {
    toast.error('An error occurred during login!');

The form event handler function (handleSubmitForm ) is async and properly uses try/catch to handle any errors that might be thrown from the handleLogin function. The handleLogin function is defined elsewhere and is a Promise-based function:

(local function) handleLogin(payload: ClientFormLogin, role: IClient['role']): Promise<boolean>

The warning appears at the point where the handleSubmitForm function is passed to the form’s onSubmit event:

<form onSubmit={handleSubmitForm}>

I’m not clear why SonarLint is flagging this as a misuse of Promises. Based on my understanding, I’m using await correctly within a try/catch block, which should properly handle the Promise returned by handleLogin. Any insights or help to understand this issue would be greatly appreciated.

Thank you for your time.

Hello Iury,

Indeed the try/catch you are using would take care of the issue.

We’ve recently updated the rule to not flag JSX attributes. Could you provide a more complete code example so we can reproduce it?