diff --git a/.eslintrc.js b/.eslintrc.js index 9ed6c9fe81..2cc79ce787 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,11 +1,18 @@ const { createConfig } = require('@edx/frontend-build'); module.exports = createConfig('eslint', { - overrides: [{ - files: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)", "setupTest.js"], - rules: { - 'import/named': 'off', - 'import/no-extraneous-dependencies': 'off', - }, - }], + rules: { + 'import/named': 'off', + 'import/no-extraneous-dependencies': 'off', + 'no-restricted-exports': 'off', + 'react-hooks/exhaustive-deps': 'off', + 'react-hooks/rules-of-hooks': 'off', + 'react/function-component-definition': 'off', + 'react/jsx-no-useless-fragment': 'off', + 'react/no-unstable-nested-components': 'off', + 'react/jsx-no-constructed-context-values': 'off', + 'react/jsx-no-bind': 'off', + 'react/prop-types': 'off', + 'react/no-unknown-property': 'off', + }, }); diff --git a/src/alerts/sequence-alerts/hooks.js b/src/alerts/sequence-alerts/hooks.js index b16dbeb9a4..f0acf50b04 100644 --- a/src/alerts/sequence-alerts/hooks.js +++ b/src/alerts/sequence-alerts/hooks.js @@ -35,7 +35,8 @@ function useSequenceEntranceExamAlert(courseId, sequenceId, intl) { if (entranceExamPassed) { entranceExamText = intl.formatMessage( - messages.entranceExamTextPassed, { entranceExamCurrentScore: entranceExamCurrentScore * 100 }, + messages.entranceExamTextPassed, + { entranceExamCurrentScore: entranceExamCurrentScore * 100 }, ); } else { entranceExamText = intl.formatMessage(messages.entranceExamTextNotPassing, { diff --git a/src/course-home/data/__factories__/courseHomeMetadata.factory.js b/src/course-home/data/__factories__/courseHomeMetadata.factory.js index fb4781b320..0364a4886c 100644 --- a/src/course-home/data/__factories__/courseHomeMetadata.factory.js +++ b/src/course-home/data/__factories__/courseHomeMetadata.factory.js @@ -34,91 +34,89 @@ Factory.define('courseHomeMetadata') currency_symbol: '$', }, }) - .attr( - 'tabs', ['id', 'host'], (id, host) => [ - Factory.build( - 'tab', - { - title: 'Course', - priority: 0, - slug: 'courseware', - type: 'courseware', - }, - { - courseId: id, - host, - path: 'course/', - }, - ), - Factory.build( - 'tab', - { - title: 'Discussion', - priority: 1, - slug: 'discussion', - type: 'discussion', - }, - { - courseId: id, - host, - path: 'discussion/forum/', - }, - ), - Factory.build( - 'tab', - { - title: 'Wiki', - priority: 2, - slug: 'wiki', - type: 'wiki', - }, - { - courseId: id, - host, - path: 'course_wiki', - }, - ), - Factory.build( - 'tab', - { - title: 'Progress', - priority: 3, - slug: 'progress', - type: 'progress', - }, - { - courseId: id, - host, - path: 'progress', - }, - ), - Factory.build( - 'tab', - { - title: 'Instructor', - priority: 4, - slug: 'instructor', - type: 'instructor', - }, - { - courseId: id, - host, - path: 'instructor', - }, - ), - Factory.build( - 'tab', - { - title: 'Dates', - priority: 5, - slug: 'dates', - type: 'dates', - }, - { - courseId: id, - host, - path: 'dates', - }, - ), - ], - ); + .attr('tabs', ['id', 'host'], (id, host) => [ + Factory.build( + 'tab', + { + title: 'Course', + priority: 0, + slug: 'courseware', + type: 'courseware', + }, + { + courseId: id, + host, + path: 'course/', + }, + ), + Factory.build( + 'tab', + { + title: 'Discussion', + priority: 1, + slug: 'discussion', + type: 'discussion', + }, + { + courseId: id, + host, + path: 'discussion/forum/', + }, + ), + Factory.build( + 'tab', + { + title: 'Wiki', + priority: 2, + slug: 'wiki', + type: 'wiki', + }, + { + courseId: id, + host, + path: 'course_wiki', + }, + ), + Factory.build( + 'tab', + { + title: 'Progress', + priority: 3, + slug: 'progress', + type: 'progress', + }, + { + courseId: id, + host, + path: 'progress', + }, + ), + Factory.build( + 'tab', + { + title: 'Instructor', + priority: 4, + slug: 'instructor', + type: 'instructor', + }, + { + courseId: id, + host, + path: 'instructor', + }, + ), + Factory.build( + 'tab', + { + title: 'Dates', + priority: 5, + slug: 'dates', + type: 'dates', + }, + { + courseId: id, + host, + path: 'dates', + }, + ), + ]); diff --git a/src/course-home/outline-tab/OutlineTab.test.jsx b/src/course-home/outline-tab/OutlineTab.test.jsx index 20701c5539..d46754355b 100644 --- a/src/course-home/outline-tab/OutlineTab.test.jsx +++ b/src/course-home/outline-tab/OutlineTab.test.jsx @@ -380,19 +380,19 @@ describe('Outline Tab', () => { ${'Regular'} | ${3} ${'Intense'} | ${5} `('calls the API with a goal of $days when $level goal is clicked', async ({ level, days }) => { - // click on Casual goal - const button = await screen.queryByTestId(`weekly-learning-goal-input-${level}`); - fireEvent.click(button); - // Verify the request was made - await waitFor(() => { - expect(axiosMock.history.post[0].url).toMatch(goalUrl); - // subscribe is turned on automatically - expect(axiosMock.history.post[0].data).toMatch(`{"course_id":"${courseId}","days_per_week":${days},"subscribed_to_reminders":true}`); - // verify that the additional info about subscriptions shows up - expect(screen.queryByText(messages.goalReminderDetail.defaultMessage)).toBeInTheDocument(); - }); - expect(screen.getByLabelText(messages.setGoalReminder.defaultMessage)).toBeEnabled(); -}); + // click on Casual goal + const button = await screen.queryByTestId(`weekly-learning-goal-input-${level}`); + fireEvent.click(button); + // Verify the request was made + await waitFor(() => { + expect(axiosMock.history.post[0].url).toMatch(goalUrl); + // subscribe is turned on automatically + expect(axiosMock.history.post[0].data).toMatch(`{"course_id":"${courseId}","days_per_week":${days},"subscribed_to_reminders":true}`); + // verify that the additional info about subscriptions shows up + expect(screen.queryByText(messages.goalReminderDetail.defaultMessage)).toBeInTheDocument(); + }); + expect(screen.getByLabelText(messages.setGoalReminder.defaultMessage)).toBeEnabled(); + }); it('shows and hides subscribe to reminders additional text', async () => { const button = await screen.getByTestId('weekly-learning-goal-input-Regular'); fireEvent.click(button); @@ -783,12 +783,14 @@ describe('Outline Tab', () => { const requestingButton = screen.getByRole('button', { name: 'Request certificate' }); fireEvent.click(requestingButton); expect(sendTrackEvent).toHaveBeenCalledTimes(1); - expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.course_outline.certificate_alert_request_cert_button.clicked', + expect(sendTrackEvent).toHaveBeenCalledWith( + 'edx.ui.lms.course_outline.certificate_alert_request_cert_button.clicked', { courserun_key: courseId, is_staff: false, org_key: 'edX', - }); + }, + ); }); it('tracks download cert button', async () => { sendTrackEvent.mockClear(); @@ -827,12 +829,14 @@ describe('Outline Tab', () => { const requestingButton = screen.getByRole('button', { name: 'View my certificate' }); fireEvent.click(requestingButton); expect(sendTrackEvent).toHaveBeenCalledTimes(1); - expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.course_outline.certificate_alert_downloadable_button.clicked', + expect(sendTrackEvent).toHaveBeenCalledWith( + 'edx.ui.lms.course_outline.certificate_alert_downloadable_button.clicked', { courserun_key: courseId, is_staff: false, org_key: 'edX', - }); + }, + ); }); it('tracks unverified cert button', async () => { sendTrackEvent.mockClear(); @@ -871,12 +875,14 @@ describe('Outline Tab', () => { const requestingButton = screen.getByRole('link', { name: 'Verify my ID' }); fireEvent.click(requestingButton); expect(sendTrackEvent).toHaveBeenCalledTimes(1); - expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.course_outline.certificate_alert_unverified_button.clicked', + expect(sendTrackEvent).toHaveBeenCalledWith( + 'edx.ui.lms.course_outline.certificate_alert_unverified_button.clicked', { courserun_key: courseId, is_staff: false, org_key: 'edX', - }); + }, + ); }); }); diff --git a/src/course-home/outline-tab/widgets/FlagButton.jsx b/src/course-home/outline-tab/widgets/FlagButton.jsx index 1c7a285944..48375cb212 100644 --- a/src/course-home/outline-tab/widgets/FlagButton.jsx +++ b/src/course-home/outline-tab/widgets/FlagButton.jsx @@ -12,8 +12,10 @@ function FlagButton({ return (