From 2228ae7197e3ef7a92d293d6bb06791f15c28f27 Mon Sep 17 00:00:00 2001 From: Ludy Date: Mon, 29 Sep 2025 13:21:48 +0200 Subject: [PATCH 1/6] ci(frontend): update licenses workflow dependencies and Node.js version (#4520) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description of Changes - Added the workflow file itself (`.github/workflows/frontend-licenses-update.yml`) to the trigger paths. - Updated `step-security/harden-runner` from **v2.12.2** → **v2.13.1**. - Bumped `actions/checkout` from **v4.2.2** → **v5.0.0**. - Upgraded `actions/setup-node` from **v4.1.0** (Node.js 18) → **v5.0.0** (Node.js 22). - Updated `actions/github-script` from **v7.0.1** → **v8.0.0**. These changes modernize the workflow, ensure compatibility with newer Node.js versions, and keep GitHub Actions up to date. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --- .github/workflows/frontend-licenses-update.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/frontend-licenses-update.yml b/.github/workflows/frontend-licenses-update.yml index fc3f3f9a9..33f295640 100644 --- a/.github/workflows/frontend-licenses-update.yml +++ b/.github/workflows/frontend-licenses-update.yml @@ -12,6 +12,7 @@ on: branches: - V2 paths: + - ".github/workflows/frontend-licenses-update.yml" - "frontend/package.json" - "frontend/package-lock.json" - "frontend/scripts/generate-licenses.js" @@ -28,12 +29,12 @@ jobs: repository-projects: write # Required for enabling automerge steps: - name: Harden Runner - uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2 + uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 with: egress-policy: audit - name: Checkout PR head (default) - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: fetch-depth: 0 persist-credentials: false @@ -48,7 +49,7 @@ jobs: - name: Checkout BASE branch (safe script) if: github.event_name == 'pull_request' - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: ref: ${{ github.event.pull_request.base.sha }} path: base @@ -56,9 +57,9 @@ jobs: persist-credentials: false - name: Set up Node.js - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: - node-version: '18' + node-version: '22' cache: 'npm' cache-dependency-path: frontend/package-lock.json @@ -114,7 +115,7 @@ jobs: # PR Event: Check licenses and comment on PR - name: Delete previous license check comments if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: github-token: ${{ steps.setup-bot.outputs.token }} script: | @@ -167,7 +168,7 @@ jobs: - name: Comment on PR - License Check Results if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: github-token: ${{ steps.setup-bot.outputs.token }} script: | From dd6b7968dbd02ab585fb3002fce8377056bd5ea8 Mon Sep 17 00:00:00 2001 From: Ludy Date: Mon, 29 Sep 2025 13:45:37 +0200 Subject: [PATCH 2/6] refactor(types): deduplicate `AutomateParameters` definition in automation types (#4522) # Description of Changes - Removed duplicate `AutomateParameters` interface from `frontend/src/types/automation.ts` - The interface was already defined earlier in the same file, leading to redundancy - Keeps type definitions consistent and avoids confusion --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com> --- frontend/src/types/automation.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frontend/src/types/automation.ts b/frontend/src/types/automation.ts index 8d9667fcf..78acc81b4 100644 --- a/frontend/src/types/automation.ts +++ b/frontend/src/types/automation.ts @@ -66,8 +66,3 @@ export interface SuggestedAutomation { updatedAt: string; icon: any; // MUI Icon component } - -// Export the AutomateParameters interface that was previously defined inline -export interface AutomateParameters extends AutomationExecutionCallbacks { - automationConfig?: AutomationConfig; -} \ No newline at end of file From c19abe0da79243d7c13be88f39081564747e75ff Mon Sep 17 00:00:00 2001 From: Ludy Date: Mon, 29 Sep 2025 13:48:35 +0200 Subject: [PATCH 3/6] refactor(frontend): add display names for forwardRef components (#4523) # Description of Changes - Added `displayName` properties to `QuickAccessBar` and `TextInput` components. - This improves debugging and React DevTools readability by ensuring components have clear, identifiable names instead of anonymous `ForwardRef`. - Minor formatting cleanup in `QuickAccessBar` for consistency. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com> --- frontend/src/components/shared/QuickAccessBar.tsx | 10 ++++++---- frontend/src/components/shared/TextInput.tsx | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/shared/QuickAccessBar.tsx b/frontend/src/components/shared/QuickAccessBar.tsx index 2ebe45002..8bc536bdb 100644 --- a/frontend/src/components/shared/QuickAccessBar.tsx +++ b/frontend/src/components/shared/QuickAccessBar.tsx @@ -41,10 +41,10 @@ const QuickAccessBar = forwardRef((_, ref) => { // Helper function to render navigation buttons with URL support const renderNavButton = (config: ButtonConfig, index: number) => { const isActive = isNavButtonActive(config, activeButton, isFilesModalOpen, configModalOpen, selectedToolKey, leftPanelView); - + // Check if this button has URL navigation support - const navProps = config.type === 'navigation' && (config.id === 'read' || config.id === 'automate') - ? getToolNavigation(config.id) + const navProps = config.type === 'navigation' && (config.id === 'read' || config.id === 'automate') + ? getToolNavigation(config.id) : null; const handleClick = (e?: React.MouseEvent) => { @@ -59,7 +59,7 @@ const QuickAccessBar = forwardRef((_, ref) => { return (
handleClick(e), @@ -249,4 +249,6 @@ const QuickAccessBar = forwardRef((_, ref) => { ); }); +QuickAccessBar.displayName = 'QuickAccessBar'; + export default QuickAccessBar; diff --git a/frontend/src/components/shared/TextInput.tsx b/frontend/src/components/shared/TextInput.tsx index a5dd90569..63c69bb08 100644 --- a/frontend/src/components/shared/TextInput.tsx +++ b/frontend/src/components/shared/TextInput.tsx @@ -107,3 +107,5 @@ export const TextInput = forwardRef(({
); }); + +TextInput.displayName = 'TextInput'; From 4ab66fdf148171c1daa78d800f085c03fec0f89c Mon Sep 17 00:00:00 2001 From: Ludy Date: Mon, 29 Sep 2025 13:51:42 +0200 Subject: [PATCH 4/6] feat(frontend): refactor ToolStep props handling and children usage (#4524) # Description of Changes - Replaced `children` being passed as a prop to `React.createElement` with proper usage as additional arguments (fixes `react/no-children-prop` warning). - Added stricter handling of `isVisible` and `_excludeFromCount` props with improved variable naming (`stepProps`) for clarity. - Refactored JSX structure for collapsed/expanded rendering logic to improve readability. This change was made to clean up prop handling, remove ESLint warnings, and make the component more consistent with React best practices. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com> --- .../src/components/tools/shared/ToolStep.tsx | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/tools/shared/ToolStep.tsx b/frontend/src/components/tools/shared/ToolStep.tsx index 4d9c5a187..b2140eb3f 100644 --- a/frontend/src/components/tools/shared/ToolStep.tsx +++ b/frontend/src/components/tools/shared/ToolStep.tsx @@ -164,13 +164,16 @@ export function createToolSteps() { const isVisible = props.isVisible !== false; const currentStepNumber = isVisible ? stepNumber++ : undefined; - const step = React.createElement(ToolStep, { - ...props, - title, - _stepNumber: currentStepNumber, - children, - key: `step-${title.toLowerCase().replace(/\s+/g, '-')}` - }); + const step = React.createElement( + ToolStep, + { + ...props, + title, + _stepNumber: currentStepNumber, + key: `step-${title.toLowerCase().replace(/\s+/g, '-')}` + }, + children + ); steps.push(step); return step; @@ -186,9 +189,9 @@ export function createToolSteps() { const getVisibleCount = () => { return steps.filter(step => { - const props = step.props as ToolStepProps; - const isVisible = props.isVisible !== false; - const excludeFromCount = props._excludeFromCount === true; + const stepProps = step.props as ToolStepProps; + const isVisible = stepProps.isVisible !== false; + const excludeFromCount = stepProps._excludeFromCount === true; return isVisible && !excludeFromCount; }).length; }; @@ -203,9 +206,9 @@ export function ToolStepProvider({ children, forceStepNumbers }: { children: Rea let count = 0; React.Children.forEach(children, (child) => { if (React.isValidElement(child) && child.type === ToolStep) { - const props = child.props as ToolStepProps; - const isVisible = props.isVisible !== false; - const excludeFromCount = props._excludeFromCount === true; + const stepProps = child.props as ToolStepProps; + const isVisible = stepProps.isVisible !== false; + const excludeFromCount = stepProps._excludeFromCount === true; if (isVisible && !excludeFromCount) count++; } }); From d4985f57d46adcc7b66629b7d9cea5df4fdca84c Mon Sep 17 00:00:00 2001 From: Ludy Date: Mon, 29 Sep 2025 13:55:53 +0200 Subject: [PATCH 5/6] style(frontend): standardize semicolons across TS/JS configs and components (#4525) # Description of Changes - **What was changed** - Added missing trailing semicolons across React components, utilities, tests, and build/test configs to ensure consistent formatting. - Normalized arrow-function assignments to end with semicolons (e.g., `const fn = () => { ... };`). - Harmonized imports/exports and object literals in configuration files to terminate statements with semicolons. - Updated test setup files and mocks to consistently use semicolons. - **Why the change was made** - Aligns the codebase with ESLint/Prettier conventions to prevent auto-format churn and avoid ASI (automatic semicolon insertion) edge cases. - Improves readability and produces cleaner diffs in future contributions. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com> --- frontend/src/components/shared/ToolChain.tsx | 2 +- frontend/src/components/shared/TopControls.tsx | 2 +- .../shared/quickAccessBar/ActiveToolButton.tsx | 8 ++++---- .../components/tools/ToolLoadingFallback.tsx | 2 +- .../tools/shared/ErrorNotification.tsx | 2 +- .../tools/shared/OperationButton.tsx | 2 +- .../src/components/tools/shared/ToolStep.tsx | 2 +- .../components/tools/split/SplitSettings.tsx | 2 +- frontend/src/constants/splitConstants.ts | 2 +- frontend/src/contexts/FileContext.tsx | 2 +- .../src/data/useTranslatedToolRegistry.tsx | 2 +- frontend/src/services/zipFileService.ts | 2 +- frontend/src/setupTests.ts | 18 +++++++++--------- .../tests/convert/ConvertIntegration.test.tsx | 2 +- frontend/src/utils/scarfTracking.ts | 2 +- frontend/tailwind.config.js | 6 +++--- frontend/vitest.config.ts | 4 ++-- frontend/vitest.minimal.config.ts | 4 ++-- 18 files changed, 33 insertions(+), 33 deletions(-) diff --git a/frontend/src/components/shared/ToolChain.tsx b/frontend/src/components/shared/ToolChain.tsx index b87b891a2..4d9a4bd51 100644 --- a/frontend/src/components/shared/ToolChain.tsx +++ b/frontend/src/components/shared/ToolChain.tsx @@ -32,7 +32,7 @@ const ToolChain: React.FC = ({ const getToolName = (toolId: ToolId) => { return t(`home.${toolId}.title`, toolId); - } + }; // Create full tool chain for tooltip const fullChainDisplay = displayStyle === 'badges' ? ( diff --git a/frontend/src/components/shared/TopControls.tsx b/frontend/src/components/shared/TopControls.tsx index 03eacc801..8edae6e72 100644 --- a/frontend/src/components/shared/TopControls.tsx +++ b/frontend/src/components/shared/TopControls.tsx @@ -15,7 +15,7 @@ const viewOptionStyle = { gap: 6, whiteSpace: 'nowrap', paddingTop: '0.3rem', -} +}; // Build view options showing text always diff --git a/frontend/src/components/shared/quickAccessBar/ActiveToolButton.tsx b/frontend/src/components/shared/quickAccessBar/ActiveToolButton.tsx index 5d58cf08c..9a08414b1 100644 --- a/frontend/src/components/shared/quickAccessBar/ActiveToolButton.tsx +++ b/frontend/src/components/shared/quickAccessBar/ActiveToolButton.tsx @@ -50,7 +50,7 @@ const ActiveToolButton: React.FC = ({ setActiveButton }) const animTimeoutRef = useRef(null); const replayRafRef = useRef(null); - const isSwitchingToNewTool = () => { return prevKeyRef.current && prevKeyRef.current !== selectedToolKey }; + const isSwitchingToNewTool = () => { return prevKeyRef.current && prevKeyRef.current !== selectedToolKey; }; const clearTimers = () => { if (collapseTimeoutRef.current) { @@ -81,7 +81,7 @@ const ActiveToolButton: React.FC = ({ setActiveButton }) setReplayAnim(false); animTimeoutRef.current = null; }, 500); - } + }; const firstShow = () => { clearTimers(); @@ -91,7 +91,7 @@ const ActiveToolButton: React.FC = ({ setActiveButton }) animTimeoutRef.current = window.setTimeout(() => { animTimeoutRef.current = null; }, 500); - } + }; const triggerCollapse = () => { clearTimers(); @@ -101,7 +101,7 @@ const ActiveToolButton: React.FC = ({ setActiveButton }) prevKeyRef.current = null; collapseTimeoutRef.current = null; }, 500); // match CSS transition duration - } + }; useEffect(() => { if (indicatorShouldShow) { diff --git a/frontend/src/components/tools/ToolLoadingFallback.tsx b/frontend/src/components/tools/ToolLoadingFallback.tsx index 8e41db433..9a2a4de14 100644 --- a/frontend/src/components/tools/ToolLoadingFallback.tsx +++ b/frontend/src/components/tools/ToolLoadingFallback.tsx @@ -10,5 +10,5 @@ export default function ToolLoadingFallback({ toolName }: { toolName?: string }) - ) + ); } diff --git a/frontend/src/components/tools/shared/ErrorNotification.tsx b/frontend/src/components/tools/shared/ErrorNotification.tsx index a1740a1f6..5b51ab11e 100644 --- a/frontend/src/components/tools/shared/ErrorNotification.tsx +++ b/frontend/src/components/tools/shared/ErrorNotification.tsx @@ -30,6 +30,6 @@ const ErrorNotification = ({ {error} ); -} +}; export default ErrorNotification; diff --git a/frontend/src/components/tools/shared/OperationButton.tsx b/frontend/src/components/tools/shared/OperationButton.tsx index 4733942a8..ec4a81e34 100644 --- a/frontend/src/components/tools/shared/OperationButton.tsx +++ b/frontend/src/components/tools/shared/OperationButton.tsx @@ -52,6 +52,6 @@ const OperationButton = ({ } ); -} +}; export default OperationButton; diff --git a/frontend/src/components/tools/shared/ToolStep.tsx b/frontend/src/components/tools/shared/ToolStep.tsx index b2140eb3f..e20af455c 100644 --- a/frontend/src/components/tools/shared/ToolStep.tsx +++ b/frontend/src/components/tools/shared/ToolStep.tsx @@ -149,7 +149,7 @@ const ToolStep = ({ ); -} +}; // ToolStepFactory for creating numbered steps export function createToolSteps() { diff --git a/frontend/src/components/tools/split/SplitSettings.tsx b/frontend/src/components/tools/split/SplitSettings.tsx index dc7c02480..ca20c24cc 100644 --- a/frontend/src/components/tools/split/SplitSettings.tsx +++ b/frontend/src/components/tools/split/SplitSettings.tsx @@ -158,6 +158,6 @@ const SplitSettings = ({ {parameters.method === SPLIT_METHODS.BY_PAGE_DIVIDER && renderByPageDividerForm()} ); -} +}; export default SplitSettings; diff --git a/frontend/src/constants/splitConstants.ts b/frontend/src/constants/splitConstants.ts index 890f94b3c..9f849203e 100644 --- a/frontend/src/constants/splitConstants.ts +++ b/frontend/src/constants/splitConstants.ts @@ -22,7 +22,7 @@ export const ENDPOINTS = { export type SplitMethod = typeof SPLIT_METHODS[keyof typeof SPLIT_METHODS]; export const isSplitMethod = (value: string | null): value is SplitMethod => { return Object.values(SPLIT_METHODS).includes(value as SplitMethod); -} +}; import { CardOption } from '../components/shared/CardSelector'; diff --git a/frontend/src/contexts/FileContext.tsx b/frontend/src/contexts/FileContext.tsx index 921c88333..62f458eaf 100644 --- a/frontend/src/contexts/FileContext.tsx +++ b/frontend/src/contexts/FileContext.tsx @@ -76,7 +76,7 @@ function FileContextInner({ const currentSelection = stateRef.current.ui.selectedFileIds; const newFileIds = stirlingFiles.map(stirlingFile => stirlingFile.fileId); dispatch({ type: 'SET_SELECTED_FILES', payload: { fileIds: [...currentSelection, ...newFileIds] } }); - } + }; // File operations using unified addFiles helper with persistence const addRawFiles = useCallback(async (files: File[], options?: { insertAfterPageId?: string; selectFiles?: boolean }): Promise => { diff --git a/frontend/src/data/useTranslatedToolRegistry.tsx b/frontend/src/data/useTranslatedToolRegistry.tsx index 6d5810055..920c654ee 100644 --- a/frontend/src/data/useTranslatedToolRegistry.tsx +++ b/frontend/src/data/useTranslatedToolRegistry.tsx @@ -92,7 +92,7 @@ import SignSettings from "../components/tools/sign/SignSettings"; import CropSettings from "../components/tools/crop/CropSettings"; import RemoveAnnotations from "../tools/RemoveAnnotations"; import RemoveAnnotationsSettings from "../components/tools/removeAnnotations/RemoveAnnotationsSettings"; -import PageLayoutSettings from "../components/tools/pageLayout/PageLayoutSettings" +import PageLayoutSettings from "../components/tools/pageLayout/PageLayoutSettings"; import ExtractImages from "../tools/ExtractImages"; import ExtractImagesSettings from "../components/tools/extractImages/ExtractImagesSettings"; import ReplaceColorSettings from "../components/tools/replaceColor/ReplaceColorSettings"; diff --git a/frontend/src/services/zipFileService.ts b/frontend/src/services/zipFileService.ts index daca80e51..36321ffa0 100644 --- a/frontend/src/services/zipFileService.ts +++ b/frontend/src/services/zipFileService.ts @@ -11,7 +11,7 @@ interface CompressedObject { const getData = (zipEntry: JSZipObject): CompressedObject | undefined => { return (zipEntry as any)._data as CompressedObject; -} +}; export interface ZipExtractionResult { success: boolean; diff --git a/frontend/src/setupTests.ts b/frontend/src/setupTests.ts index b640be3b6..38456157a 100644 --- a/frontend/src/setupTests.ts +++ b/frontend/src/setupTests.ts @@ -1,5 +1,5 @@ -import '@testing-library/jest-dom' -import { vi } from 'vitest' +import '@testing-library/jest-dom'; +import { vi } from 'vitest'; // Mock i18next for tests vi.mock('react-i18next', () => ({ @@ -27,8 +27,8 @@ vi.mock('i18next-http-backend', () => ({ })); // Mock window.URL.createObjectURL and revokeObjectURL for tests -global.URL.createObjectURL = vi.fn(() => 'mocked-url') -global.URL.revokeObjectURL = vi.fn() +global.URL.createObjectURL = vi.fn(() => 'mocked-url'); +global.URL.revokeObjectURL = vi.fn(); // Mock File and Blob API methods that aren't available in jsdom if (!globalThis.File.prototype.arrayBuffer) { @@ -88,21 +88,21 @@ global.Worker = vi.fn().mockImplementation(() => ({ removeEventListener: vi.fn(), onmessage: null, onerror: null, -})) +})); // Mock ResizeObserver for Mantine components global.ResizeObserver = vi.fn().mockImplementation(() => ({ observe: vi.fn(), unobserve: vi.fn(), disconnect: vi.fn(), -})) +})); // Mock IntersectionObserver for components that might use it global.IntersectionObserver = vi.fn().mockImplementation(() => ({ observe: vi.fn(), unobserve: vi.fn(), disconnect: vi.fn(), -})) +})); // Mock matchMedia for responsive components Object.defineProperty(window, 'matchMedia', { @@ -117,7 +117,7 @@ Object.defineProperty(window, 'matchMedia', { removeEventListener: vi.fn(), dispatchEvent: vi.fn(), })), -}) +}); // Set global test timeout to prevent hangs -vi.setConfig({ testTimeout: 5000, hookTimeout: 5000 }) +vi.setConfig({ testTimeout: 5000, hookTimeout: 5000 }); diff --git a/frontend/src/tests/convert/ConvertIntegration.test.tsx b/frontend/src/tests/convert/ConvertIntegration.test.tsx index c2398dab7..a7a6cda06 100644 --- a/frontend/src/tests/convert/ConvertIntegration.test.tsx +++ b/frontend/src/tests/convert/ConvertIntegration.test.tsx @@ -452,7 +452,7 @@ describe('Convert Tool Integration Tests', () => { const files = [ createPDFFile(), createTestStirlingFile('test2.pdf', '%PDF-1.4...', 'application/pdf') - ] + ]; const parameters: ConvertParameters = { fromExtension: 'pdf', toExtension: 'png', diff --git a/frontend/src/utils/scarfTracking.ts b/frontend/src/utils/scarfTracking.ts index 1d88da97c..1c6688b00 100644 --- a/frontend/src/utils/scarfTracking.ts +++ b/frontend/src/utils/scarfTracking.ts @@ -17,7 +17,7 @@ export function firePixel(pathname: string): void { lastFiredTime = now; const url = 'https://static.scarf.sh/a.png?x-pxid=3c1d68de-8945-4e9f-873f-65320b6fabf7' - + '&path=' + encodeURIComponent(pathname) + + '&path=' + encodeURIComponent(pathname); const img = new Image(); img.referrerPolicy = "no-referrer-when-downgrade"; diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js index 405c2bbc1..327bb64a0 100644 --- a/frontend/tailwind.config.js +++ b/frontend/tailwind.config.js @@ -63,11 +63,11 @@ module.exports = { background: 'rgb(var(--background) / )', border: 'rgb(var(--border) / )', }, - + // Z-index scale zIndex: { 'dropdown': '1000', - 'sticky': '1020', + 'sticky': '1020', 'fixed': '1030', 'modal-backdrop': '1040', 'modal': '1050', @@ -81,4 +81,4 @@ module.exports = { corePlugins: { preflight: true, }, -} \ No newline at end of file +}; diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts index c31c17675..dd393c6be 100644 --- a/frontend/vitest.config.ts +++ b/frontend/vitest.config.ts @@ -1,4 +1,4 @@ -import { defineConfig } from 'vitest/config' +import { defineConfig } from 'vitest/config'; import react from '@vitejs/plugin-react-swc'; export default defineConfig({ @@ -37,4 +37,4 @@ export default defineConfig({ '@': '/src' } } -}) +}); diff --git a/frontend/vitest.minimal.config.ts b/frontend/vitest.minimal.config.ts index 335af4e9c..c6c9b5672 100644 --- a/frontend/vitest.minimal.config.ts +++ b/frontend/vitest.minimal.config.ts @@ -1,4 +1,4 @@ -import { defineConfig } from 'vitest/config' +import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { @@ -6,4 +6,4 @@ export default defineConfig({ testTimeout: 5000, include: ['src/utils/convertUtils.test.ts'] }, -}) \ No newline at end of file +}); From 02189a67bda972840b03cd1fa5f5035a684059de Mon Sep 17 00:00:00 2001 From: Ludy Date: Mon, 29 Sep 2025 14:01:09 +0200 Subject: [PATCH 6/6] refactor(frontend): remove unused React default imports (#4529) ## Description of Changes - Removed unused `React` default imports across multiple frontend components. - Updated imports to only include required React hooks and types (e.g., `useState`, `useEffect`, `Suspense`, `createContext`). - Ensured consistency with React 17+ JSX transform, where default `React` import is no longer required. - This cleanup reduces bundle size slightly and aligns code with modern React best practices. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com> --- frontend/src/App.tsx | 2 +- .../src/components/shared/FilePickerModal.tsx | 2 +- .../components/shared/FileUploadButton.tsx | 2 +- frontend/src/components/shared/Footer.tsx | 1 - .../components/shared/MultiSelectControls.tsx | 11 +++--- .../shared/NavigationWarningModal.tsx | 1 - .../shared/RainbowThemeProvider.tsx | 2 +- .../src/components/toast/ToastRenderer.tsx | 11 +++--- .../src/components/tools/ToolRenderer.tsx | 4 +-- .../AddWatermarkSingleStepSettings.tsx | 5 ++- .../addWatermark/WatermarkFormatting.tsx | 3 +- .../tools/addWatermark/WatermarkImageFile.tsx | 1 - .../addWatermark/WatermarkStyleSettings.tsx | 3 +- .../tools/addWatermark/WatermarkTextStyle.tsx | 3 +- .../tools/automate/AutomationSelection.tsx | 9 +++-- .../BookletImpositionSettings.tsx | 4 +-- .../tools/compress/CompressSettings.tsx | 2 +- .../convert/ConvertFromEmailSettings.tsx | 1 - .../convert/ConvertFromImageSettings.tsx | 1 - .../tools/convert/ConvertFromWebSettings.tsx | 1 - .../tools/convert/ConvertSettings.tsx | 2 +- .../tools/convert/ConvertToImageSettings.tsx | 1 - .../tools/convert/ConvertToPdfaSettings.tsx | 1 - .../tools/convert/GroupedFormatDropdown.tsx | 36 +++++++++---------- .../tools/pageLayout/PageLayoutSettings.tsx | 1 - .../ReorganizePagesSettings.tsx | 3 +- .../replaceColor/ReplaceColorSettings.tsx | 3 +- .../components/tools/shared/FileMetadata.tsx | 3 +- .../tools/shared/NavigationControls.tsx | 1 - .../tools/shared/NumberInputWithUnit.tsx | 20 +++++------ .../tools/shared/OperationButton.tsx | 1 - .../tools/shared/ResultsPreview.tsx | 2 +- .../components/tools/sign/SignSettings.tsx | 4 +-- .../tools/toolPicker/ToolSearch.tsx | 2 +- .../components/viewer/CustomSearchLayer.tsx | 20 +++++------ .../viewer/LocalEmbedPDFWithAnnotations.tsx | 4 +-- .../components/viewer/PdfViewerToolbar.tsx | 12 +++---- .../components/viewer/ThumbnailSidebar.tsx | 2 +- frontend/src/components/viewer/Viewer.tsx | 3 +- frontend/src/contexts/FileContext.tsx | 2 +- frontend/src/contexts/SidebarContext.tsx | 6 ++-- frontend/src/tools/OCR.tsx | 2 +- frontend/src/tools/RemovePages.tsx | 1 - frontend/src/tools/ReorganizePages.tsx | 2 +- 44 files changed, 90 insertions(+), 113 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index da9a14eb5..529da2643 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import React, { Suspense } from "react"; +import { Suspense } from "react"; import { RainbowThemeProvider } from "./components/shared/RainbowThemeProvider"; import { FileContextProvider } from "./contexts/FileContext"; import { NavigationProvider } from "./contexts/NavigationContext"; diff --git a/frontend/src/components/shared/FilePickerModal.tsx b/frontend/src/components/shared/FilePickerModal.tsx index fde20f014..9bb2694a1 100644 --- a/frontend/src/components/shared/FilePickerModal.tsx +++ b/frontend/src/components/shared/FilePickerModal.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import { useState, useEffect } from 'react'; import { Modal, Text, diff --git a/frontend/src/components/shared/FileUploadButton.tsx b/frontend/src/components/shared/FileUploadButton.tsx index 434aad1b4..f09cc19d0 100644 --- a/frontend/src/components/shared/FileUploadButton.tsx +++ b/frontend/src/components/shared/FileUploadButton.tsx @@ -1,4 +1,4 @@ -import React, { useRef } from "react"; +import { useRef } from "react"; import { FileButton, Button } from "@mantine/core"; import { useTranslation } from "react-i18next"; diff --git a/frontend/src/components/shared/Footer.tsx b/frontend/src/components/shared/Footer.tsx index 137914617..0c94efa0e 100644 --- a/frontend/src/components/shared/Footer.tsx +++ b/frontend/src/components/shared/Footer.tsx @@ -1,5 +1,4 @@ import { Flex } from '@mantine/core'; -import React from 'react'; import { useTranslation } from 'react-i18next'; import { useCookieConsent } from '../../hooks/useCookieConsent'; diff --git a/frontend/src/components/shared/MultiSelectControls.tsx b/frontend/src/components/shared/MultiSelectControls.tsx index 11790abf8..b6e0b24b9 100644 --- a/frontend/src/components/shared/MultiSelectControls.tsx +++ b/frontend/src/components/shared/MultiSelectControls.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { Box, Group, Text, Button } from "@mantine/core"; import { useTranslation } from "react-i18next"; @@ -37,7 +36,7 @@ const MultiSelectControls = ({ > {t("fileManager.clearSelection", "Clear Selection")} - + {onAddToUpload && (