From 4de0494a6603eb8e5e4ec074e410dac6f03e462b Mon Sep 17 00:00:00 2001 From: Yassin Kammoun <52890329+yassin-kammoun-sonarsource@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:43:51 +0200 Subject: [PATCH] Modify rule S6774: Add missing "How to fix it" section (#3208) --- rules/S6774/javascript/rule.adoc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rules/S6774/javascript/rule.adoc b/rules/S6774/javascript/rule.adoc index f0bdfcec1e4..712d4cd97bd 100644 --- a/rules/S6774/javascript/rule.adoc +++ b/rules/S6774/javascript/rule.adoc @@ -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'; @@ -27,6 +33,8 @@ Hello.propTypes = { }; ---- +==== Compliant solution + [source,javascript,diff-id=1,diff-type=compliant] ---- import PropTypes from 'prop-types';