From 8cb457369e83ed431834d2937f68e59fe3ce9814 Mon Sep 17 00:00:00 2001 From: Yen-chi Chen Date: Tue, 18 Jun 2024 01:07:36 +0800 Subject: [PATCH] feat: add propTypes check (add sortShapeProp) (#1336) --- .eslintrc.js | 2 +- src/components/About/Timeline.js | 2 +- .../SubscriptionPlanCollection.js | 4 ++-- src/components/Buy/SubscriptionsSection/index.js | 4 ++-- .../CompanyAndJobTitle/IndexPage/index.js | 2 +- .../Overview/AverageWeekWorkTimeView.js | 2 +- .../CompanyAndJobTitle/Overview/index.js | 14 +++++++------- .../TimeAndSalary/TimeAndSalary.js | 2 +- .../CompanyAndJobTitle/TimeAndSalary/index.js | 2 +- src/components/ExperienceDetail/index.js | 2 +- src/components/LandingPage/SummarySection.js | 4 ++-- src/components/Me/CurrentSubscription.js | 4 ++-- .../WorkExperiencesForm/WorkExperience/index.js | 2 +- .../ShareExperience/common/SectionEleContent.js | 2 +- src/components/ShareExperience/common/Sections.js | 6 +++--- .../common/Charts/JobTitleDistrubitionChart.js | 6 +++--- .../common/Charts/SalaryDistributionChart.js | 4 ++-- src/components/common/FeedbackBlock/index.js | 2 +- src/components/common/TabLinkGroup/index.js | 2 +- src/components/common/button/ButtonGroup.js | 2 +- src/components/common/button/ButtonGroupImage.js | 4 ++-- src/components/common/form/Select.js | 2 +- src/utils/fetchBox.js | 2 +- 23 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3f4d0ecbe..846952f2d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -35,6 +35,6 @@ module.exports = { 'no-use-before-define': 'error', 'react/prop-types': 'error', 'react/no-unused-prop-types': 'error', - 'react/sort-prop-types': 'error', + 'react/sort-prop-types': ['error', {'sortShapeProp': true}], }, }; diff --git a/src/components/About/Timeline.js b/src/components/About/Timeline.js index 6caf648e2..0063f8344 100644 --- a/src/components/About/Timeline.js +++ b/src/components/About/Timeline.js @@ -26,8 +26,8 @@ const Timeline = ({ year, data }) => ( Timeline.propTypes = { data: PropTypes.arrayOf( PropTypes.shape({ - month: PropTypes.number.isRequired, Content: PropTypes.func.isRequired, + month: PropTypes.number.isRequired, }), ), year: PropTypes.number, diff --git a/src/components/Buy/SubscriptionsSection/SubscriptionPlanCollection.js b/src/components/Buy/SubscriptionsSection/SubscriptionPlanCollection.js index 4e9900f89..c3158f46c 100644 --- a/src/components/Buy/SubscriptionsSection/SubscriptionPlanCollection.js +++ b/src/components/Buy/SubscriptionsSection/SubscriptionPlanCollection.js @@ -24,10 +24,10 @@ const SubscriptionPlanCollection = ({ plans, selectedId, setSelectedId }) => ( SubscriptionPlanCollection.propTypes = { plans: PropTypes.arrayOf( PropTypes.shape({ + amount: PropTypes.number.isRequired, + description: PropTypes.string.isRequired, skuId: PropTypes.string.isRequired, title: PropTypes.string.isRequired, - description: PropTypes.string.isRequired, - amount: PropTypes.number.isRequired, type: PropTypes.oneOf(subscriptionTypes).isRequired, }), ), diff --git a/src/components/Buy/SubscriptionsSection/index.js b/src/components/Buy/SubscriptionsSection/index.js index 1f8cd2352..b30c46e2d 100644 --- a/src/components/Buy/SubscriptionsSection/index.js +++ b/src/components/Buy/SubscriptionsSection/index.js @@ -39,13 +39,13 @@ const SubscriptionsSection = ({ SubscriptionsSection.propTypes = { plans: PropTypes.arrayOf( PropTypes.shape({ - skuId: PropTypes.string.isRequired, - title: PropTypes.string.isRequired, amount: PropTypes.number.isRequired, duration: PropTypes.shape({ amount: PropTypes.number.isRequired, type: PropTypes.string.isRequired, }), + skuId: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, }), ), selectedId: PropTypes.string, diff --git a/src/components/CompanyAndJobTitle/IndexPage/index.js b/src/components/CompanyAndJobTitle/IndexPage/index.js index e2d1334cb..89b685fb8 100644 --- a/src/components/CompanyAndJobTitle/IndexPage/index.js +++ b/src/components/CompanyAndJobTitle/IndexPage/index.js @@ -86,13 +86,13 @@ const CompanyAndJobTitleIndex = ({ CompanyAndJobTitleIndex.propTypes = { getPageLink: PropTypes.func.isRequired, indexesBox: PropTypes.shape({ - status: PropTypes.string.isRequired, data: PropTypes.arrayOf( PropTypes.shape({ name: PropTypes.string.isRequired, }), ), error: PropTypes.any, + status: PropTypes.string.isRequired, }), // pagination usage page: PropTypes.number.isRequired, diff --git a/src/components/CompanyAndJobTitle/Overview/AverageWeekWorkTimeView.js b/src/components/CompanyAndJobTitle/Overview/AverageWeekWorkTimeView.js index 22f96a616..aedef1187 100644 --- a/src/components/CompanyAndJobTitle/Overview/AverageWeekWorkTimeView.js +++ b/src/components/CompanyAndJobTitle/Overview/AverageWeekWorkTimeView.js @@ -37,10 +37,10 @@ const AverageWeekWorkTimeView = ({ AverageWeekWorkTimeView.propTypes = { averageWeekWorkTime: PropTypes.number.isRequired, overtimeFrequencyCount: PropTypes.shape({ + almost_everyday: PropTypes.number, seldom: PropTypes.number, sometimes: PropTypes.number, usually: PropTypes.number, - almost_everyday: PropTypes.number, }).isRequired, }; diff --git a/src/components/CompanyAndJobTitle/Overview/index.js b/src/components/CompanyAndJobTitle/Overview/index.js index 70210fdb7..b3c6e3ed7 100644 --- a/src/components/CompanyAndJobTitle/Overview/index.js +++ b/src/components/CompanyAndJobTitle/Overview/index.js @@ -68,20 +68,20 @@ const Overview = ({ Overview.propTypes = { canView: PropTypes.bool.isRequired, overviewBox: PropTypes.shape({ - status: PropTypes.string.isRequired, data: PropTypes.shape({ + averageWeekWorkTime: PropTypes.number.isRequired, interviewExperiences: PropTypes.arrayOf(PropTypes.object).isRequired, interviewExperiencesCount: PropTypes.number.isRequired, - workExperiences: PropTypes.arrayOf(PropTypes.object).isRequired, - workExperiencesCount: PropTypes.number.isRequired, - salaryWorkTimes: PropTypes.arrayOf(PropTypes.object).isRequired, - salaryWorkTimesCount: PropTypes.number.isRequired, - salaryDistribution: PropTypes.array, jobAverageSalaries: PropTypes.array, - averageWeekWorkTime: PropTypes.number.isRequired, overtimeFrequencyCount: PropTypes.object.isRequired, + salaryDistribution: PropTypes.array, + salaryWorkTimes: PropTypes.arrayOf(PropTypes.object).isRequired, + salaryWorkTimesCount: PropTypes.number.isRequired, + workExperiences: PropTypes.arrayOf(PropTypes.object).isRequired, + workExperiencesCount: PropTypes.number.isRequired, }), error: PropTypes.any, + status: PropTypes.string.isRequired, }).isRequired, page: PropTypes.number.isRequired, pageName: PropTypes.string.isRequired, diff --git a/src/components/CompanyAndJobTitle/TimeAndSalary/TimeAndSalary.js b/src/components/CompanyAndJobTitle/TimeAndSalary/TimeAndSalary.js index ef67f4c0a..38b805762 100644 --- a/src/components/CompanyAndJobTitle/TimeAndSalary/TimeAndSalary.js +++ b/src/components/CompanyAndJobTitle/TimeAndSalary/TimeAndSalary.js @@ -80,9 +80,9 @@ TimeAndSalary.propTypes = { pageType: PropTypes.string, queryParams: PropTypes.object, salaryWorkTimeStatistics: PropTypes.shape({ - count: PropTypes.number, average_estimated_hourly_wage: PropTypes.number, average_week_work_time: PropTypes.number, + count: PropTypes.number, }), salaryWorkTimes: PropTypes.array, tabType: PropTypes.string, diff --git a/src/components/CompanyAndJobTitle/TimeAndSalary/index.js b/src/components/CompanyAndJobTitle/TimeAndSalary/index.js index 1046d541a..dd0134820 100644 --- a/src/components/CompanyAndJobTitle/TimeAndSalary/index.js +++ b/src/components/CompanyAndJobTitle/TimeAndSalary/index.js @@ -45,9 +45,9 @@ TimeAndSalary.propTypes = { pageName: PropTypes.string, pageType: PropTypes.string, salaryWorkTimeStatistics: PropTypes.shape({ - count: PropTypes.number, average_estimated_hourly_wage: PropTypes.number, average_week_work_time: PropTypes.number, + count: PropTypes.number, }), salaryWorkTimes: PropTypes.array, status: PropTypes.string.isRequired, diff --git a/src/components/ExperienceDetail/index.js b/src/components/ExperienceDetail/index.js index c0b44923c..f2cd2b7c2 100644 --- a/src/components/ExperienceDetail/index.js +++ b/src/components/ExperienceDetail/index.js @@ -281,8 +281,8 @@ const ExperienceDetail = ({ ...props }) => { ExperienceDetail.propTypes = { location: PropTypes.shape({ state: PropTypes.shape({ - replyId: PropTypes.string, pageType: PropTypes.string, + replyId: PropTypes.string, }), }), }; diff --git a/src/components/LandingPage/SummarySection.js b/src/components/LandingPage/SummarySection.js index 21ae66532..6c32526e4 100644 --- a/src/components/LandingPage/SummarySection.js +++ b/src/components/LandingPage/SummarySection.js @@ -75,18 +75,18 @@ const SummarySection = ({ SummarySection.propTypes = { popularCompanyAverageSalary: PropTypes.arrayOf( PropTypes.shape({ + average_salaries: PropTypes.array, company: PropTypes.shape({ name: PropTypes.string, }), - average_salaries: PropTypes.array, }), ).isRequired, popularJobTitleSalaryDistribution: PropTypes.arrayOf( PropTypes.shape({ + bins: PropTypes.array, job_title: PropTypes.shape({ name: PropTypes.string, }), - bins: PropTypes.array, }), ).isRequired, }; diff --git a/src/components/Me/CurrentSubscription.js b/src/components/Me/CurrentSubscription.js index 518300670..9181a6bce 100644 --- a/src/components/Me/CurrentSubscription.js +++ b/src/components/Me/CurrentSubscription.js @@ -32,10 +32,10 @@ const CurrentSubscription = ({ subscriptionPlan, expiredAt }) => { CurrentSubscription.propTypes = { expiredAt: PropTypes.string, subscriptionPlan: PropTypes.shape({ - title: PropTypes.string, + amount: PropTypes.number, description: PropTypes.string, + title: PropTypes.string, type: PropTypes.string, - amount: PropTypes.number, }), }; diff --git a/src/components/ShareExperience/WorkExperiencesForm/WorkExperience/index.js b/src/components/ShareExperience/WorkExperiencesForm/WorkExperience/index.js index a097a80a4..545d7ad09 100644 --- a/src/components/ShareExperience/WorkExperiencesForm/WorkExperience/index.js +++ b/src/components/ShareExperience/WorkExperiencesForm/WorkExperience/index.js @@ -101,9 +101,9 @@ WorkExperience.propTypes = { removeSection: PropTypes.func, sections: PropTypes.arrayOf( PropTypes.shape({ + content: PropTypes.string, id: PropTypes.number, subtitle: PropTypes.string, - content: PropTypes.string, }), ), submitted: PropTypes.bool, diff --git a/src/components/ShareExperience/common/SectionEleContent.js b/src/components/ShareExperience/common/SectionEleContent.js index abbb030ce..67cbcbbfc 100644 --- a/src/components/ShareExperience/common/SectionEleContent.js +++ b/src/components/ShareExperience/common/SectionEleContent.js @@ -94,9 +94,9 @@ SectionEleContent.propTypes = { placeholder: PropTypes.string, removeSection: PropTypes.func, section: PropTypes.shape({ + content: PropTypes.string, id: PropTypes.number, subtitle: PropTypes.string, - content: PropTypes.string, }).isRequired, submitted: PropTypes.bool.isRequired, titlePlaceholder: PropTypes.string, diff --git a/src/components/ShareExperience/common/Sections.js b/src/components/ShareExperience/common/Sections.js index 5d385e145..6fb2aa2ba 100644 --- a/src/components/ShareExperience/common/Sections.js +++ b/src/components/ShareExperience/common/Sections.js @@ -43,12 +43,12 @@ Sections.propTypes = { removeSection: PropTypes.func, sections: PropTypes.arrayOf( PropTypes.shape({ + content: PropTypes.string, id: PropTypes.number, - subtitle: PropTypes.string, + isSubtitleEditable: PropTypes.bool, placeholder: PropTypes.string, + subtitle: PropTypes.string, titlePlaceholder: PropTypes.string, - content: PropTypes.string, - isSubtitleEditable: PropTypes.bool, }), ), submitted: PropTypes.bool, diff --git a/src/components/common/Charts/JobTitleDistrubitionChart.js b/src/components/common/Charts/JobTitleDistrubitionChart.js index fb3c75eba..5aaee9de7 100644 --- a/src/components/common/Charts/JobTitleDistrubitionChart.js +++ b/src/components/common/Charts/JobTitleDistrubitionChart.js @@ -65,12 +65,12 @@ const JobTitleDistributionChart = ({ data }) => { JobTitleDistributionChart.propTypes = { data: PropTypes.arrayOf( PropTypes.shape({ - job_title: PropTypes.shape({ - name: PropTypes.string, - }), average_salary: PropTypes.shape({ amount: PropTypes.number, }), + job_title: PropTypes.shape({ + name: PropTypes.string, + }), }), ).isRequired, }; diff --git a/src/components/common/Charts/SalaryDistributionChart.js b/src/components/common/Charts/SalaryDistributionChart.js index d9a8e5916..ae372f5f4 100644 --- a/src/components/common/Charts/SalaryDistributionChart.js +++ b/src/components/common/Charts/SalaryDistributionChart.js @@ -19,10 +19,10 @@ const LabelOnSmallDevice = ({ viewBox: { x, y, width, height } }) => { LabelOnSmallDevice.propTypes = { viewBox: PropTypes.shape({ + height: PropTypes.number.isRequired, + width: PropTypes.number.isRequired, x: PropTypes.number.isRequired, y: PropTypes.number.isRequired, - width: PropTypes.number.isRequired, - height: PropTypes.number.isRequired, }).isRequired, }; diff --git a/src/components/common/FeedbackBlock/index.js b/src/components/common/FeedbackBlock/index.js index 49cc78198..a6fc33534 100644 --- a/src/components/common/FeedbackBlock/index.js +++ b/src/components/common/FeedbackBlock/index.js @@ -16,8 +16,8 @@ class FeedbackBlock extends React.Component { category: PropTypes.string.isRequired, className: PropTypes.string, placeholders: PropTypes.shape({ - yes: PropTypes.string, no: PropTypes.string, + yes: PropTypes.string, }), question: PropTypes.string, }; diff --git a/src/components/common/TabLinkGroup/index.js b/src/components/common/TabLinkGroup/index.js index 486686e25..e948e959f 100644 --- a/src/components/common/TabLinkGroup/index.js +++ b/src/components/common/TabLinkGroup/index.js @@ -36,9 +36,9 @@ TabLinkGroup.propTypes = { to: PropTypes.oneOfType([ PropTypes.string, PropTypes.shape({ + hash: PropTypes.string, pathname: PropTypes.string, search: PropTypes.string, - hash: PropTypes.string, state: PropTypes.object, }), ]), diff --git a/src/components/common/button/ButtonGroup.js b/src/components/common/button/ButtonGroup.js index ab71ac31c..ad40413e7 100644 --- a/src/components/common/button/ButtonGroup.js +++ b/src/components/common/button/ButtonGroup.js @@ -53,8 +53,8 @@ ButtonGroup.propTypes = { onChange: PropTypes.func, options: PropTypes.arrayOf( PropTypes.shape({ - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), }), ), value: PropTypes.oneOfType([ diff --git a/src/components/common/button/ButtonGroupImage.js b/src/components/common/button/ButtonGroupImage.js index 20818032b..f9dd0cb2b 100644 --- a/src/components/common/button/ButtonGroupImage.js +++ b/src/components/common/button/ButtonGroupImage.js @@ -110,9 +110,9 @@ ButtonGroupImage.propTypes = { onChange: PropTypes.func, options: PropTypes.arrayOf( PropTypes.shape({ - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), icon: PropTypes.node, + label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), }), ), theme: PropTypes.string, diff --git a/src/components/common/form/Select.js b/src/components/common/form/Select.js index a5d1a2c2c..8447e8515 100644 --- a/src/components/common/form/Select.js +++ b/src/components/common/form/Select.js @@ -32,8 +32,8 @@ Select.propTypes = { onChange: PropTypes.func, options: PropTypes.arrayOf( PropTypes.shape({ - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), }), ), value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), diff --git a/src/utils/fetchBox.js b/src/utils/fetchBox.js index a3fc84779..4dac64cbc 100644 --- a/src/utils/fetchBox.js +++ b/src/utils/fetchBox.js @@ -21,8 +21,8 @@ const initFetchBox = ( export const fetchBoxPropType = PropTypes.shape({ data: PropTypes.any, - status: PropTypes.oneOf(Object.values(fetchingStatus)), error: PropTypes.any, + status: PropTypes.oneOf(Object.values(fetchingStatus)), }); const getStatus = prop('status');