Skip to content

Commit

Permalink
Modify rule S6774: Add missing "How to fix it" section (#3208)
Browse files Browse the repository at this point in the history
  • Loading branch information
yassin-kammoun-sonarsource authored Oct 5, 2023
1 parent acdf388 commit 4de0494
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rules/S6774/javascript/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ In JavaScript, props are typically passed as plain objects, which can lead to er

By defining types for component props, developers can enforce type safety and provide clear documentation for the expected props of a component. This helps catch potential errors at compile-time. It also improves code maintainability by making it easier to understand how components should be used and what props they accept.

== How to fix it

=== Code examples

==== Noncompliant code example

[source,javascript,diff-id=1,diff-type=noncompliant]
----
import PropTypes from 'prop-types';
Expand All @@ -27,6 +33,8 @@ Hello.propTypes = {
};
----

==== Compliant solution

[source,javascript,diff-id=1,diff-type=compliant]
----
import PropTypes from 'prop-types';
Expand Down

0 comments on commit 4de0494

Please sign in to comment.