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>
}