Просмотр исходного кода

fix non-auto fixable biome errors

Futa Arai 3 месяцев назад
Родитель
Сommit
08b010a3a9

+ 2 - 2
apps/app/src/client/components/CreateTemplateModal/CreateTemplateModal.tsx

@@ -104,11 +104,11 @@ export const CreateTemplateModal: React.FC<CreateTemplateModalProps> = ({
           </ModalHeader>
           <ModalBody>
             <div>
-              <label className="form-label mb-4">
+              <div className="form-label mb-4">
                 <code>{parentPath}</code>
                 <br />
                 {t('template.modal_label.Create template under')}
-              </label>
+              </div>
               <div className="row row-cols-2">
                 {renderTemplateCard('children', '_template')}
                 {renderTemplateCard('descendants', '__template')}

+ 3 - 3
apps/app/src/client/components/CustomNavigation/CustomNav.tsx

@@ -159,9 +159,9 @@ export const CustomNavTab = (props: CustomNavTabProps): JSX.Element => {
   }
 
   // Might make this dynamic for px, %, pt, em
-  function getPercentage(min, max) {
+  const getPercentage = useCallback((min: number, max: number) => {
     return (min / max) * 100;
-  }
+  }, []);
 
   useEffect(() => {
     if (activeTab == null || activeTab === '') {
@@ -189,7 +189,7 @@ export const CustomNavTab = (props: CustomNavTabProps): JSX.Element => {
 
       marginLeft += width;
     }
-  }, [activeTab, navTabRefs, navTabMapping]);
+  }, [activeTab, getPercentage, navTabRefs]);
 
   // determine inactive classes to hide NavItem
   const inactiveClassnames: string[] = [];

+ 3 - 1
apps/app/src/client/components/CustomNavigation/CustomNavAndContents.tsx

@@ -13,6 +13,8 @@ type CustomNavAndContentsProps = {
   navRightElement?: ReactNode;
 };
 
+type CustomNavComponent = typeof CustomNavTab;
+
 const CustomNavAndContents = (
   props: CustomNavAndContentsProps,
 ): JSX.Element => {
@@ -28,7 +30,7 @@ const CustomNavAndContents = (
     Object.keys(props.navTabMapping)[defaultTabIndex || 0],
   );
 
-  let SelectedNav;
+  let SelectedNav: CustomNavComponent = CustomNavTab;
   switch (navigationMode) {
     case 'tab':
       SelectedNav = CustomNavTab;

+ 2 - 2
apps/app/src/client/components/DeleteBookmarkFolderModal/DeleteBookmarkFolderModal.tsx

@@ -52,9 +52,9 @@ const DeleteBookmarkFolderModalSubstance = ({
       </ModalHeader>
       <ModalBody>
         <div className="pb-1 text-break">
-          <label className="form-label">
+          <div className="form-label">
             {t('bookmark_folder.delete_modal.modal_body_description')}:
-          </label>
+          </div>
           <br />
           <FolderIcon isOpen={false} /> {bookmarkFolder?.name}
         </div>

+ 1 - 3
apps/app/src/client/components/EmptyTrashModal/EmptyTrashModal.tsx

@@ -73,9 +73,7 @@ const EmptyTrashModalSubstance = ({
       </ModalHeader>
       <ModalBody>
         <div className="grw-scrollable-modal-body pb-1">
-          <label className="form-label">
-            {t('modal_delete.deleting_page')}:
-          </label>
+          <div className="form-label">{t('modal_delete.deleting_page')}:</div>
           <br />
           {/* Todo: change the way to show path on modal when too many pages are selected */}
           {renderPagePaths}

+ 3 - 2
apps/app/src/client/components/Maintenance/Maintenance.tsx

@@ -43,13 +43,14 @@ export const Maintenance = (): JSX.Element => {
             <span className="material-symbols-outlined">
               arrow_circle_right
             </span>
-            <a
+            <button
+              type="button"
               className="btn btn-link"
               onClick={logoutHandler}
               id="maintanounse-mode-logout"
             >
               {t('maintenance_mode.logout')}
-            </a>
+            </button>
           </p>
         ) : (
           <p>

+ 10 - 2
apps/app/src/client/components/PageHistory/PageRevisionTable.tsx

@@ -180,7 +180,11 @@ export const PageRevisionTable = (
               <label
                 className="form-label form-check-label"
                 htmlFor={`compareSource-${revisionId}`}
-              />
+              >
+                <span className="visually-hidden">
+                  {t('page_history.comparing_source')}
+                </span>
+              </label>
             </div>
           )}
         </td>
@@ -199,7 +203,11 @@ export const PageRevisionTable = (
               <label
                 className="form-label form-check-label"
                 htmlFor={`compareTarget-${revisionId}`}
-              />
+              >
+                <span className="visually-hidden">
+                  {t('page_history.comparing_target')}
+                </span>
+              </label>
             </div>
           )}
         </td>

+ 1 - 0
apps/app/src/client/components/PageHistory/RevisionDiff.tsx

@@ -141,6 +141,7 @@ export const RevisionDiff = (props: RevisioinDiffProps): JSX.Element => {
       {/* eslint-disable-next-line react/no-danger */}
       <div
         className="revision-history-diff pb-1"
+        // biome-ignore lint/security/noDangerouslySetInnerHtml: diff view is pre-sanitized HTML
         dangerouslySetInnerHTML={diffView}
       />
     </div>

+ 2 - 2
apps/app/src/client/components/PutbackPageModal/PutbackPageModal.tsx

@@ -94,9 +94,9 @@ const PutBackPageModalSubstance: FC<PutBackPageModalSubstanceProps> = ({
     () => (
       <>
         <div>
-          <label className="form-label">
+          <div className="form-label">
             {t('modal_putback.label.Put Back Page')}:
-          </label>
+          </div>
           <br />
           <code>{path}</code>
         </div>

+ 3 - 0
apps/app/src/client/components/ShortcutsModal/ShortcutsModal.tsx

@@ -41,6 +41,7 @@ const ShortcutsModalSubstance = (): React.JSX.Element => {
                   <span
                     className="text-nowrap"
                     // eslint-disable-next-line react/no-danger
+                    // biome-ignore lint/security/noDangerouslySetInnerHtml: i18n content includes markup
                     dangerouslySetInnerHTML={{
                       __html: t(
                         'modal_shortcuts.global.Open/Close shortcut help',
@@ -87,6 +88,7 @@ const ShortcutsModalSubstance = (): React.JSX.Element => {
                   <span
                     className="text-nowrap"
                     // eslint-disable-next-line react/no-danger
+                    // biome-ignore lint/security/noDangerouslySetInnerHtml: i18n content includes markup
                     dangerouslySetInnerHTML={{
                       __html: t('modal_shortcuts.global.Show Contributors'),
                     }}
@@ -248,6 +250,7 @@ const ShortcutsModalSubstance = (): React.JSX.Element => {
                 <div className="flex-grow-1">
                   <span
                     // eslint-disable-next-line react/no-danger
+                    // biome-ignore lint/security/noDangerouslySetInnerHtml: i18n content includes markup
                     dangerouslySetInnerHTML={{
                       __html: t('modal_shortcuts.editor.Insert Line'),
                     }}

+ 4 - 3
apps/app/src/client/components/StaffCredit/StaffCredit.tsx

@@ -101,14 +101,15 @@ const StaffCredit = (props: Props): JSX.Element => {
       );
     });
     return (
-      <div
-        className="text-center staff-credit-content"
+      <button
+        type="button"
+        className="text-center staff-credit-content btn btn-link p-0 border-0"
         onClick={contentsClickedHandler}
       >
         <h1 className="staff-credit-mb-6rem">GROWI Contributors</h1>
         <div className="clearfix"></div>
         {credit}
-      </div>
+      </button>
     );
   }, [contentsClickedHandler, contributors, renderMembers]);
 

+ 3 - 2
apps/app/src/client/components/TemplateModal/TemplateModal.tsx

@@ -71,7 +71,8 @@ const TemplateListGroupItem: React.FC<TemplateSummaryItemProps> = ({
   assert(localizedTemplate?.isValid);
 
   return (
-    <a
+    <button
+      type="button"
       className={`list-group-item list-group-item-action ${isSelected ? 'active' : ''}`}
       onClick={onClick}
     >
@@ -97,7 +98,7 @@ const TemplateListGroupItem: React.FC<TemplateSummaryItemProps> = ({
             {locale}
           </span>
         ))}
-    </a>
+    </button>
   );
 };