typescript:S6754 potential false positive for boolean "is" prefix

What language is this for?

TypeScript

Which rule?

typescript:S6754 - The return value of “useState” should be destructured and named symmetrically

Why do you believe it’s a false-positive/false-negative?

There is a common convention for our codebase (and I have also seen this in other codebases) that we name getter/setter pairs for booleans like this

  • isFeatureEnabled
  • setFeatureEnabled

SonarQube wants to enforce it to be setIsFeatureEnabled (adding the extra Is). Would you consider adding this as an exception to the rule?

Are you using

SonarQube Server 10.6

How can we reproduce the problem?

import {useState} from "react";

function MyComponent() {
    const [isFeatureEnabled, setFeatureEnabled] = useState(false);

    return <div>Feature enabled: {isFeatureEnabled}</div>
}

Hello Jan,

Thank you for the feedback!

We will discuss your proposal and come back to you.

In the meantime, I can share with you that we are relying on an eslint-plugin-react’s implementation for this rule, so you can also submit your proposition there if you wish.