Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create rule S6790: Disallow using string references (react/no-string-refs) #3187

Merged
merged 5 commits into from
Oct 11, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 2, 2023

You can preview this rule here (updated a few minutes after each push).

Review

A dedicated reviewer checked the rule description successfully for:

  • logical errors and incorrect information
  • information gaps and missing content
  • text style and tone
  • PR summary and labels follow the guidelines

@github-actions github-actions bot added the jsts label Oct 2, 2023
@victor-diez-sonarsource victor-diez-sonarsource changed the title Create rule S6790 Create rule S6790: Disallow using string references (react/no-string-refs) Oct 2, 2023
rules/S6790/javascript/metadata.json Outdated Show resolved Hide resolved
rules/S6790/javascript/rule.adoc Outdated Show resolved Hide resolved
rules/S6790/javascript/rule.adoc Outdated Show resolved Hide resolved
rules/S6790/javascript/rule.adoc Outdated Show resolved Hide resolved
rules/S6790/javascript/rule.adoc Outdated Show resolved Hide resolved
rules/S6790/javascript/rule.adoc Outdated Show resolved Hide resolved
rules/S6790/javascript/rule.adoc Outdated Show resolved Hide resolved
rules/S6790/javascript/rule.adoc Outdated Show resolved Hide resolved
});
----

Instead, reference callbacks should be used. These do not have the limitations mentioned above. When the DOM node is added to the screen, React will call the `ref` callback with the DOM node as the argument. When that DOM node is removed, React will call your `ref` callback with `null`. One should return `undefined` from the `ref` callback.

Choose a reason for hiding this comment

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

Suggested change
Instead, reference callbacks should be used. These do not have the limitations mentioned above. When the DOM node is added to the screen, React will call the `ref` callback with the DOM node as the argument. When that DOM node is removed, React will call your `ref` callback with `null`. One should return `undefined` from the `ref` callback.
Instead, reference callbacks should be used. These do not have the limitations mentioned above. When the DOM node is added to the Web page, React will call the `ref` callback with the DOM node as the argument. When that DOM node is removed, React will call your `ref` callback with `null`. One should return `undefined` from the `ref` callback.

Co-authored-by: Yassin Kammoun <52890329+yassin-kammoun-sonarsource@users.noreply.github.com>
@victor-diez-sonarsource victor-diez-sonarsource marked this pull request as ready for review October 11, 2023 07:52
@sonarqube-next
Copy link

SonarQube Quality Gate for 'rspec-frontend'

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarqube-next
Copy link

SonarQube Quality Gate for 'rspec-tools'

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@victor-diez-sonarsource victor-diez-sonarsource merged commit d908ea4 into master Oct 11, 2023
9 of 11 checks passed
@victor-diez-sonarsource victor-diez-sonarsource deleted the rule/add-RSPEC-S6790 branch October 11, 2023 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants