Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

sonarjs/cognitive-complexity doesn't ignore functional components written as arrow function #422

Closed
neotrow opened this issue Sep 21, 2023 · 3 comments
Assignees
Labels
jira-import_26-04-2024 The issue have been imported to Jira (26/04/2024): https://sonarsource.atlassian.net/browse/ESLINTJS

Comments

@neotrow
Copy link

neotrow commented Sep 21, 2023

I want to report a bug.

I saw that react functional components should be ignored: SonarSource/SonarJS#2238

But if the functional component is written as arrow function it's not ignored.

This will not be ignored and complain about cognitiv complexity:

const EmployeeDetailsSection: FC<EmployeeDetailsSectionProps> = (props) => {
  const t = useT();
  const { locale } = useRouter();

  return (
    <div>
       ...
   </div>
  );
}

But this will be ignored:

function EmployeeDetailsSection(props) {
  const t = useT();
  const { locale } = useRouter();

  return (
    <div>
       ...
   </div>
  );
}

eslint-plugin-sonarjs version: 0.21.0
eslint version: 8.26.0
Node.js version: 20

Rule key: sonarjs/cognitive-complexity

@btynflvc63
Copy link

btynflvc63 commented Nov 2, 2023

This will not be ignored and complain about cognitiv complexity:

const Test = React.forwardRef((props, ref) => {
  const t = useT();
  const { locale } = useRouter();

  return (
    <div>
       ...
   </div>
  );
})

@sebheron
Copy link

This is still an issue. Is this being worked on?

@Wohops Wohops added the jira-import_26-04-2024 The issue have been imported to Jira (26/04/2024): https://sonarsource.atlassian.net/browse/ESLINTJS label Apr 26, 2024
@Wohops
Copy link
Contributor

Wohops commented Apr 29, 2024

This issue has been migrated to Jira. ESLINTJS-27

@Wohops Wohops closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
jira-import_26-04-2024 The issue have been imported to Jira (26/04/2024): https://sonarsource.atlassian.net/browse/ESLINTJS
Projects
None yet
Development

No branches or pull requests

5 participants