SonarJS
SonarJS copied to clipboard
Fix FP S3800 (`function-return-type`): Exceptions for React components
Add an exception for React components:
- ignore when returning null or false
This issue was extracted from #4527 to not delay the sanitation fix.
I was not able to reproduce the first issue (React components, ignore when returning null or false): based on my testings with the current state of SonarJS, the S3800 rule never triggers when either the render
method of a React Component or a React FunctionComponent returns false
conditionally. Typically, the following code is compliant according to S3800:
export const MyComponent = ({flag}) => {
if (flag) {
return <>5</>;
}
return false;
};
I'll try to get more information about the edge case from the developer who dismissed the rule because of conditionally returning false.
Migrated to Jira. New ticket number: JS-31