chore: fix various lint/type issues found by oxlint (#2850)

This commit is contained in:
Braden MacDonald
2026-01-30 17:01:11 -08:00
committed by GitHub
parent b0066e547c
commit 6effb4d39e
36 changed files with 120 additions and 78 deletions

View File

@@ -1,3 +1,4 @@
// oxlint-disable unicorn/no-useless-spread
/* eslint-disable react/prop-types */
import userEvent from '@testing-library/user-event';

View File

@@ -23,7 +23,9 @@ const ReleaseInfoComponent = () => {
);
}
return releaseInfo.message;
// istanbul ignore next
// eslint-disable-next-line react/jsx-no-useless-fragment
return <>{releaseInfo.message}</>;
};
export default ReleaseInfoComponent;

View File

@@ -29,6 +29,16 @@ const messages = defineMessages({
id: 'course-authoring.course-unit.sidebar.body.note',
defaultMessage: 'Note: Do not hide graded assignments after they have been released.',
},
publishInfoDraftSaved: {
id: 'course-authoring.course-unit.publish.info.draft.saved',
defaultMessage: 'DRAFT SAVED',
description: 'Label for the draft date in the publish info section',
},
publishLastPublished: {
id: 'course-authoring.course-unit.publish.info.last.published',
defaultMessage: 'LAST PUBLISHED',
description: 'Label for the last published date in the publish info section',
},
publishInfoPreviouslyPublished: {
id: 'course-authoring.course-unit.publish.info.previously-published',
defaultMessage: 'Previously published',

View File

@@ -5,20 +5,32 @@ import {
Lock,
} from '@openedx/paragon/icons';
import type { IntlShape } from 'react-intl';
import { ICON_COLOR_VARIANTS, UNIT_VISIBILITY_STATES } from '../constants';
import messages from './messages';
/**
* Get information about the publishing status.
* @param {Object} intl - The internationalization object.
* @param {boolean} hasChanges - Indicates if there are unpublished changes.
* @param {string} editedBy - The user who edited the content.
* @param {string} editedOn - The timestamp when the content was edited.
* @param {string} publishedBy - The user who last published the content.
* @param {string} publishedOn - The timestamp when the content was last published.
* @returns {string} Publish information based on the provided parameters.
* @param intl - The internationalization object.
* @param hasChanges - Indicates if there are unpublished changes.
* @param editedBy - The user who edited the content.
* @param editedOn - The timestamp when the content was edited.
* @param publishedBy - The user who last published the content.
* @param publishedOn - The timestamp when the content was last published.
* @returns Publish information based on the provided parameters.
*/
export const getPublishInfo = (intl, hasChanges, editedBy, editedOn, publishedBy, publishedOn) => {
// this fn appears to be unused - <SidebarBody> is never called with displayUnitLocation=false.
// Ingoring it for coverage for now and we'll delete the whole legacy sidebar soon.
// istanbul ignore next
export const getPublishInfo = (
intl: IntlShape,
hasChanges: boolean,
editedBy: string,
editedOn: string,
publishedBy: string,
publishedOn: any,
): string => {
let publishInfoText;
if (hasChanges && editedOn && editedBy) {
publishInfoText = intl.formatMessage(messages.publishInfoDraftSaved, { editedOn, editedBy });
@@ -33,12 +45,12 @@ export const getPublishInfo = (intl, hasChanges, editedBy, editedOn, publishedBy
/**
* Get information about the release status.
* @param {Object} intl - The internationalization object.
* @param {string} releaseDate - The release date of the content.
* @param {string} releaseDateFrom - The section name associated with the release date.
* @returns {string|ReactElement} Release information based on the provided parameters.
* @param intl - The internationalization object.
* @param releaseDate - The release date of the content.
* @param releaseDateFrom - The section name associated with the release date.
* @returns Release information based on the provided parameters.
*/
export const getReleaseInfo = (intl, releaseDate, releaseDateFrom) => {
export const getReleaseInfo = (intl: IntlShape, releaseDate: string, releaseDateFrom: string) => {
if (releaseDate) {
return {
isScheduled: true,
@@ -55,14 +67,14 @@ export const getReleaseInfo = (intl, releaseDate, releaseDateFrom) => {
/**
* Get the icon variant based on the provided visibility state and publication status.
* @param {string} visibilityState - The visibility state of the content.
* @param {boolean} published - Indicates if the content is published.
* @param {boolean} hasChanges - Indicates if there are unpublished changes.
* @returns {Object} An object containing the icon component and color variant.
* @param visibilityState - The visibility state of the content.
* @param published - Indicates if the content is published.
* @param hasChanges - Indicates if there are unpublished changes.
* @returns An object containing the icon component and color variant.
* - iconSrc: The source component for the icon.
* - colorVariant: The color variant for the icon.
*/
export const getIconVariant = (visibilityState, published, hasChanges) => {
export const getIconVariant = (visibilityState: string, published: boolean, hasChanges: boolean) => {
const iconVariants = {
[UNIT_VISIBILITY_STATES.staffOnly]: { iconSrc: Lock, colorVariant: ICON_COLOR_VARIANTS.PRIMARY },
[UNIT_VISIBILITY_STATES.live]: { iconSrc: CheckCircleIcon, colorVariant: ICON_COLOR_VARIANTS.GREEN },
@@ -81,7 +93,7 @@ export const getIconVariant = (visibilityState, published, hasChanges) => {
/**
* Extracts the clear course unit ID from the given course unit data.
* @param {string} id - The course unit ID.
* @returns {string} The clear course unit ID extracted from the provided data.
* @param id - The course unit ID.
* @returns The clear course unit ID extracted from the provided data.
*/
export const extractCourseUnitId = (id) => id.match(/block@(.+)$/)[1];
export const extractCourseUnitId = (id: string): string => id.match(/block@(.+)$/)![1];

View File

@@ -27,7 +27,7 @@ const courseId = '1234567890';
const closeModalMockFn = jest.fn() as jest.MockedFunction<() => void>;
const openModalMockFn = jest.fn() as jest.MockedFunction<() => void>;
const scrollToMockFn = jest.fn() as jest.MockedFunction<() => void>;
const sections: IXBlock[] | any = camelCaseObject(courseOutlineInfoMock)?.childInfo.children || [];
const sections: IXBlock[] = camelCaseObject(courseOutlineInfoMock)?.childInfo.children || [];
const subsections: IXBlock[] = sections[1]?.childInfo?.children || [];
const units: IXBlock[] = subsections[1]?.childInfo?.children || [];
const components: IXBlock[] = units[0]?.childInfo?.children || [];

View File

@@ -85,7 +85,7 @@ const UnitInfoSettings = () => {
const handleUpdate = async (
isVisible: boolean,
groupAccess: Object | null,
groupAccess: Record<string, any> | null,
isDiscussionEnabled: boolean,
) => {
// oxlint-disable-next-line @typescript-eslint/await-thenable - this dispatch() IS returning a promise.