Skip to content

JS-776 Remove in-rule React detection and rely on requiredDependency#6635

Open
zglicz wants to merge 6 commits intomasterfrom
codex/js-776-required-dependency
Open

JS-776 Remove in-rule React detection and rely on requiredDependency#6635
zglicz wants to merge 6 commits intomasterfrom
codex/js-776-required-dependency

Conversation

@zglicz
Copy link
Contributor

@zglicz zglicz commented Mar 19, 2026

Summary

  • remove per-rule React detection logic (detectReactRule) from S6440 and S6441
  • remove redundant react dependency guards from S6477 and S6747
  • delete unused rule-detect-react helper
  • keep fixtures focused on React scenarios only
  • add linter tests verifying requiredDependency filtering for a React rule (disabled without react, enabled with react)

Validation

  • npx tsx --tsconfig packages/tsconfig.test.json --test packages/jsts/src/rules/S6440/cb.test.ts packages/jsts/src/rules/S6441/cb.test.ts packages/jsts/tests/linter/index.test.ts

@hashicorp-vault-sonar-prod
Copy link

hashicorp-vault-sonar-prod bot commented Mar 19, 2026

JS-776

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Ruling Report

New issues flagged (9 issues)

S6440

eigen/src/app/Components/ArtworkGrids/LotCloseInfo.tsx:30

    28 |     return null
    29 |   }
>   30 |   const { hasEnded: lotHasClosed } = useTimer(lotEndAt, sale.startAt ?? "")
    31 | 
    32 |   const { hasEnded: lotsAreClosing, hasStarted: saleHasStarted } = useTimer(

eigen/src/app/Components/ArtworkGrids/LotCloseInfo.tsx:32

    30 |   const { hasEnded: lotHasClosed } = useTimer(lotEndAt, sale.startAt ?? "")
    31 | 
>   32 |   const { hasEnded: lotsAreClosing, hasStarted: saleHasStarted } = useTimer(
    33 |     sale.endAt!,
    34 |     sale.startAt!

eigen/src/app/Scenes/Inbox/Components/Conversations/OpenInquiryModalButton.tests.tsx:14

    12 | import { OpenInquiryModalButtonFragmentContainer } from "./OpenInquiryModalButton"
    13 | 
>   14 | const trackEvent = useTracking().trackEvent
    15 | 
    16 | jest.unmock("react-relay")

eigen/src/app/utils/platformUtil.ts:10

     8 |     return 0
     9 |   } else {
>   10 |     return 13 + useSafeAreaInsets().top
    11 |   }
    12 | }

moose/renderer/utils/animations.ts:29

    27 | 
    28 |   const translateY = `${reverse ? -5 : 5}px`;
>   29 |   return useTransition(item, keys, {
    30 |     from: {
    31 |       opacity: 0,

moose/renderer/utils/animations.ts:48

    46 | 
    47 | export function fadeIn(item, keys) {
>   48 |   return useTransition(item, keys, {
    49 |     from: {
    50 |       opacity: 0,

moose/renderer/utils/animations.ts:65

    63 | 
    64 | export function scale(item) {
>   65 |   return useTransition(item, null, {
    66 |     from: { transform: "scale(0.5)", opacity: 0 },
    67 |     enter: { transform: "scale(1)", opacity: 1 },

sonar-web/src/main/js/helpers/measures.js:12

    10 | export function formatMeasure (value, type) {
    11 |   let formatter = getFormatter(type);
>   12 |   return useFormatter(value, formatter);
    13 | }
    14 | 

sonar-web/src/main/js/helpers/measures.js:23

    21 | export function formatMeasureVariation (value, type) {
    22 |   let formatter = getVariationFormatter(type);
>   23 |   return useFormatter(value, formatter);
    24 | }
    25 | 

@sonar-review-alpha
Copy link

Generating a summary...

Comment on lines 31 to 33
'Remove this property or method or refactor this component, as "{{name}}" is not used inside component body',
unusedWithClass:
'Remove this property or method or refactor "{{className}}", as "{{name}}" is not used inside component body',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we override the builtin messages from eslint

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@sonarqube-next
Copy link

@zglicz zglicz requested a review from a team March 19, 2026 12:46
Copy link
Contributor

@vdiez vdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be more exhaustive, there are more rules trying to detect react aside of the rule-detect-react.ts helper. some are using custom esquery selectors. check S6439 or S6443 for example.

@zglicz
Copy link
Contributor Author

zglicz commented Mar 19, 2026

Both of those rule can't immediately benefit from simplification.

  • S6439 - additionaly checks if react-native is present and has a little bit different logic
  • S6443 - checks fqn to make sure its a react hook call

I did update rspec with required dependencies for a few of these rules - https://github.com/SonarSource/rspec/pull/6379

@zglicz zglicz requested a review from vdiez March 19, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants