Skip to content

Commit 4980c7a

Browse files
test: expand oxlint config for better eslint parity (#2972)
* test: expand oxlint config, enable 'react' lints, remove temporary disable * chore: fix missing keys * chore: other miscellaneous fixes * test: re-enable oxlint check for "no-unused-vars" * chore: remove unused imports * test: improve test coverage slightly
1 parent 199823a commit 4980c7a

36 files changed

Lines changed: 111 additions & 73 deletions

File tree

.oxlintrc.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@
33
"categories": {
44
"correctness": "warn"
55
},
6+
"plugins": ["react"],
67
"rules": {
7-
"eslint/no-unused-vars": "off",
8-
"typescript/unbound-method": "off", // 🛑 TEMPORARY
8+
"eslint/no-unused-vars": ["warn", {
9+
// Allow using {ignoredProp, ...keepTheRest} to omit a prop like 'ignoredProp' from an object.
10+
"ignoreRestSiblings": true,
11+
}],
12+
// We disable exhaustive-deps because: it's noisy, and we often include extra deps when we want a memoized thing to
13+
// re-calculate after some change, even if we're not using that thing in the calculation.
14+
"react-hooks/exhaustive-deps": "off",
15+
// Rule of hooks is useful, but not on by default:
16+
"react/rules-of-hooks": "warn",
917
"typescript/no-floating-promises": ["error", {
1018
"allowForKnownSafeCalls": [
1119
// queryClient.invalidateQueries returns a promise that can be awaited

plugins/course-apps/teams/GroupEditor.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const GroupEditor = ({
4848
? (
4949
<div className="d-flex flex-column card rounded mb-3 px-4 py-2 p-4" key="isDeleting">
5050
<h4 className="mb-3">{intl.formatMessage(messages.groupDeleteHeading)}</h4>
51-
{intl.formatMessage(messages.groupDeleteBody).split('\n').map(text => <p>{text}</p>)}
51+
{intl.formatMessage(messages.groupDeleteBody).split('\n').map(text => <p key={text}>{text}</p>)}
5252
<div className="d-flex flex-row justify-content-end">
5353
<Button variant="muted" size="sm" onClick={cancelDeletion}>
5454
{intl.formatMessage(messages.cancel)}

src/advanced-settings/AdvancedSettings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ const AdvancedSettings = () => {
282282
role="dialog"
283283
actions={[
284284
!isQueryPending ? (
285-
<Button variant="tertiary" onClick={handleResetSettingsValues}>
285+
<Button key="cancelBtn" variant="tertiary" onClick={handleResetSettingsValues}>
286286
{intl.formatMessage(messages.buttonCancelText)}
287287
</Button>
288288
) : /* istanbul ignore next */ null,

src/course-libraries/OutOfSyncAlert.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ export const OutOfSyncAlert: React.FC<OutOfSyncAlertProps> = ({
6767
variant="info"
6868
onClose={dismissAlert}
6969
actions={[
70-
<Button
71-
onClick={onReview}
72-
>
70+
<Button key="review-btn" onClick={onReview}>
7371
{intl.formatMessage(messages.outOfSyncCountAlertReviewBtn)}
7472
</Button>,
7573
]}

src/course-outline/CourseOutline.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { UnlinkModal } from '@src/generic/unlink-modal';
2828
import AlertMessage from '@src/generic/alert-message';
2929
import getPageHeadTitle from '@src/generic/utils';
3030
import CourseOutlineHeaderActionsSlot from '@src/plugin-slots/CourseOutlineHeaderActionsSlot';
31-
import { XBlock } from '@src/data/types';
3231
import { useCourseAuthoringContext } from '@src/CourseAuthoringContext';
3332
import { useCourseOutlineContext } from './CourseOutlineContext';
3433
import LegacyLibContentBlockAlert from '@src/course-libraries/LegacyLibContentBlockAlert';
@@ -72,8 +71,6 @@ const CourseOutline = () => {
7271
closeUnlinkModal,
7372
} = useCourseAuthoringContext();
7473
const {
75-
handleAddBlock,
76-
handleAddAndOpenUnit,
7774
currentSelection,
7875
sections,
7976
restoreSectionList,

src/course-outline/CourseOutlineContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useDispatch, useSelector } from 'react-redux';
55
import { useToggle } from '@openedx/paragon';
66
import { arrayMove } from '@dnd-kit/sortable';
77

8-
import { SelectionState, type UnitXBlock, type XBlock } from '@src/data/types';
8+
import { SelectionState, type XBlock } from '@src/data/types';
99
import { useToggleWithValue } from '@src/hooks';
1010
import { getBlockType } from '@src/generic/key-utils';
1111
import { COURSE_BLOCK_NAMES } from '@src/constants';

src/course-outline/hooks.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import {
3838
enableCourseHighlightsEmailsQuery,
3939
fetchCourseBestPracticesQuery,
4040
fetchCourseLaunchQuery,
41-
fetchCourseOutlineIndexQuery,
4241
fetchCourseReindexQuery,
4342
setVideoSharingOptionQuery,
4443
dismissNotificationQuery,
@@ -52,7 +51,6 @@ const useCourseOutline = ({ courseId }) => {
5251
handleAddBlock,
5352
setCurrentSelection,
5453
currentSelection,
55-
isDuplicatingItem,
5654
isDeleteModalOpen,
5755
openDeleteModal,
5856
closeDeleteModal,

src/course-outline/page-alerts/PageAlerts.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const PageAlerts = ({
104104
onClose={onDismiss}
105105
actions={[
106106
<Button
107+
key="learnMore"
107108
href={discussionsIncontextLearnmoreUrl}
108109
target="_blank"
109110
>
@@ -267,6 +268,7 @@ const PageAlerts = ({
267268
onClose={onDismiss}
268269
actions={[
269270
<Button
271+
key="view-files"
270272
as={Link}
271273
to={getAssetsUrl()}
272274
>
@@ -329,6 +331,7 @@ const PageAlerts = ({
329331
onClose={onDismiss}
330332
actions={[
331333
<Button
334+
key="view-files"
332335
as={Link}
333336
to={getAssetsUrl()}
334337
>

src/course-unit/CourseUnit.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,12 @@ const CourseUnit = () => {
273273
</TransitionReplace>
274274
{courseUnit.upstreamInfo?.upstreamLink && (
275275
<AlertMessage
276-
title={intl.formatMessage(
276+
description={intl.formatMessage(
277277
messages.alertLibraryUnitReadOnlyText,
278278
{
279279
link: (
280-
<Alert.Link
281-
href={courseUnit.upstreamInfo.upstreamLink}
282-
>
283-
{intl.formatMessage(messages.alertLibraryUnitReadOnlyLinkText)}
280+
<Alert.Link href={courseUnit.upstreamInfo.upstreamLink}>
281+
<FormattedMessage {...messages.alertLibraryUnitReadOnlyLinkText} />
284282
</Alert.Link>
285283
),
286284
},

src/course-unit/clipboard/paste-notification/index.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const PastNotificationAlert = ({ staticFileNotices, courseId }) => {
4747
icon={WarningIcon}
4848
dismissible
4949
actions={[
50+
// oxlint-disable-next-line react/jsx-key (Paragon <Alert> adds its own key for action buttons)
5051
<ActionButton
5152
courseId={courseId}
5253
title={intl.formatMessage(messages.hasConflictingErrorsButtonText)}
@@ -87,6 +88,7 @@ const PastNotificationAlert = ({ staticFileNotices, courseId }) => {
8788
icon={InfoIcon}
8889
dismissible
8990
actions={[
91+
// oxlint-disable-next-line react/jsx-key (Paragon <Alert> adds its own key for action buttons)
9092
<ActionButton
9193
courseId={courseId}
9294
title={intl.formatMessage(messages.hasNewFilesButtonText)}

0 commit comments

Comments
 (0)