From 78299475aedec6137ea92a05414242045c7aa5fa Mon Sep 17 00:00:00 2001 From: Merlijn Vos Date: Tue, 1 Jul 2025 14:55:41 +0200 Subject: [PATCH] Migrate from Eslint/Prettier/Stylelint to Biome (#5794) --- .eslintignore | 8 - .eslintrc.js | 506 ----- .github/workflows/linters.yml | 4 +- .github/workflows/release-candidate.yml | 5 +- .prettierignore | 9 - .prettierrc.js | 22 - .remarkignore | 8 - .stylelintrc.json | 12 - .vscode/extensions.json | 3 + .vscode/uppy.code-workspace | 20 +- .vscode/uppy.code-workspace.bak | 29 - .../pre-commit-npm-1.2.2-f30af83877.patch | 34 - bin/build-components.mjs | 17 +- bin/build-css.js | 64 +- bin/update-contributors.mjs | 8 +- biome.json | 67 + e2e/clients/dashboard-aws-multipart/app.js | 2 +- e2e/clients/dashboard-aws/app.js | 2 +- e2e/clients/dashboard-compressor/app.js | 2 +- .../generateSignatureIfSecret.js | 24 +- e2e/clients/dashboard-tus/app.js | 2 +- e2e/clients/dashboard-ui/app.js | 16 +- e2e/clients/dashboard-vue/App.vue | 6 +- e2e/clients/dashboard-xhr/app.js | 7 +- e2e/clients/react/App.jsx | 7 +- e2e/clients/react/index.jsx | 1 - e2e/cypress.config.mjs | 2 +- e2e/cypress/fixtures/DeepFrozenStore.mjs | 17 +- .../dashboard-aws-multipart.spec.ts | 2 - .../integration/dashboard-transloadit.spec.ts | 5 +- e2e/cypress/integration/dashboard-tus.spec.ts | 2 +- e2e/cypress/integration/dashboard-xhr.spec.ts | 2 +- e2e/cypress/integration/react.spec.ts | 2 - e2e/cypress/support/createFakeFile.ts | 3 - e2e/cypress/support/e2e.ts | 1 - e2e/generate-test.mjs | 31 +- e2e/mock-server.mjs | 61 +- e2e/start-companion-with-load-balancer.mjs | 67 +- e2e/tsconfig.json | 4 +- .../angular-example/src/app/app.component.ts | 6 +- .../angular-example/src/app/app.module.ts | 4 +- examples/angular-example/src/main.ts | 2 +- examples/angular-example/src/styles.css | 8 +- examples/angular-example/tsconfig.json | 6 +- examples/aws-companion/server.cjs | 26 +- examples/aws-nodejs/index.js | 102 +- examples/aws-php/main.js | 28 +- examples/bundled/index.js | 10 +- examples/bundled/sw.js | 17 +- .../client/MyCustomProvider.jsx | 2 +- examples/custom-provider/client/main.js | 2 +- .../custom-provider/server/CustomProvider.cjs | 25 +- examples/custom-provider/server/index.cjs | 16 +- examples/digitalocean-spaces/main.js | 2 +- examples/digitalocean-spaces/server.cjs | 32 +- examples/node-xhr/main.js | 2 +- examples/node-xhr/server.js | 81 +- examples/php-xhr/main.js | 2 +- examples/python-xhr/main.js | 2 +- examples/react-native-expo/App.js | 74 +- examples/react-native-expo/FileList.js | 36 +- .../react-native-expo/PauseResumeButton.js | 18 +- examples/react-native-expo/ProgressBar.js | 22 +- .../react-native-expo/SelectFilesButton.js | 9 +- examples/react-native-expo/tusFileReader.js | 24 +- examples/react/src/App.tsx | 21 +- examples/react/src/CustomDropzone.tsx | 6 +- examples/react/src/MediaCapture.tsx | 2 - examples/react/src/RemoteSource.tsx | 18 +- examples/react/src/ScreenCapture.tsx | 3 +- examples/react/src/Webcam.tsx | 4 +- examples/react/src/app.css | 2 +- examples/react/src/main.tsx | 1 - examples/react/tsconfig.json | 4 +- examples/react/vite.config.ts | 5 +- examples/redux/main.js | 34 +- examples/sveltekit/src/app.css | 2 +- .../src/components/CustomDropzone.svelte | 14 +- .../src/components/MediaCapture.svelte | 48 +- .../src/components/RemoteSource.svelte | 52 +- .../src/components/ScreenCapture.svelte | 30 +- .../sveltekit/src/components/Webcam.svelte | 30 +- examples/sveltekit/src/routes/+layout.svelte | 6 +- examples/sveltekit/src/routes/+page.svelte | 68 +- examples/sveltekit/svelte.config.js | 26 +- examples/sveltekit/tsconfig.json | 4 +- examples/sveltekit/vite.config.ts | 3 +- examples/transloadit-markdown-bin/main.js | 49 +- examples/transloadit/main.js | 20 +- examples/transloadit/server.js | 46 +- examples/uppy-with-companion/server/index.js | 12 +- examples/vue3/src/App.vue | 28 +- examples/vue3/src/Dropzone.vue | 2 +- examples/vue3/src/RemoteSource.vue | 4 +- examples/vue3/src/app.css | 2 +- examples/vue3/vite.config.js | 4 +- examples/xhr-bundle/server.cjs | 2 +- package.json | 62 +- .../dashboard-modal-demo.component.ts | 18 +- .../dashboard-modal.component.spec.ts | 37 +- .../dashboard-modal.component.ts | 99 +- .../dashboard-modal.stories.ts | 18 +- .../dashboard/dashboard-demo.component.ts | 18 +- .../dashboard/dashboard.component.spec.ts | 37 +- .../dashboard/dashboard.component.ts | 71 +- .../components/dashboard/dashboard.stories.ts | 18 +- .../drag-drop/drag-drop-demo.component.ts | 18 +- .../drag-drop/drag-drop.component.spec.ts | 37 +- .../drag-drop/drag-drop.component.ts | 71 +- .../components/drag-drop/drag-drop.stories.ts | 24 +- .../progress-bar-demo.component.ts | 86 +- .../progress-bar.component.spec.ts | 37 +- .../progress-bar/progress-bar.component.ts | 71 +- .../progress-bar/progress-bar.stories.ts | 22 +- .../status-bar/status-bar-demo.component.ts | 43 +- .../status-bar/status-bar.component.spec.ts | 37 +- .../status-bar/status-bar.component.ts | 71 +- .../status-bar/status-bar.stories.ts | 18 +- .../uppy/angular/src/lib/utils/wrapper.ts | 100 +- .../projects/uppy/angular/src/public-api.ts | 10 +- packages/@uppy/angular/tsconfig.json | 6 +- packages/@uppy/audio/src/Audio.tsx | 24 +- packages/@uppy/audio/src/DiscardButton.tsx | 2 +- .../@uppy/audio/src/PermissionsScreen.tsx | 8 +- packages/@uppy/audio/src/RecordingLength.tsx | 13 +- packages/@uppy/audio/src/RecordingScreen.tsx | 21 +- packages/@uppy/audio/src/SubmitButton.tsx | 2 +- .../audio/src/audio-oscilloscope/index.ts | 9 +- packages/@uppy/audio/src/index.ts | 2 +- .../audio/src/supportsMediaRecorder.test.ts | 5 +- packages/@uppy/audio/tsconfig.json | 10 +- .../aws-s3/src/HTTPCommunicationQueue.ts | 24 +- .../@uppy/aws-s3/src/MultipartUploader.ts | 9 +- .../@uppy/aws-s3/src/createSignedURL.test.ts | 5 +- packages/@uppy/aws-s3/src/index.test.ts | 19 +- packages/@uppy/aws-s3/src/index.ts | 72 +- packages/@uppy/aws-s3/tsconfig.json | 12 +- packages/@uppy/box/src/Box.tsx | 23 +- packages/@uppy/box/src/index.ts | 2 +- packages/@uppy/box/tsconfig.json | 14 +- .../@uppy/companion-client/src/AuthError.ts | 2 - .../src/CompanionPluginOptions.ts | 2 +- .../@uppy/companion-client/src/Provider.ts | 17 +- .../src/RequestClient.test.ts | 2 +- .../companion-client/src/RequestClient.ts | 39 +- .../src/getAllowedHosts.test.ts | 2 +- .../companion-client/src/getAllowedHosts.ts | 5 +- packages/@uppy/companion-client/src/index.ts | 13 +- packages/@uppy/companion-client/tsconfig.json | 10 +- packages/@uppy/companion/src/companion.js | 185 +- .../@uppy/companion/src/config/companion.js | 71 +- packages/@uppy/companion/src/config/grant.js | 10 +- .../@uppy/companion/src/server/Uploader.js | 180 +- .../src/server/controllers/callback.js | 42 +- .../src/server/controllers/connect.js | 34 +- .../src/server/controllers/deauth-callback.js | 8 +- .../companion/src/server/controllers/get.js | 20 +- .../src/server/controllers/googlePicker.js | 18 +- .../companion/src/server/controllers/index.js | 1 - .../companion/src/server/controllers/list.js | 8 +- .../src/server/controllers/logout.js | 14 +- .../src/server/controllers/oauth-redirect.js | 17 +- .../src/server/controllers/preauth.js | 10 +- .../src/server/controllers/refresh-token.js | 31 +- .../companion/src/server/controllers/s3.js | 347 ++-- .../src/server/controllers/send-token.js | 12 +- .../src/server/controllers/simple-auth.js | 22 +- .../src/server/controllers/thumbnail.js | 8 +- .../companion/src/server/controllers/url.js | 20 +- .../@uppy/companion/src/server/download.js | 5 +- .../companion/src/server/emitter/index.js | 4 +- .../src/server/emitter/redis-emitter.js | 63 +- packages/@uppy/companion/src/server/got.js | 1 - .../companion/src/server/header-blacklist.js | 11 +- .../@uppy/companion/src/server/helpers/jwt.js | 25 +- .../companion/src/server/helpers/request.js | 68 +- .../companion/src/server/helpers/upload.js | 32 +- .../companion/src/server/helpers/utils.js | 136 +- packages/@uppy/companion/src/server/jobs.js | 56 +- packages/@uppy/companion/src/server/logger.js | 22 +- .../@uppy/companion/src/server/middlewares.js | 155 +- .../companion/src/server/provider/Provider.js | 38 +- .../src/server/provider/box/adapter.js | 7 +- .../src/server/provider/box/index.js | 72 +- .../src/server/provider/credentials.js | 91 +- .../src/server/provider/dropbox/index.js | 219 +- .../companion/src/server/provider/error.js | 14 +- .../src/server/provider/facebook/index.js | 101 +- .../server/provider/google/drive/adapter.js | 61 +- .../src/server/provider/google/drive/index.js | 205 +- .../src/server/provider/google/index.js | 55 +- .../companion/src/server/provider/index.js | 85 +- .../provider/instagram/graph/adapter.js | 2 +- .../server/provider/instagram/graph/index.js | 100 +- .../src/server/provider/onedrive/index.js | 101 +- .../src/server/provider/providerErrors.js | 37 +- .../src/server/provider/unsplash/adapter.js | 8 +- .../src/server/provider/unsplash/index.js | 59 +- .../src/server/provider/webdav/index.js | 66 +- .../src/server/provider/zoom/adapter.js | 43 +- .../src/server/provider/zoom/index.js | 137 +- packages/@uppy/companion/src/server/redis.js | 10 +- .../@uppy/companion/src/server/s3-client.js | 25 +- packages/@uppy/companion/src/server/socket.js | 33 +- .../@uppy/companion/src/standalone/helper.js | 88 +- .../@uppy/companion/src/standalone/index.js | 80 +- .../companion/test/__mocks__/tus-js-client.js | 9 +- .../companion/test/__tests__/callback.js | 30 +- .../companion/test/__tests__/companion.js | 98 +- .../@uppy/companion/test/__tests__/cors.js | 45 +- .../companion/test/__tests__/credentials.js | 43 +- .../test/__tests__/deauthorization.js | 34 +- .../companion/test/__tests__/http-agent.js | 21 +- .../@uppy/companion/test/__tests__/logger.js | 45 +- .../@uppy/companion/test/__tests__/preauth.js | 24 +- .../test/__tests__/provider-manager.js | 92 +- .../companion/test/__tests__/providers.js | 539 ++--- .../companion/test/__tests__/uploader.js | 134 +- .../@uppy/companion/test/__tests__/url.js | 37 +- .../@uppy/companion/test/fixtures/drive.js | 41 +- .../@uppy/companion/test/fixtures/index.js | 2 +- .../@uppy/companion/test/fixtures/zoom.js | 53 +- packages/@uppy/companion/test/mockserver.js | 15 +- packages/@uppy/companion/tsconfig.json | 5 +- packages/@uppy/components/src/Dropzone.tsx | 11 +- packages/@uppy/components/src/FilesGrid.tsx | 8 +- packages/@uppy/components/src/FilesList.tsx | 10 +- .../@uppy/components/src/ProviderIcon.tsx | 2 - packages/@uppy/components/src/Thumbnail.tsx | 46 +- .../@uppy/components/src/UploadButton.tsx | 26 +- .../components/src/hooks/remote-source.ts | 4 +- .../components/src/hooks/screencapture.ts | 21 +- packages/@uppy/components/src/hooks/webcam.ts | 2 +- packages/@uppy/components/src/index.ts | 76 +- packages/@uppy/components/src/input.css | 10 +- .../@uppy/components/src/uppyEventAdapter.ts | 3 +- packages/@uppy/components/tsconfig.json | 18 +- packages/@uppy/compressor/src/index.test.ts | 7 +- packages/@uppy/compressor/src/index.ts | 12 +- packages/@uppy/compressor/tsconfig.json | 10 +- packages/@uppy/core/src/BasePlugin.ts | 8 +- packages/@uppy/core/src/EventManager.ts | 4 +- packages/@uppy/core/src/Restricter.ts | 8 +- packages/@uppy/core/src/UIPlugin.test.ts | 2 +- packages/@uppy/core/src/UIPlugin.ts | 21 +- packages/@uppy/core/src/Uppy.test.ts | 25 +- packages/@uppy/core/src/Uppy.ts | 111 +- packages/@uppy/core/src/index.ts | 35 +- packages/@uppy/core/src/loggers.ts | 1 - .../@uppy/core/src/mocks/acquirerPlugin1.ts | 2 +- .../@uppy/core/src/mocks/acquirerPlugin2.ts | 2 +- .../@uppy/core/src/supportsUploadProgress.ts | 1 - packages/@uppy/core/src/types.test.ts | 6 +- packages/@uppy/core/tsconfig.json | 10 +- packages/@uppy/dashboard/src/Dashboard.tsx | 57 +- .../dashboard/src/components/AddFiles.tsx | 36 +- .../src/components/AddFilesPanel.tsx | 6 +- .../dashboard/src/components/Dashboard.tsx | 69 +- .../dashboard/src/components/EditorPanel.tsx | 4 +- .../components/FileCard/RenderMetaFields.tsx | 7 +- .../src/components/FileCard/index.tsx | 10 +- .../src/components/FileItem/Buttons/index.tsx | 14 +- .../components/FileItem/FileInfo/index.tsx | 15 +- .../FileItem/FilePreviewAndLink/index.tsx | 7 +- .../FileItem/FileProgress/index.tsx | 14 +- .../src/components/FileItem/index.tsx | 23 +- .../dashboard/src/components/FileList.tsx | 21 +- .../src/components/PickerPanelContent.tsx | 3 +- .../src/components/PickerPanelTopBar.tsx | 20 +- .../@uppy/dashboard/src/components/Slide.tsx | 6 +- packages/@uppy/dashboard/src/index.test.ts | 21 +- packages/@uppy/dashboard/src/index.ts | 2 +- .../src/utils/copyToClipboard.test.ts | 2 +- .../dashboard/src/utils/copyToClipboard.ts | 3 +- .../src/utils/createSuperFocus.test.ts | 2 +- .../dashboard/src/utils/createSuperFocus.ts | 3 +- .../@uppy/dashboard/src/utils/trapFocus.ts | 3 +- packages/@uppy/dashboard/tsconfig.json | 24 +- packages/@uppy/drag-drop/src/DragDrop.tsx | 20 +- packages/@uppy/drag-drop/src/index.ts | 2 +- packages/@uppy/drag-drop/tsconfig.json | 10 +- packages/@uppy/drop-target/src/index.ts | 4 +- packages/@uppy/drop-target/tsconfig.json | 10 +- packages/@uppy/dropbox/src/Dropbox.tsx | 23 +- packages/@uppy/dropbox/src/index.ts | 2 +- packages/@uppy/dropbox/tsconfig.json | 14 +- packages/@uppy/facebook/src/Facebook.tsx | 23 +- packages/@uppy/facebook/src/index.ts | 2 +- packages/@uppy/facebook/tsconfig.json | 14 +- packages/@uppy/file-input/src/FileInput.tsx | 18 +- packages/@uppy/file-input/src/index.ts | 2 +- packages/@uppy/file-input/tsconfig.json | 10 +- packages/@uppy/form/src/index.ts | 17 +- packages/@uppy/form/tsconfig.json | 10 +- .../golden-retriever/src/IndexedDBStore.ts | 1 - .../golden-retriever/src/MetaDataStore.ts | 2 +- .../golden-retriever/src/ServiceWorker.js | 17 +- packages/@uppy/golden-retriever/src/index.ts | 45 +- packages/@uppy/golden-retriever/tsconfig.json | 10 +- .../src/GoogleDrivePicker.tsx | 13 +- .../@uppy/google-drive-picker/tsconfig.json | 14 +- .../google-drive/src/DriveProviderViews.ts | 4 +- .../@uppy/google-drive/src/GoogleDrive.tsx | 23 +- packages/@uppy/google-drive/src/index.ts | 2 +- packages/@uppy/google-drive/tsconfig.json | 14 +- .../src/GooglePhotosPicker.tsx | 13 +- .../@uppy/google-photos-picker/tsconfig.json | 14 +- packages/@uppy/image-editor/src/Editor.tsx | 13 +- .../@uppy/image-editor/src/ImageEditor.tsx | 14 +- packages/@uppy/image-editor/src/index.ts | 2 +- ...anvasDataThatFitsPerfectlyIntoContainer.ts | 1 + packages/@uppy/image-editor/tsconfig.json | 10 +- packages/@uppy/informer/src/FadeIn.tsx | 2 +- packages/@uppy/informer/src/Informer.tsx | 12 +- .../@uppy/informer/src/TransitionGroup.ts | 26 +- packages/@uppy/informer/src/index.ts | 2 +- packages/@uppy/informer/tsconfig.json | 10 +- packages/@uppy/instagram/src/Instagram.tsx | 23 +- packages/@uppy/instagram/src/index.ts | 2 +- packages/@uppy/instagram/tsconfig.json | 14 +- packages/@uppy/locales/src/en_US.ts | 1 - packages/@uppy/locales/src/hi_IN.ts | 15 +- packages/@uppy/locales/src/ms_MY.ts | 1 - packages/@uppy/locales/src/pt_BR.ts | 1 - packages/@uppy/locales/src/th_TH.ts | 6 +- packages/@uppy/locales/template.ts | 1 - packages/@uppy/locales/tsconfig.json | 8 +- packages/@uppy/onedrive/src/OneDrive.tsx | 23 +- packages/@uppy/onedrive/src/index.ts | 2 +- packages/@uppy/onedrive/tsconfig.json | 14 +- .../@uppy/progress-bar/src/ProgressBar.tsx | 12 +- packages/@uppy/progress-bar/src/index.ts | 3 +- packages/@uppy/progress-bar/tsconfig.json | 10 +- .../@uppy/provider-views/src/Breadcrumbs.tsx | 10 +- packages/@uppy/provider-views/src/Browser.tsx | 11 +- .../provider-views/src/FooterActions.tsx | 6 +- .../src/GooglePicker/GooglePickerView.tsx | 27 +- .../src/GooglePicker/googlePicker.ts | 31 +- .../src/Item/components/GridItem.tsx | 2 +- .../src/Item/components/ItemIcon.tsx | 2 +- .../src/Item/components/ListItem.tsx | 79 +- .../@uppy/provider-views/src/Item/index.tsx | 8 +- .../src/ProviderView/AuthView.tsx | 13 +- .../src/ProviderView/Header.tsx | 9 +- .../src/ProviderView/ProviderView.tsx | 61 +- .../provider-views/src/ProviderView/User.tsx | 2 +- .../@uppy/provider-views/src/SearchInput.tsx | 6 +- .../SearchProviderView/SearchProviderView.tsx | 26 +- packages/@uppy/provider-views/src/index.ts | 6 +- .../src/utils/PartialTreeUtils/afterFill.ts | 17 +- .../PartialTreeUtils/afterToggleCheckbox.ts | 7 +- .../utils/PartialTreeUtils/getBreadcrumbs.ts | 1 - .../getCheckedFilesWithPaths.ts | 11 +- .../src/utils/PartialTreeUtils/index.test.ts | 211 +- .../src/utils/PartialTreeUtils/index.ts | 2 +- .../provider-views/src/utils/addFiles.ts | 2 +- .../provider-views/src/utils/getTagFile.ts | 2 +- packages/@uppy/provider-views/tsconfig.json | 10 +- .../@uppy/react-native/file-picker/index.js | 136 +- .../react-native/file-picker/instagram.js | 26 +- .../react-native/file-picker/provider-grid.js | 36 +- .../react-native/file-picker/provider.js | 3 +- .../file-picker/selectDocument.js | 4 +- .../react-native/file-picker/selectImage.js | 2 +- .../react-native/file-picker/takePicture.js | 18 +- .../@uppy/react-native/file-picker/url.js | 28 +- packages/@uppy/react/src/Dashboard.ts | 11 +- packages/@uppy/react/src/DashboardModal.ts | 8 +- packages/@uppy/react/src/DragDrop.ts | 7 +- packages/@uppy/react/src/FileInput.ts | 8 +- packages/@uppy/react/src/ProgressBar.ts | 7 +- packages/@uppy/react/src/StatusBar.ts | 7 +- .../src/headless/UppyContextProvider.tsx | 19 +- .../react/src/headless/generated/Dropzone.tsx | 5 +- .../src/headless/generated/FilesGrid.tsx | 5 +- .../src/headless/generated/FilesList.tsx | 5 +- .../src/headless/generated/ProviderIcon.tsx | 3 +- .../src/headless/generated/Thumbnail.tsx | 3 +- .../src/headless/generated/UploadButton.tsx | 3 +- packages/@uppy/react/src/index.ts | 21 +- packages/@uppy/react/src/useDropzone.ts | 12 +- packages/@uppy/react/src/useFileInput.ts | 7 +- packages/@uppy/react/src/useRemoteSource.ts | 6 +- packages/@uppy/react/src/useScreenCapture.ts | 4 +- packages/@uppy/react/src/useUppyEvent.test.ts | 7 +- packages/@uppy/react/src/useUppyEvent.ts | 3 +- .../@uppy/react/src/useUppyState.test.tsx | 6 +- packages/@uppy/react/src/useUppyState.ts | 4 +- packages/@uppy/react/src/useWebcam.ts | 2 +- packages/@uppy/react/tsconfig.json | 26 +- packages/@uppy/redux-dev-tools/src/index.js | 26 +- packages/@uppy/redux-dev-tools/tsconfig.json | 4 +- .../@uppy/remote-sources/src/index.test.ts | 4 +- packages/@uppy/remote-sources/src/index.ts | 17 +- packages/@uppy/remote-sources/tsconfig.json | 28 +- .../screen-capture/src/DiscardButton.tsx | 2 +- .../@uppy/screen-capture/src/RecordButton.tsx | 3 +- .../screen-capture/src/RecorderScreen.tsx | 52 +- .../screen-capture/src/ScreenCapture.tsx | 53 +- .../screen-capture/src/ScreenRecIcon.tsx | 1 - .../@uppy/screen-capture/src/StopWatch.tsx | 5 +- .../@uppy/screen-capture/src/StreamStatus.tsx | 3 - .../@uppy/screen-capture/src/SubmitButton.tsx | 3 +- packages/@uppy/screen-capture/src/index.ts | 3 +- packages/@uppy/screen-capture/tsconfig.json | 10 +- packages/@uppy/status-bar/src/Components.tsx | 50 +- packages/@uppy/status-bar/src/StatusBar.tsx | 24 +- packages/@uppy/status-bar/src/StatusBarUI.tsx | 41 +- packages/@uppy/status-bar/tsconfig.json | 10 +- .../@uppy/store-default/src/index.test.ts | 4 +- packages/@uppy/store-default/tsconfig.json | 4 +- packages/@uppy/store-redux/src/index.js | 16 +- packages/@uppy/store-redux/src/index.test.js | 15 +- packages/@uppy/store-redux/tsconfig.json | 4 +- .../src/lib/components/Dashboard.svelte | 68 +- .../src/lib/components/DashboardModal.svelte | 88 +- .../svelte/src/lib/components/DragDrop.svelte | 60 +- .../src/lib/components/ProgressBar.svelte | 60 +- .../src/lib/components/StatusBar.svelte | 60 +- .../headless/UppyContextProvider.svelte | 14 +- .../lib/components/headless/uppyContext.ts | 16 +- packages/@uppy/svelte/src/lib/index.ts | 25 +- packages/@uppy/svelte/src/lib/useDropzone.ts | 87 +- packages/@uppy/svelte/src/lib/useFileInput.ts | 74 +- .../@uppy/svelte/src/lib/useRemoteSource.ts | 88 +- .../svelte/src/lib/useScreenCapture.svelte.ts | 132 +- .../src/lib/useSyncExternalStore.svelte.ts | 32 +- .../@uppy/svelte/src/lib/useWebcam.svelte.ts | 121 +- packages/@uppy/svelte/svelte.config.js | 1 - packages/@uppy/svelte/tsconfig.json | 4 +- packages/@uppy/svelte/vite.config.js | 1 - .../thumbnail-generator/src/index.test.js | 127 +- .../@uppy/thumbnail-generator/src/index.ts | 13 +- .../@uppy/thumbnail-generator/tsconfig.json | 10 +- .../@uppy/transloadit/src/Assembly.test.js | 2 +- packages/@uppy/transloadit/src/Assembly.ts | 7 +- .../@uppy/transloadit/src/AssemblyWatcher.ts | 2 +- packages/@uppy/transloadit/src/Client.ts | 8 +- packages/@uppy/transloadit/src/index.test.js | 4 +- packages/@uppy/transloadit/src/index.ts | 53 +- packages/@uppy/transloadit/tsconfig.json | 16 +- packages/@uppy/tus/src/index.test.ts | 2 +- packages/@uppy/tus/src/index.ts | 49 +- packages/@uppy/tus/tsconfig.json | 12 +- packages/@uppy/unsplash/src/Unsplash.tsx | 18 +- packages/@uppy/unsplash/src/index.ts | 2 +- packages/@uppy/unsplash/tsconfig.json | 14 +- packages/@uppy/url/src/Url.tsx | 18 +- packages/@uppy/url/src/UrlUI.tsx | 4 +- packages/@uppy/url/src/index.ts | 2 +- .../src/utils/forEachDroppedOrPastedUrl.ts | 2 +- packages/@uppy/url/tsconfig.json | 12 +- packages/@uppy/utils/src/AbortController.ts | 4 +- packages/@uppy/utils/src/ErrorWithCause.ts | 2 +- packages/@uppy/utils/src/EventManager.js | 22 +- packages/@uppy/utils/src/ProgressTimeout.ts | 6 +- .../@uppy/utils/src/RateLimitedQueue.test.ts | 2 +- packages/@uppy/utils/src/RateLimitedQueue.ts | 2 +- packages/@uppy/utils/src/Translator.ts | 1 - packages/@uppy/utils/src/VirtualList.jsx | 30 +- packages/@uppy/utils/src/delay.ts | 4 +- packages/@uppy/utils/src/fetcher.ts | 2 +- .../@uppy/utils/src/findAllDOMElements.ts | 4 +- packages/@uppy/utils/src/findDOMElement.ts | 4 +- .../@uppy/utils/src/generateFileID.test.js | 44 +- packages/@uppy/utils/src/generateFileID.ts | 2 +- .../@uppy/utils/src/getDroppedFiles/index.ts | 2 +- .../utils/webkitGetAsEntryApi/index.ts | 18 +- packages/@uppy/utils/src/getETA.ts | 4 +- packages/@uppy/utils/src/getFileType.ts | 5 +- .../@uppy/utils/src/getFileTypeExtension.ts | 1 - packages/@uppy/utils/src/getTextDirection.ts | 1 - packages/@uppy/utils/src/hasProperty.ts | 4 +- packages/@uppy/utils/src/prettyETA.ts | 28 +- packages/@uppy/utils/tsconfig.json | 4 +- packages/@uppy/vue/src/dashboard-modal.ts | 6 +- packages/@uppy/vue/src/dashboard.ts | 4 +- packages/@uppy/vue/src/drag-drop.ts | 4 +- packages/@uppy/vue/src/file-input.ts | 4 +- .../vue/src/headless/context-provider.ts | 14 +- .../vue/src/headless/generated/Dropzone.ts | 5 +- .../vue/src/headless/generated/FilesGrid.ts | 5 +- .../vue/src/headless/generated/FilesList.ts | 5 +- .../src/headless/generated/ProviderIcon.ts | 3 +- .../vue/src/headless/generated/Thumbnail.ts | 3 +- .../src/headless/generated/UploadButton.ts | 3 +- .../@uppy/vue/src/headless/useUppyContext.ts | 2 +- packages/@uppy/vue/src/index.ts | 7 +- packages/@uppy/vue/src/progress-bar.ts | 4 +- packages/@uppy/vue/src/status-bar.ts | 4 +- packages/@uppy/vue/src/useFileInput.ts | 3 +- packages/@uppy/vue/src/useRemoteSource.ts | 4 +- packages/@uppy/vue/src/useScreenCapture.ts | 2 +- .../@uppy/vue/src/useSyncExternalStore.ts | 2 +- packages/@uppy/vue/src/useUppy.ts | 4 +- packages/@uppy/vue/src/useWebcam.ts | 2 +- packages/@uppy/vue/tsconfig.json | 20 +- packages/@uppy/webcam/src/CameraIcon.tsx | 2 +- packages/@uppy/webcam/src/CameraScreen.tsx | 19 +- .../@uppy/webcam/src/PermissionsScreen.tsx | 8 +- packages/@uppy/webcam/src/RecordingLength.tsx | 14 +- .../@uppy/webcam/src/VideoSourceSelect.tsx | 2 +- packages/@uppy/webcam/src/Webcam.test.ts | 3 +- packages/@uppy/webcam/src/Webcam.tsx | 35 +- packages/@uppy/webcam/src/index.ts | 3 +- .../webcam/src/supportsMediaRecorder.test.ts | 3 - packages/@uppy/webcam/tsconfig.json | 10 +- packages/@uppy/webdav/src/Webdav.tsx | 24 +- packages/@uppy/webdav/tsconfig.json | 14 +- packages/@uppy/xhr-upload/src/index.test.ts | 4 +- packages/@uppy/xhr-upload/src/index.ts | 42 +- packages/@uppy/xhr-upload/tsconfig.json | 12 +- packages/@uppy/zoom/src/Zoom.tsx | 23 +- packages/@uppy/zoom/src/index.ts | 2 +- packages/@uppy/zoom/tsconfig.json | 14 +- packages/uppy/build-bundle.mjs | 105 +- packages/uppy/bundle.mjs | 4 - packages/uppy/src/bundle.ts | 65 +- packages/uppy/src/index.ts | 45 +- packages/uppy/tsconfig.json | 76 +- private/dev/Dashboard.js | 32 +- private/dev/DragDrop.js | 13 +- private/dev/generateSignatureIfSecret.js | 24 +- private/dev/index.js | 20 +- private/dev/sw.js | 14 +- private/dev/tsconfig.json | 42 +- private/dev/vite.config.js | 8 +- private/js2ts/index.mjs | 14 +- private/locale-pack/helpers.mjs | 24 +- private/locale-pack/index.mjs | 3 +- private/locale-pack/test.mjs | 43 +- private/release/afterVersionBump.js | 87 +- private/release/autoFixConflicts.js | 11 +- private/release/choose-semverness.js | 11 +- private/release/commit-and-open-pr.js | 24 +- private/release/formatChangeLog.js | 49 +- private/release/getUpToDateRefsFromGitHub.js | 45 +- private/release/interactive.js | 12 +- private/release/updateChangelogs.js | 55 +- private/test/globalSetup.mjs | 2 +- private/upload-to-cdn/index.js | 90 +- tsconfig.json | 92 +- vitest.config.ts | 2 +- yarn.lock | 1763 ++--------------- 544 files changed, 7527 insertions(+), 8168 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.js delete mode 100644 .prettierignore delete mode 100644 .prettierrc.js delete mode 100644 .remarkignore delete mode 100644 .stylelintrc.json create mode 100644 .vscode/extensions.json delete mode 100644 .vscode/uppy.code-workspace.bak delete mode 100644 .yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch create mode 100644 biome.json diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 26bf2ac7b..000000000 --- a/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -lib -dist -coverage -test/lib/** -test/endtoend/*/build -examples/svelte-example/public/build/ -bundle-legacy.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 8df12192f..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,506 +0,0 @@ -/* eslint-disable quote-props */ - -'use strict' - -const svgPresentationAttributes = [ - 'alignment-baseline', 'baseline-shift', 'class', 'clip', 'clip-path', 'clip-rule', 'color', 'color-interpolatio', 'color-interpolatio-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'display', 'dominant-baseline', 'enable-background', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'opacity', 'overflow', 'pointer-events', 'shape-rendering', 'stop-color', 'stop-opacity', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'transform', 'transform-origin', 'unicode-bidi', 'vector-effect', 'visibility', 'word-spacing', 'writing-mod', -] - -module.exports = { - root: true, - extends: ['transloadit', 'prettier'], - env: { - es6: true, - jest: true, - node: true, - // extra: - browser: true, - }, - globals: { - globalThis: true, - hexo: true, - window: true, - }, - plugins: [ - 'jest', - 'markdown', - 'node', - 'prefer-import', - 'promise', - 'react', - // extra: - 'jsdoc', - 'no-only-tests', - 'unicorn', - ], - parser: '@typescript-eslint/parser', - parserOptions: { - sourceType: 'script', - ecmaVersion: 2022, - ecmaFeatures: { - jsx: true, - }, - }, - rules: { - // transloadit rules we are actually ok with in the uppy repo - 'import/extensions': 'off', - 'object-shorthand': ['error', 'always'], - 'strict': 'off', - 'key-spacing': 'off', - 'max-classes-per-file': ['error', 2], - 'react/no-unknown-property': ['error', { - ignore: svgPresentationAttributes, - }], - - 'import/no-unresolved': 'off', - - // rules we want to enforce - 'array-callback-return': 'error', - 'func-names': 'error', - 'import/no-dynamic-require': 'error', - 'import/no-extraneous-dependencies': 'error', - 'max-len': 'error', - 'no-empty': 'error', - 'no-bitwise': 'error', - 'no-continue': 'error', - 'no-lonely-if': 'error', - 'no-nested-ternary': 'error', - 'no-restricted-properties': 'error', - 'no-return-assign': 'error', - 'no-underscore-dangle': 'error', - 'no-unused-expressions': 'error', - 'no-unused-vars': 'error', - 'no-useless-concat': 'error', - 'no-var': 'error', - 'node/handle-callback-err': 'error', - 'prefer-destructuring': 'error', - 'prefer-spread': 'error', - 'unicorn/prefer-node-protocol': 'error', - - 'react/button-has-type': 'error', - 'react/forbid-prop-types': 'error', - 'react/no-access-state-in-setstate': 'error', - 'react/no-array-index-key': 'error', - 'react/no-deprecated': 'error', - 'react/no-this-in-sfc': 'error', - 'react/no-will-update-set-state': 'error', - 'react/prefer-stateless-function': 'error', - 'react/require-default-props': ['error', { - forbidDefaultForRequired: true, - functions: 'ignore', - }], - 'react/sort-comp': 'error', - 'react/static-property-placement': 'off', - 'react/style-prop-object': 'error', - - // accessibility - 'jsx-a11y/alt-text': 'error', - 'jsx-a11y/anchor-has-content': 'error', - 'jsx-a11y/click-events-have-key-events': 'error', - 'jsx-a11y/control-has-associated-label': 'error', - 'jsx-a11y/label-has-associated-control': 'error', - 'jsx-a11y/media-has-caption': 'error', - 'jsx-a11y/mouse-events-have-key-events': 'error', - 'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error', - 'jsx-a11y/no-noninteractive-element-interactions': 'error', - 'jsx-a11y/no-static-element-interactions': 'error', - - // jsdoc - 'jsdoc/check-alignment': 'error', - 'jsdoc/check-examples': 'off', // cannot yet be supported for ESLint 8, see https://github.com/eslint/eslint/issues/14745 - 'jsdoc/check-param-names': 'error', - 'jsdoc/check-syntax': 'error', - 'jsdoc/check-tag-names': ['error', { jsxTags: true }], - 'jsdoc/check-types': 'error', - 'jsdoc/valid-types': 'error', - 'jsdoc/check-indentation': ['off'], - }, - - settings: { - 'import/core-modules': ['tsd'], - react: { - pragma: 'h', - }, - jsdoc: { - mode: 'typescript', - }, - polyfills: [ - 'Promise', - 'fetch', - 'Object.assign', - 'document.querySelector', - ], - }, - - overrides: [ - { - files: [ - '*.jsx', - '*.tsx', - 'packages/@uppy/react-native/**/*.js', - ], - parser: 'espree', - parserOptions: { - sourceType: 'module', - ecmaFeatures: { - jsx: true, - }, - }, - rules: { - 'no-restricted-globals': [ - 'error', - { - name: '__filename', - message: 'Use import.meta.url instead', - }, - { - name: '__dirname', - message: 'Not available in ESM', - }, - { - name: 'exports', - message: 'Not available in ESM', - }, - { - name: 'module', - message: 'Not available in ESM', - }, - { - name: 'require', - message: 'Use import instead', - }, - { - name: 'JSX', - message: 'Use h.JSX.Element, ComponentChild, or ComponentChildren from Preact', - }, - { - name: 'React', - message: 'Import the value instead of relying on global.React.', - }, - ], - 'import/extensions': ['error', 'ignorePackages'], - }, - }, - { - files: [ - '*.mjs', - 'e2e/clients/**/*.js', - 'examples/aws-companion/*.js', - 'examples/aws-php/*.js', - 'examples/bundled/*.js', - 'examples/custom-provider/client/*.js', - 'examples/digitalocean-spaces/*.js', - 'examples/multiple-instances/*.js', - 'examples/node-xhr/*.js', - 'examples/php-xhr/*.js', - 'examples/python-xhr/*.js', - 'examples/react-example/*.js', - 'examples/redux/*.js', - 'examples/transloadit/*.js', - 'examples/transloadit-markdown-bin/*.js', - 'examples/xhr-bundle/*.js', - 'private/dev/*.js', - 'private/release/*.js', - 'private/remark-lint-uppy/*.js', - 'packages/@uppy/!(companion|react-native)/**/*.js', - ], - parser: 'espree', - parserOptions: { - sourceType: 'module', - ecmaFeatures: { - jsx: false, - }, - }, - rules: { - 'import/named': 'off', // Disabled because that rule tries and fails to parse JSX dependencies. - 'import/no-named-as-default': 'off', // Disabled because that rule tries and fails to parse JSX dependencies. - 'import/no-named-as-default-member': 'off', // Disabled because that rule tries and fails to parse JSX dependencies. - 'no-restricted-globals': [ - 'error', - { - name: '__filename', - message: 'Use import.meta.url instead', - }, - { - name: '__dirname', - message: 'Not available in ESM', - }, - { - name: 'exports', - message: 'Not available in ESM', - }, - { - name: 'module', - message: 'Not available in ESM', - }, - { - name: 'require', - message: 'Use import instead', - }, - { - name: 'JSX', - message: 'Use h.JSX.Element, ComponentChild, or ComponentChildren from Preact', - }, - { - name: 'React', - message: 'Import the value instead of relying on global.React.', - }, - ], - 'import/extensions': ['error', 'ignorePackages'], - }, - }, - { - files: ['packages/uppy/*.mjs'], - rules: { - 'import/first': 'off', - 'import/newline-after-import': 'off', - 'import/no-extraneous-dependencies': ['error', { - devDependencies: true, - }], - }, - }, - { - files: [ - 'packages/@uppy/*/types/*.d.ts', - ], - rules : { - 'import/no-unresolved': 'off', - 'max-classes-per-file': 'off', - 'no-use-before-define': 'off', - }, - }, - { - files: [ - 'packages/@uppy/dashboard/src/components/**/*.jsx', - ], - rules: { - 'react/destructuring-assignment': 'off', - }, - }, - { - files: [ - // Those need looser rules, and cannot be made part of the stricter rules above. - // TODO: update those to more modern code when switch to ESM is complete - 'examples/react-native-expo/*.js', - 'examples/svelte-example/**/*.js', - 'examples/sveltekit/**/*.js', - 'examples/vue/**/*.js', - 'examples/vue3/**/*.js', - ], - rules: { - 'no-unused-vars': [ - 'error', - { - 'varsIgnorePattern': 'React', - }, - ], - }, - parserOptions: { - sourceType: 'module', - }, - }, - { - files: ['./packages/@uppy/companion/**/*.js'], - rules: { - 'no-underscore-dangle': 'off', - }, - }, - { - files: [ - 'bin/**.js', - 'bin/**.mjs', - 'examples/**/*.cjs', - 'examples/**/*.js', - 'packages/@uppy/companion/test/**/*.js', - 'test/**/*.js', - 'test/**/*.ts', - '*.test.js', - '*.test.ts', - '*.test-d.ts', - '*.test-d.tsx', - 'postcss.config.js', - '.eslintrc.js', - 'private/**/*.js', - 'private/**/*.mjs', - ], - rules: { - 'no-console': 'off', - 'import/no-extraneous-dependencies': ['error', { - devDependencies: true, - }], - }, - }, - - { - files: [ - 'packages/@uppy/locales/src/*.js', - 'packages/@uppy/locales/template.js', - ], - rules: { - camelcase: ['off'], - 'quote-props': ['error', 'as-needed', { 'numbers': true }], - }, - }, - - { - files: ['test/endtoend/*/*.mjs', 'test/endtoend/*/*.ts'], - rules: { - // we mostly import @uppy stuff in these files. - 'import/no-extraneous-dependencies': ['off'], - }, - }, - { - files: ['test/endtoend/*/*.js'], - env: { - mocha: true, - }, - }, - - { - files: ['packages/@uppy/react/src/**/*.js'], - rules: { - 'import/no-extraneous-dependencies': ['error', { - peerDependencies: true, - }], - }, - }, - - { - files: ['**/*.md', '*.md'], - processor: 'markdown/markdown', - }, - { - files: ['**/*.md/*.js', '**/*.md/*.javascript'], - parserOptions: { - sourceType: 'module', - }, - rules: { - 'react/destructuring-assignment': 'off', - 'no-restricted-globals': [ - 'error', - { - name: '__filename', - message: 'Use import.meta.url instead', - }, - { - name: '__dirname', - message: 'Not available in ESM', - }, - { - name: 'exports', - message: 'Not available in ESM', - }, - { - name: 'module', - message: 'Not available in ESM', - }, - { - name: 'require', - message: 'Use import instead', - }, - ], - }, - }, - { - files: ['**/*.ts', '**/*.md/*.ts', '**/*.md/*.typescript', '**/*.tsx', '**/*.md/*.tsx'], - excludedFiles: ['examples/angular-example/**/*.ts', 'packages/@uppy/angular/**/*.ts'], - parser: '@typescript-eslint/parser', - settings: { - 'import/resolver': { - node: { - extensions: ['.js', '.jsx', '.ts', '.tsx'], - }, - }, - }, - plugins: ['@typescript-eslint'], - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - ], - rules: { - 'no-extra-semi': 'off', - 'no-restricted-syntax': ['error', { - selector: 'ImportDeclaration[source.value=/^@uppy\\x2F[a-z-0-9]+\\x2F/]:not([source.value=/^@uppy\\x2Futils\\x2F/]):not([source.value=/\\.(js|css)$/])', - message: 'Use ".js" file extension for import type declarations from a different package', - }, { - selector: 'ImportDeclaration[source.value=/^@uppy\\x2Futils\\x2Flib\\x2F.+\\.[mc]?[jt]sx?$/]', - message: 'Do not use file extension when importing from @uppy/utils', - }, - { - selector: 'ImportDeclaration[source.value=/^@uppy\\x2F[a-z-0-9]+\\x2Fsrc\\x2F/]', - message: 'Importing from "src/" is not allowed. Import from root or from "lib/" if you must.', - }], - 'import/extensions': ['error', 'ignorePackages'], - 'import/prefer-default-export': 'off', - '@typescript-eslint/no-empty-function': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-extra-semi': 'off', - '@typescript-eslint/no-namespace': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - }, - }, - { - files: ['packages/@uppy/*/src/**/*.ts'], - excludedFiles: ['packages/@uppy/**/*.test.ts', 'packages/@uppy/core/src/mocks/*.ts'], - rules: { - '@typescript-eslint/explicit-module-boundary-types': 'error', - }, - }, - { - files: ['**/*.md/*.*'], - rules: { - 'import/no-extraneous-dependencies': 'off', - 'import/no-unresolved': 'off', - 'no-console': 'off', - 'no-undef': 'off', - 'no-unused-vars': 'off', - }, - }, - { - files: ['**/react/*.md/*.js', '**/react.md/*.js', '**/react-*.md/*.js', '**/react/**/*.test-d.tsx'], - settings: { - react: { pragma: 'React' }, - }, - }, - { - files: ['**/react/**/*.test-d.tsx'], - rules: { - 'import/extensions': 'off', - 'import/no-useless-path-segments': 'off', - 'no-alert': 'off', - 'no-inner-declarations': 'off', - 'no-lone-blocks': 'off', - 'no-unused-expressions': 'off', - 'no-unused-vars': 'off', - }, - }, - { - files: [ - 'packages/@uppy/svelte/**', - ], - parserOptions: { - sourceType: 'module', - }, - }, - { - files: ['e2e/**/*.ts'], - extends: ['plugin:cypress/recommended'], - }, - { - files: ['e2e/**/*.ts', 'e2e/**/*.js', 'e2e/**/*.jsx', 'e2e/**/*.mjs'], - rules: { - 'import/no-extraneous-dependencies': 'off', - 'no-console': 'off', - 'no-only-tests/no-only-tests': 'error', - 'no-unused-expressions': 'off', - }, - }, - { - files: ["packages/@uppy/vue/**"], - rules: { - 'react-hooks/rules-of-hooks': 'off', - }, - }, - ], -} diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 6f9deaf72..778b35e68 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -38,6 +38,4 @@ jobs: corepack yarn workspaces focus @uppy/angular @uppy-example/angular @uppy-example/react-native-expo @uppy/react-native @uppy-dev/build - name: Run linter - run: corepack yarn run lint - - name: Run Prettier - run: corepack yarn run format:check-diff + run: corepack yarn run check:ci diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index a14593f02..2ec78f4b8 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -1,7 +1,8 @@ name: Release candidate on: push: - branches: release + branches: + - release env: YARN_ENABLE_GLOBAL_CACHE: false @@ -50,7 +51,7 @@ jobs: releases.json | xargs git add - name: Update contributors table run: - corepack yarn contributors:save && corepack yarn prettier -w README.md + corepack yarn contributors:save && git add README.md - name: Update CDN URLs run: diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index d8404c980..000000000 --- a/.prettierignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules/ -*.js -*.jsx -*.cjs -*.mjs -!private/js2ts/* -!examples/svelte-example/* -*.lock -CHANGELOG.md diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index ba4df7a5f..000000000 --- a/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -/** @type {import("prettier").Config} */ -module.exports = { - proseWrap: 'always', - singleQuote: true, - trailingComma: 'all', - semi: false, - experimentalTernaries: true, - overrides: [ - { - files: 'packages/@uppy/angular/**', - options: { - semi: true, - }, - }, - { - files: ['tsconfig.json'], - options: { - parser: 'jsonc', - }, - }, - ], -} diff --git a/.remarkignore b/.remarkignore deleted file mode 100644 index 2995e88d0..000000000 --- a/.remarkignore +++ /dev/null @@ -1,8 +0,0 @@ -website/src/_posts/201* -website/src/_posts/2020-* -website/src/_posts/2021-0* -examples/ -CHANGELOG.md -CHANGELOG.next.md -BACKLOG.md -node_modules/ diff --git a/.stylelintrc.json b/.stylelintrc.json deleted file mode 100644 index 3d05d89b9..000000000 --- a/.stylelintrc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": [ - "stylelint-config-standard", - "stylelint-config-standard-scss", - "stylelint-config-rational-order" - ], - "rules": { - "at-rule-no-unknown": null, - "scss/at-rule-no-unknown": true - }, - "defaultSeverity": "warning" -} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..699ed7331 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["biomejs.biome"] +} diff --git a/.vscode/uppy.code-workspace b/.vscode/uppy.code-workspace index 918de6b36..472f46c9c 100644 --- a/.vscode/uppy.code-workspace +++ b/.vscode/uppy.code-workspace @@ -1,29 +1,23 @@ { "folders": [ { - "path": "..", - }, + "path": ".." + } ], "settings": { + "editor.defaultFormatter": "biomejs.biome", "workbench.colorCustomizations": { "titleBar.activeForeground": "#ffffff", - "titleBar.activeBackground": "#ff009d", + "titleBar.activeBackground": "#ff009d" }, "search.exclude": { - "website/public/": true, "node_modules/": true, - "website/node_modules/": true, "dist/": true, "lib/": true, - "package-lock.json": true, - "website/package-lock.json": true, "yarn-error.log": true, - "website/.deploy_git": true, "npm-debug.log": true, - "website/npm-debug.log": true, - "website/debug.log": true, "nohup.out": true, - "yarn.lock": true, - }, - }, + "yarn.lock": true + } + } } diff --git a/.vscode/uppy.code-workspace.bak b/.vscode/uppy.code-workspace.bak deleted file mode 100644 index 2aea22309..000000000 --- a/.vscode/uppy.code-workspace.bak +++ /dev/null @@ -1,29 +0,0 @@ -{ - "folders": [ - { - "path": "." - } - ], - "settings": { - "workbench.colorCustomizations": { - "titleBar.activeForeground": "#ffffff", - "titleBar.activeBackground": "#ff009d", - }, - "search.exclude": { - "website/public/": true, - "node_modules/": true, - "website/node_modules/": true, - "dist/": true, - "lib/": true, - "package-lock.json": true, - "website/package-lock.json": true, - "yarn-error.log": true, - "website/.deploy_git": true, - "npm-debug.log": true, - "website/npm-debug.log": true, - "website/debug.log": true, - "nohup.out": true, - "yarn.lock": true - } - } -} diff --git a/.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch b/.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch deleted file mode 100644 index 2e5dbd70e..000000000 --- a/.yarn/patches/pre-commit-npm-1.2.2-f30af83877.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/index.js b/index.js -index a20646d922945004cb737918ef6b6d063bb3c2a4..a44863e9555abdaa569f309b1197fddc8dd244a5 100644 ---- a/index.js -+++ b/index.js -@@ -147,7 +147,7 @@ Hook.prototype.log = function log(lines, exit) { - * @api private - */ - Hook.prototype.initialize = function initialize() { -- ['git', 'npm'].forEach(function each(binary) { -+ ['git', 'corepack'].forEach(function each(binary) { - try { this[binary] = which.sync(binary); } - catch (e) {} - }, this); -@@ -159,9 +159,9 @@ Hook.prototype.initialize = function initialize() { - if (!this.npm) { - try { - process.env.PATH += path.delimiter + path.dirname(process.env._); -- this.npm = which.sync('npm'); -+ this.npm = which.sync('corepack'); - } catch (e) { -- return this.log(this.format(Hook.log.binary, 'npm'), 0); -+ return this.log(this.format(Hook.log.binary, 'corepack'), 0); - } - } - -@@ -225,7 +225,7 @@ Hook.prototype.run = function runner() { - // this doesn't have the required `isAtty` information that libraries use to - // output colors resulting in script output that doesn't have any color. - // -- spawn(hooked.npm, ['run', script, '--silent'], { -+ spawn(hooked.npm, ['yarn', script], { - env: process.env, - cwd: hooked.root, - stdio: [0, 1, 2] diff --git a/bin/build-components.mjs b/bin/build-components.mjs index 84c3987f1..8e934fe98 100644 --- a/bin/build-components.mjs +++ b/bin/build-components.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node -import fs from 'node:fs/promises' import { existsSync } from 'node:fs' +import fs from 'node:fs/promises' import path from 'node:path' import { fileURLToPath } from 'node:url' @@ -13,7 +13,10 @@ const rootDir = path.resolve(scriptDir, '..') // source: const COMPONENTS_DIR = path.join(rootDir, 'packages/@uppy/components/src') // destinations: -const REACT_DIR = path.join(rootDir, 'packages/@uppy/react/src/headless/generated') +const REACT_DIR = path.join( + rootDir, + 'packages/@uppy/react/src/headless/generated', +) const VUE_DIR = path.join(rootDir, 'packages/@uppy/vue/src/headless/generated') const SVELTE_DIR = path.join( rootDir, @@ -222,7 +225,10 @@ try { const reactIndexContent = reactComponents .map((name) => `export { default as ${name} } from './${name}.js'`) .join('\n') - await fs.writeFile(path.join(REACT_DIR, 'index.ts'), `${reactIndexContent}\n`) + await fs.writeFile( + path.join(REACT_DIR, 'index.ts'), + `${reactIndexContent}\n`, + ) console.log(`\nExporting React components from ${REACT_DIR}`) } @@ -238,7 +244,10 @@ try { const svelteIndexContent = svelteComponents .map((name) => `export { default as ${name} } from './${name}.svelte'`) .join('\n') - await fs.writeFile(path.join(SVELTE_DIR, 'index.ts'), `${svelteIndexContent}\n`) + await fs.writeFile( + path.join(SVELTE_DIR, 'index.ts'), + `${svelteIndexContent}\n`, + ) console.log(`Exporting Svelte components from ${SVELTE_DIR}`) } diff --git a/bin/build-css.js b/bin/build-css.js index d780ddc09..89d0d85ed 100644 --- a/bin/build-css.js +++ b/bin/build-css.js @@ -16,49 +16,50 @@ const { mkdir, writeFile } = fs.promises const cwd = process.cwd() let chalk -function handleErr (err) { +function handleErr(err) { console.error(chalk.red('✗ Error:'), chalk.red(err.message)) } -async function compileCSS () { - ({ default:chalk } = await import('chalk')) +async function compileCSS() { + ;({ default: chalk } = await import('chalk')) const files = await glob('packages/{,@uppy/}*/src/style.scss') for (const file of files) { const importedFiles = new Set() const scssResult = await renderScss({ file, - importer (url, from, done) { - resolve(url, { - basedir: path.dirname(from), - filename: from, - extensions: ['.scss'], - }, (err, resolved) => { - if (err) { - done(err) - return - } + importer(url, from, done) { + resolve( + url, + { + basedir: path.dirname(from), + filename: from, + extensions: ['.scss'], + }, + (err, resolved) => { + if (err) { + done(err) + return + } - const realpath = fs.realpathSync(resolved) + const realpath = fs.realpathSync(resolved) - if (importedFiles.has(realpath)) { - done({ contents: '' }) - return - } - importedFiles.add(realpath) + if (importedFiles.has(realpath)) { + done({ contents: '' }) + return + } + importedFiles.add(realpath) - done({ file: realpath }) - }) + done({ file: realpath }) + }, + ) }, }) - const plugins = [ - autoprefixer, - postcssLogical(), - postcssDirPseudoClass(), - ] - const postcssResult = await postcss(plugins) - .process(scssResult.css, { from: file }) + const plugins = [autoprefixer, postcssLogical(), postcssDirPseudoClass()] + const postcssResult = await postcss(plugins).process(scssResult.css, { + from: file, + }) postcssResult.warnings().forEach((warn) => { console.warn(warn.toString()) }) @@ -79,9 +80,10 @@ async function compileCSS () { chalk.magenta(path.relative(cwd, outfile)), ) - const minifiedResult = await postcss([ - cssnano({ safe: true }), - ]).process(postcssResult.css, { from: outfile }) + const minifiedResult = await postcss([cssnano({ safe: true })]).process( + postcssResult.css, + { from: outfile }, + ) minifiedResult.warnings().forEach((warn) => { console.warn(warn.toString()) }) diff --git a/bin/update-contributors.mjs b/bin/update-contributors.mjs index 8a877a494..37ea33a44 100755 --- a/bin/update-contributors.mjs +++ b/bin/update-contributors.mjs @@ -1,12 +1,12 @@ #!/usr/bin/env node -import fetchContrib from 'github-contributors-list/lib/contributors.js' -import layoutStrategy from 'github-contributors-list/lib/strategies/layout_strategies/json.js' -import sortStrategy from 'github-contributors-list/lib/strategies/sort_strategies/sort_desc.js' -import filterStrategy from 'github-contributors-list/lib/strategies/filter_strategies/login.js' import { Buffer } from 'node:buffer' import fs from 'node:fs/promises' import process from 'node:process' +import fetchContrib from 'github-contributors-list/lib/contributors.js' +import filterStrategy from 'github-contributors-list/lib/strategies/filter_strategies/login.js' +import layoutStrategy from 'github-contributors-list/lib/strategies/layout_strategies/json.js' +import sortStrategy from 'github-contributors-list/lib/strategies/sort_strategies/sort_desc.js' const README_FILE_NAME = new URL('../README.md', import.meta.url) diff --git a/biome.json b/biome.json new file mode 100644 index 000000000..6518554fc --- /dev/null +++ b/biome.json @@ -0,0 +1,67 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.0.5/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": true, + "includes": [ + "packages/**", + "examples/**", + "bin/**", + "e2e/**", + "private/**", + "!packages/**/{dist,lib}/**", + "!node_modules", + "!.svelte-kit", + "!packages/@uppy/components/src/input.css" + ] + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "formatWithErrors": true + }, + "linter": { + "enabled": true, + "includes": ["!**/*.vue", "!**/*.svelte"], + "rules": { + "recommended": true, + "suspicious": { + "noExplicitAny": "off" + }, + "correctness": { + "noUnusedImports": "off", + "noUnusedFunctionParameters": "off", + "noUnusedVariables": { + "level": "error", + "options": { + "ignoreRestSiblings": true + } + } + }, + "style": { + "noNonNullAssertion": "off" + }, + "a11y": { + "noSvgWithoutTitle": "off" + } + } + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "semicolons": "asNeeded" + } + }, + "assist": { + "enabled": true, + "actions": { + "source": { + "organizeImports": "on" + } + } + } +} diff --git a/e2e/clients/dashboard-aws-multipart/app.js b/e2e/clients/dashboard-aws-multipart/app.js index e3a14ea62..cee350c4b 100644 --- a/e2e/clients/dashboard-aws-multipart/app.js +++ b/e2e/clients/dashboard-aws-multipart/app.js @@ -1,6 +1,6 @@ +import AwsS3Multipart from '@uppy/aws-s3' import { Uppy } from '@uppy/core' import Dashboard from '@uppy/dashboard' -import AwsS3Multipart from '@uppy/aws-s3' import '@uppy/core/dist/style.css' import '@uppy/dashboard/dist/style.css' diff --git a/e2e/clients/dashboard-aws/app.js b/e2e/clients/dashboard-aws/app.js index 2c23b9205..c7e2bbf3c 100644 --- a/e2e/clients/dashboard-aws/app.js +++ b/e2e/clients/dashboard-aws/app.js @@ -1,6 +1,6 @@ +import AwsS3 from '@uppy/aws-s3' import { Uppy } from '@uppy/core' import Dashboard from '@uppy/dashboard' -import AwsS3 from '@uppy/aws-s3' import '@uppy/core/dist/style.css' import '@uppy/dashboard/dist/style.css' diff --git a/e2e/clients/dashboard-compressor/app.js b/e2e/clients/dashboard-compressor/app.js index a0ca67ddd..09301b44a 100644 --- a/e2e/clients/dashboard-compressor/app.js +++ b/e2e/clients/dashboard-compressor/app.js @@ -1,6 +1,6 @@ +import Compressor from '@uppy/compressor' import Uppy from '@uppy/core' import Dashboard from '@uppy/dashboard' -import Compressor from '@uppy/compressor' import '@uppy/core/dist/style.css' import '@uppy/dashboard/dist/style.css' diff --git a/e2e/clients/dashboard-transloadit/generateSignatureIfSecret.js b/e2e/clients/dashboard-transloadit/generateSignatureIfSecret.js index 2f40ce20e..4eee9e4d7 100644 --- a/e2e/clients/dashboard-transloadit/generateSignatureIfSecret.js +++ b/e2e/clients/dashboard-transloadit/generateSignatureIfSecret.js @@ -1,12 +1,22 @@ const enc = new TextEncoder('utf-8') -async function sign (secret, body) { +async function sign(secret, body) { const algorithm = { name: 'HMAC', hash: 'SHA-384' } - const key = await crypto.subtle.importKey('raw', enc.encode(secret), algorithm, false, ['sign', 'verify']) - const signature = await crypto.subtle.sign(algorithm.name, key, enc.encode(body)) - return `sha384:${Array.from(new Uint8Array(signature), x => x.toString(16).padStart(2, '0')).join('')}` + const key = await crypto.subtle.importKey( + 'raw', + enc.encode(secret), + algorithm, + false, + ['sign', 'verify'], + ) + const signature = await crypto.subtle.sign( + algorithm.name, + key, + enc.encode(body), + ) + return `sha384:${Array.from(new Uint8Array(signature), (x) => x.toString(16).padStart(2, '0')).join('')}` } -function getExpiration (future) { +function getExpiration(future) { return new Date(Date.now() + future) .toISOString() .replace('T', ' ') @@ -20,12 +30,10 @@ function getExpiration (future) { * @param {object} params * @returns {{ params: string, signature?: string }} */ -export default async function generateSignatureIfSecret (secret, params) { +export default async function generateSignatureIfSecret(secret, params) { let signature if (secret) { - // eslint-disable-next-line no-param-reassign params.auth.expires = getExpiration(5 * 60 * 1000) - // eslint-disable-next-line no-param-reassign params = JSON.stringify(params) signature = await sign(secret, params) } diff --git a/e2e/clients/dashboard-tus/app.js b/e2e/clients/dashboard-tus/app.js index 4ce9ec033..b982d6241 100644 --- a/e2e/clients/dashboard-tus/app.js +++ b/e2e/clients/dashboard-tus/app.js @@ -7,7 +7,7 @@ import Url from '@uppy/url' import '@uppy/core/dist/style.css' import '@uppy/dashboard/dist/style.css' -function onShouldRetry (err, retryAttempt, options, next) { +function onShouldRetry(err, retryAttempt, options, next) { if (err?.originalResponse?.getStatus() === 418) { return true } diff --git a/e2e/clients/dashboard-ui/app.js b/e2e/clients/dashboard-ui/app.js index 6e63ab9a1..d3efe1b89 100644 --- a/e2e/clients/dashboard-ui/app.js +++ b/e2e/clients/dashboard-ui/app.js @@ -1,13 +1,13 @@ -import Uppy from '@uppy/core' -import Dashboard from '@uppy/dashboard' -import RemoteSources from '@uppy/remote-sources' -import Webcam from '@uppy/webcam' -import ScreenCapture from '@uppy/screen-capture' -import GoldenRetriever from '@uppy/golden-retriever' -import ImageEditor from '@uppy/image-editor' -import DropTarget from '@uppy/drop-target' import Audio from '@uppy/audio' import Compressor from '@uppy/compressor' +import Uppy from '@uppy/core' +import Dashboard from '@uppy/dashboard' +import DropTarget from '@uppy/drop-target' +import GoldenRetriever from '@uppy/golden-retriever' +import ImageEditor from '@uppy/image-editor' +import RemoteSources from '@uppy/remote-sources' +import ScreenCapture from '@uppy/screen-capture' +import Webcam from '@uppy/webcam' import '@uppy/core/dist/style.css' import '@uppy/dashboard/dist/style.css' diff --git a/e2e/clients/dashboard-vue/App.vue b/e2e/clients/dashboard-vue/App.vue index e727f934c..0277b21d1 100644 --- a/e2e/clients/dashboard-vue/App.vue +++ b/e2e/clients/dashboard-vue/App.vue @@ -21,16 +21,16 @@
diff --git a/examples/sveltekit/src/components/MediaCapture.svelte b/examples/sveltekit/src/components/MediaCapture.svelte index ee78dc462..44bf9ff9d 100644 --- a/examples/sveltekit/src/components/MediaCapture.svelte +++ b/examples/sveltekit/src/components/MediaCapture.svelte @@ -1,30 +1,30 @@
diff --git a/examples/sveltekit/src/components/RemoteSource.svelte b/examples/sveltekit/src/components/RemoteSource.svelte index e8201d1b3..cc151800e 100644 --- a/examples/sveltekit/src/components/RemoteSource.svelte +++ b/examples/sveltekit/src/components/RemoteSource.svelte @@ -1,32 +1,32 @@ {#if !remoteSource.state.authenticated} diff --git a/examples/sveltekit/src/components/ScreenCapture.svelte b/examples/sveltekit/src/components/ScreenCapture.svelte index f3ae45113..dbb655daf 100644 --- a/examples/sveltekit/src/components/ScreenCapture.svelte +++ b/examples/sveltekit/src/components/ScreenCapture.svelte @@ -1,21 +1,21 @@ - import MediaCapture from './MediaCapture.svelte' - import { untrack } from 'svelte' - import { useWebcam } from '@uppy/svelte' +import { useWebcam } from '@uppy/svelte' +import { untrack } from 'svelte' +import MediaCapture from './MediaCapture.svelte' - interface Props { - close: () => void +interface Props { + close: () => void +} + +const { close }: Props = $props() +const webcamStore = useWebcam({ onSubmit: close }) + +$effect(() => { + untrack(() => webcamStore.start()) + return () => { + untrack(() => webcamStore.stop()) } - - const { close }: Props = $props() - const webcamStore = useWebcam({ onSubmit: close }) - - $effect(() => { - untrack(() => webcamStore.start()) - return () => { - untrack(() => webcamStore.stop()) - } - }) +}) - import '../app.css'; - - let { children } = $props(); +import '../app.css' + +const { children } = $props() {@render children()} diff --git a/examples/sveltekit/src/routes/+page.svelte b/examples/sveltekit/src/routes/+page.svelte index 1a8ebbd84..bbbd864e5 100644 --- a/examples/sveltekit/src/routes/+page.svelte +++ b/examples/sveltekit/src/routes/+page.svelte @@ -1,43 +1,43 @@ diff --git a/examples/sveltekit/svelte.config.js b/examples/sveltekit/svelte.config.js index 1295460d1..e92eb5e12 100644 --- a/examples/sveltekit/svelte.config.js +++ b/examples/sveltekit/svelte.config.js @@ -1,18 +1,18 @@ -import adapter from '@sveltejs/adapter-auto'; -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; +import adapter from '@sveltejs/adapter-auto' +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' /** @type {import('@sveltejs/kit').Config} */ const config = { - // Consult https://svelte.dev/docs/kit/integrations - // for more information about preprocessors - preprocess: vitePreprocess(), + // Consult https://svelte.dev/docs/kit/integrations + // for more information about preprocessors + preprocess: vitePreprocess(), - kit: { - // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter() - } -}; + kit: { + // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. + // If your environment is not supported, or you settled on a specific environment, switch out the adapter. + // See https://svelte.dev/docs/kit/adapters for more information about adapters. + adapter: adapter(), + }, +} -export default config; +export default config diff --git a/examples/sveltekit/tsconfig.json b/examples/sveltekit/tsconfig.json index c2d46c7a3..68383fa08 100644 --- a/examples/sveltekit/tsconfig.json +++ b/examples/sveltekit/tsconfig.json @@ -10,8 +10,8 @@ "sourceMap": true, "strict": true, "module": "preserve", - "moduleResolution": "bundler", - }, + "moduleResolution": "bundler" + } // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files // diff --git a/examples/sveltekit/vite.config.ts b/examples/sveltekit/vite.config.ts index cecc075e2..85c6af9d2 100644 --- a/examples/sveltekit/vite.config.ts +++ b/examples/sveltekit/vite.config.ts @@ -1,6 +1,5 @@ -import tailwindcss from '@tailwindcss/vite' import { sveltekit } from '@sveltejs/kit/vite' -// eslint-disable-next-line import/no-extraneous-dependencies +import tailwindcss from '@tailwindcss/vite' import { defineConfig } from 'vite' export default defineConfig({ diff --git a/examples/transloadit-markdown-bin/main.js b/examples/transloadit-markdown-bin/main.js index bd7016e05..acfe8ae3f 100644 --- a/examples/transloadit-markdown-bin/main.js +++ b/examples/transloadit-markdown-bin/main.js @@ -1,11 +1,11 @@ -import { marked } from 'marked' import Uppy from '@uppy/core' -import DropTarget from '@uppy/drop-target' import Dashboard from '@uppy/dashboard' -import Transloadit from '@uppy/transloadit' -import RemoteSources from '@uppy/remote-sources' -import Webcam from '@uppy/webcam' +import DropTarget from '@uppy/drop-target' import ImageEditor from '@uppy/image-editor' +import RemoteSources from '@uppy/remote-sources' +import Transloadit from '@uppy/transloadit' +import Webcam from '@uppy/webcam' +import { marked } from 'marked' import '@uppy/core/dist/style.css' import '@uppy/dashboard/dist/style.css' @@ -14,13 +14,12 @@ import '@uppy/image-editor/dist/style.css' const TRANSLOADIT_EXAMPLE_KEY = '35c1aed03f5011e982b6afe82599b6a0' const TRANSLOADIT_EXAMPLE_TEMPLATE = '0b2ee2bc25dc43619700c2ce0a75164a' -function matchFilesAndThumbs (results) { +function matchFilesAndThumbs(results) { const filesById = {} const thumbsById = {} for (const [stepName, result] of Object.entries(results)) { - // eslint-disable-next-line no-shadow - result.forEach(result => { + result.forEach((result) => { if (stepName === 'thumbnails') { thumbsById[result.original_id] = result } else { @@ -39,7 +38,7 @@ function matchFilesAndThumbs (results) { * A textarea for markdown text, with support for file attachments. */ class MarkdownTextarea { - constructor (element) { + constructor(element) { this.element = element this.controls = document.createElement('div') this.controls.classList.add('mdtxt-controls') @@ -52,7 +51,7 @@ class MarkdownTextarea { ) } - install () { + install() { const { element } = this const wrapper = document.createElement('div') wrapper.classList.add('mdtxt') @@ -82,11 +81,9 @@ class MarkdownTextarea { this.uppy.on('complete', (result) => { const { successful, failed, transloadit } = result if (successful.length !== 0) { - this.insertAttachments( - matchFilesAndThumbs(transloadit[0].results), - ) + this.insertAttachments(matchFilesAndThumbs(transloadit[0].results)) } else { - failed.forEach(error => { + failed.forEach((error) => { console.error(error) this.reportUploadError(error) }) @@ -95,14 +92,14 @@ class MarkdownTextarea { }) } - reportUploadError (err) { + reportUploadError(err) { this.uploadLine.classList.add('error') const message = document.createElement('span') message.appendChild(document.createTextNode(err.message)) this.uploadLine.insertChild(message, this.uploadLine.firstChild) } - unreportUploadError () { + unreportUploadError() { this.uploadLine.classList.remove('error') const message = this.uploadLine.querySelector('message') if (message) { @@ -110,13 +107,16 @@ class MarkdownTextarea { } } - insertAttachments (attachments) { + insertAttachments(attachments) { attachments.forEach((attachment) => { const { file, thumb } = attachment const link = `\n[LABEL](${file.ssl_url})\n` const labelText = `View File ${file.basename}` if (thumb) { - this.element.value += link.replace('LABEL', `![${labelText}](${thumb.ssl_url})`) + this.element.value += link.replace( + 'LABEL', + `![${labelText}](${thumb.ssl_url})`, + ) } else { this.element.value += link.replace('LABEL', labelText) } @@ -124,7 +124,7 @@ class MarkdownTextarea { } uploadFiles = (files) => { - const filesForUppy = files.map(file => { + const filesForUppy = files.map((file) => { return { data: file, type: file.type, @@ -139,7 +139,7 @@ class MarkdownTextarea { const textarea = new MarkdownTextarea(document.querySelector('#new textarea')) textarea.install() -function renderSnippet (title, text) { +function renderSnippet(title, text) { const template = document.querySelector('#snippet') const newSnippet = document.importNode(template.content, true) const titleEl = newSnippet.querySelector('.snippet-title') @@ -152,13 +152,13 @@ function renderSnippet (title, text) { list.insertBefore(newSnippet, list.firstChild) } -function saveSnippet (title, text) { +function saveSnippet(title, text) { const id = parseInt(localStorage.numSnippets || 0, 10) localStorage[`snippet_${id}`] = JSON.stringify({ title, text }) localStorage.numSnippets = id + 1 } -function loadSnippets () { +function loadSnippets() { for (let id = 0; localStorage[`snippet_${id}`] != null; id += 1) { const { title, text } = JSON.parse(localStorage[`snippet_${id}`]) renderSnippet(title, text) @@ -168,16 +168,13 @@ function loadSnippets () { document.querySelector('#new').addEventListener('submit', (event) => { event.preventDefault() - const title = event.target.elements['title'].value - || 'Unnamed Snippet' + const title = event.target.elements.title.value || 'Unnamed Snippet' const text = textarea.element.value saveSnippet(title, text) renderSnippet(title, text) - // eslint-disable-next-line no-param-reassign event.target.querySelector('input').value = '' - // eslint-disable-next-line no-param-reassign event.target.querySelector('textarea').value = '' }) diff --git a/examples/transloadit/main.js b/examples/transloadit/main.js index 8470c630a..4c6699dfb 100644 --- a/examples/transloadit/main.js +++ b/examples/transloadit/main.js @@ -1,11 +1,11 @@ -import Transloadit, { COMPANION_URL } from '@uppy/transloadit' import Uppy from '@uppy/core' -import Form from '@uppy/form' import Dashboard from '@uppy/dashboard' -import RemoteSources from '@uppy/remote-sources' +import Form from '@uppy/form' import ImageEditor from '@uppy/image-editor' -import Webcam from '@uppy/webcam' import ProgressBar from '@uppy/progress-bar' +import RemoteSources from '@uppy/remote-sources' +import Transloadit, { COMPANION_URL } from '@uppy/transloadit' +import Webcam from '@uppy/webcam' import '@uppy/core/dist/style.css' import '@uppy/dashboard/dist/style.css' @@ -59,13 +59,11 @@ const formUppy = new Uppy({ }) formUppy.on('error', (err) => { - document.querySelector('#test-form .error') - .textContent = err.message + document.querySelector('#test-form .error').textContent = err.message }) formUppy.on('upload-error', (file, err) => { - document.querySelector('#test-form .error') - .textContent = err.message + document.querySelector('#test-form .error').textContent = err.message }) formUppy.on('complete', ({ transloadit }) => { @@ -163,15 +161,13 @@ const dashboardModal = new Uppy({ dashboardModal.on('complete', ({ transloadit, successful, failed }) => { if (failed?.length !== 0) { - // eslint-disable-next-line no-console console.error('it failed', failed) } else { - // eslint-disable-next-line no-console console.log('success', { transloadit, successful }) } }) -function openModal () { +function openModal() { dashboardModal.getPlugin('Dashboard').openModal() } @@ -208,7 +204,7 @@ window.doUpload = (event) => { errorEl.classList.add('hidden') resultEl.textContent = JSON.stringify(transloadit[0].results, null, 2) - const resizedUrl = transloadit[0].results['resize'][0]['ssl_url'] + const resizedUrl = transloadit[0].results.resize[0].ssl_url const img = document.createElement('img') img.src = resizedUrl document.getElementById('upload-result-image').appendChild(img) diff --git a/examples/transloadit/server.js b/examples/transloadit/server.js index 27b505107..e76053323 100755 --- a/examples/transloadit/server.js +++ b/examples/transloadit/server.js @@ -1,13 +1,12 @@ #!/usr/bin/env node - import http from 'node:http' import qs from 'node:querystring' import he from 'he' const e = he.encode -function Header () { +function Header() { return ` @@ -28,7 +27,7 @@ function Header () { ` } -function Footer () { +function Footer() { return ` @@ -36,31 +35,28 @@ function Footer () { ` } -function FormFields (fields) { - function Field ([name, value]) { +function FormFields(fields) { + function Field([name, value]) { if (name === 'transloadit') return '' let isValueJSON = false if (value.startsWith('{') || value.startsWith('[')) { try { - // eslint-disable-next-line no-param-reassign - value = JSON.stringify( - JSON.parse(value), - null, - 2, - ) + value = JSON.stringify(JSON.parse(value), null, 2) isValueJSON = true } catch { // Nothing } } - const prettyValue = isValueJSON ? ` + const prettyValue = isValueJSON + ? `
${e(value)}
- ` : e(value) + ` + : e(value) return `
${e(name)}
@@ -78,8 +74,8 @@ function FormFields (fields) { ` } -function UploadsList (uploads) { - function Upload (upload) { +function UploadsList(uploads) { + function Upload(upload) { return `
  • ${e(upload.name)}
  • ` } @@ -90,12 +86,12 @@ function UploadsList (uploads) { ` } -function ResultsList (results) { - function Result (result) { +function ResultsList(results) { + function Result(result) { return `
  • ${e(result.name)} View
  • ` } - function ResultsSection (stepName) { + function ResultsSection(stepName) { return `

    ${e(stepName)}

      @@ -104,12 +100,10 @@ function ResultsList (results) { ` } - return Object.keys(results) - .map(ResultsSection) - .join('\n') + return Object.keys(results).map(ResultsSection).join('\n') } -function AssemblyResult (assembly) { +function AssemblyResult(assembly) { return `

      ${e(assembly.assembly_id)} (${e(assembly.ok)})

      ${UploadsList(assembly.uploads)} @@ -117,14 +111,14 @@ function AssemblyResult (assembly) { ` } -function onrequest (req, res) { +function onrequest(req, res) { if (req.url !== '/test') { res.writeHead(404, { 'content-type': 'text/html' }) res.end('404') return } - function onbody (body) { + function onbody(body) { const fields = qs.parse(body) const result = JSON.parse(fields.uppyResult) const assemblies = result[0].transloadit @@ -140,7 +134,9 @@ function onrequest (req, res) { { let body = '' - req.on('data', (chunk) => { body += chunk }) + req.on('data', (chunk) => { + body += chunk + }) req.on('end', () => { onbody(body) }) diff --git a/examples/uppy-with-companion/server/index.js b/examples/uppy-with-companion/server/index.js index ed85fa3f7..ae9cf38d5 100644 --- a/examples/uppy-with-companion/server/index.js +++ b/examples/uppy-with-companion/server/index.js @@ -6,11 +6,13 @@ const companion = require('@uppy/companion') const app = express() app.use(bodyParser.json()) -app.use(session({ - secret: 'some-secret', - resave: true, - saveUninitialized: true, -})) +app.use( + session({ + secret: 'some-secret', + resave: true, + saveUninitialized: true, + }), +) app.use((req, res, next) => { res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*') diff --git a/examples/vue3/src/App.vue b/examples/vue3/src/App.vue index 5a2bad4dc..4ce701a3c 100644 --- a/examples/vue3/src/App.vue +++ b/examples/vue3/src/App.vue @@ -42,23 +42,23 @@
      diff --git a/packages/@uppy/svelte/src/lib/components/DashboardModal.svelte b/packages/@uppy/svelte/src/lib/components/DashboardModal.svelte index 0dd57dc28..57e147002 100644 --- a/packages/@uppy/svelte/src/lib/components/DashboardModal.svelte +++ b/packages/@uppy/svelte/src/lib/components/DashboardModal.svelte @@ -2,57 +2,57 @@ lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body" > - import { onMount, onDestroy } from 'svelte' - import type { Uppy } from '@uppy/core' - import DashboardPlugin from '@uppy/dashboard' +import type { Uppy } from "@uppy/core"; +import DashboardPlugin from "@uppy/dashboard"; +import { onDestroy, onMount } from "svelte"; - let container: HTMLElement - let plugin: DashboardPlugin +let container: HTMLElement; +let plugin: DashboardPlugin; - export let uppy: Uppy - export let props: Object | undefined = {} - export let open: boolean - let lastOpen: boolean = open +export let uppy: Uppy; +export const props: Object | undefined = {}; +export let open: boolean; +let lastOpen: boolean = open; - export let plugins: string[] = [] +export const plugins: string[] = []; - const installPlugin = () => { - const options = { - id: 'svelte:DashboardModal', - plugins, - ...props, - target: container, - } +const installPlugin = () => { + const options = { + id: "svelte:DashboardModal", + plugins, + ...props, + target: container, + }; - uppy.use(DashboardPlugin, options) - plugin = uppy.getPlugin(options.id) as DashboardPlugin - if (open) plugin.openModal() - } - const uninstallPlugin = (uppyInstance: Uppy = uppy) => { - if (plugin != null) uppyInstance.removePlugin(plugin) - } + uppy.use(DashboardPlugin, options); + plugin = uppy.getPlugin(options.id) as DashboardPlugin; + if (open) plugin.openModal(); +}; +const uninstallPlugin = (uppyInstance: Uppy = uppy) => { + if (plugin != null) uppyInstance.removePlugin(plugin); +}; - onMount(() => installPlugin()) +onMount(() => installPlugin()); - onDestroy(() => uninstallPlugin()) - $: { - const options = { - id: 'svelte:DashboardModal', - plugins, - ...props, - target: container, - } - uppy.setOptions(options) - } - $: { - if (open && !lastOpen) { - plugin.openModal() - } - if (!open && lastOpen) { - plugin.closeModal() - } - lastOpen = open - } +onDestroy(() => uninstallPlugin()); +$: { + const options = { + id: "svelte:DashboardModal", + plugins, + ...props, + target: container, + }; + uppy.setOptions(options); +} +$: { + if (open && !lastOpen) { + plugin.openModal(); + } + if (!open && lastOpen) { + plugin.closeModal(); + } + lastOpen = open; +}
      diff --git a/packages/@uppy/svelte/src/lib/components/DragDrop.svelte b/packages/@uppy/svelte/src/lib/components/DragDrop.svelte index 3e116b0e4..854ee5b08 100644 --- a/packages/@uppy/svelte/src/lib/components/DragDrop.svelte +++ b/packages/@uppy/svelte/src/lib/components/DragDrop.svelte @@ -2,42 +2,42 @@ lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body" > - import { onMount, onDestroy } from 'svelte' - import type { Uppy } from '@uppy/core' - import DragDropPlugin from '@uppy/drag-drop' +import type { Uppy } from "@uppy/core"; +import DragDropPlugin from "@uppy/drag-drop"; +import { onDestroy, onMount } from "svelte"; - let container: HTMLElement - let plugin: DragDropPlugin +let container: HTMLElement; +let plugin: DragDropPlugin; - export let uppy: Uppy - export let props: Object | undefined = {} +export let uppy: Uppy; +export const props: Object | undefined = {}; - const installPlugin = () => { - const options = { - id: 'svelte:DragDrop', - inline: true, - ...props, - target: container, - } +const installPlugin = () => { + const options = { + id: "svelte:DragDrop", + inline: true, + ...props, + target: container, + }; - uppy.use(DragDropPlugin, options) - plugin = uppy.getPlugin(options.id) as DragDropPlugin - } - const uninstallPlugin = (uppyInstance: Uppy = uppy) => { - if (plugin != null) uppyInstance.removePlugin(plugin) - } + uppy.use(DragDropPlugin, options); + plugin = uppy.getPlugin(options.id) as DragDropPlugin; +}; +const uninstallPlugin = (uppyInstance: Uppy = uppy) => { + if (plugin != null) uppyInstance.removePlugin(plugin); +}; - onMount(() => installPlugin()) +onMount(() => installPlugin()); - onDestroy(() => uninstallPlugin()) - $: { - const options = { - id: 'svelte:DragDrop', - ...props, - target: container, - } - uppy.setOptions(options) - } +onDestroy(() => uninstallPlugin()); +$: { + const options = { + id: "svelte:DragDrop", + ...props, + target: container, + }; + uppy.setOptions(options); +}
      diff --git a/packages/@uppy/svelte/src/lib/components/ProgressBar.svelte b/packages/@uppy/svelte/src/lib/components/ProgressBar.svelte index 68287980b..b43603198 100644 --- a/packages/@uppy/svelte/src/lib/components/ProgressBar.svelte +++ b/packages/@uppy/svelte/src/lib/components/ProgressBar.svelte @@ -2,42 +2,42 @@ lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body" > - import { onMount, onDestroy } from 'svelte' - import type { Uppy } from '@uppy/core' - import ProgressBarPlugin from '@uppy/progress-bar' +import type { Uppy } from "@uppy/core"; +import ProgressBarPlugin from "@uppy/progress-bar"; +import { onDestroy, onMount } from "svelte"; - let container: HTMLElement - let plugin: ProgressBarPlugin +let container: HTMLElement; +let plugin: ProgressBarPlugin; - export let uppy: Uppy - export let props: Object | undefined = {} +export let uppy: Uppy; +export const props: Object | undefined = {}; - const installPlugin = () => { - const options = { - id: 'svelte:ProgressBar', - inline: true, - ...props, - target: container, - } +const installPlugin = () => { + const options = { + id: "svelte:ProgressBar", + inline: true, + ...props, + target: container, + }; - uppy.use(ProgressBarPlugin, options) - plugin = uppy.getPlugin(options.id) as ProgressBarPlugin - } - const uninstallPlugin = (uppyInstance: Uppy = uppy) => { - if (plugin != null) uppyInstance.removePlugin(plugin) - } + uppy.use(ProgressBarPlugin, options); + plugin = uppy.getPlugin(options.id) as ProgressBarPlugin; +}; +const uninstallPlugin = (uppyInstance: Uppy = uppy) => { + if (plugin != null) uppyInstance.removePlugin(plugin); +}; - onMount(() => installPlugin()) +onMount(() => installPlugin()); - onDestroy(() => uninstallPlugin()) - $: { - const options = { - id: 'svelte:ProgressBar', - ...props, - target: container, - } - uppy.setOptions(options) - } +onDestroy(() => uninstallPlugin()); +$: { + const options = { + id: "svelte:ProgressBar", + ...props, + target: container, + }; + uppy.setOptions(options); +}
      diff --git a/packages/@uppy/svelte/src/lib/components/StatusBar.svelte b/packages/@uppy/svelte/src/lib/components/StatusBar.svelte index b217ca37d..e7ef9a758 100644 --- a/packages/@uppy/svelte/src/lib/components/StatusBar.svelte +++ b/packages/@uppy/svelte/src/lib/components/StatusBar.svelte @@ -2,42 +2,42 @@ lang="ts" generics="M extends import('@uppy/utils/lib/UppyFile').Meta, B extends import('@uppy/utils/lib/UppyFile').Body" > - import { onMount, onDestroy } from 'svelte' - import type { Uppy } from '@uppy/core' - import StatusBarPlugin from '@uppy/status-bar' +import type { Uppy } from "@uppy/core"; +import StatusBarPlugin from "@uppy/status-bar"; +import { onDestroy, onMount } from "svelte"; - let container: HTMLElement - let plugin: StatusBarPlugin +let container: HTMLElement; +let plugin: StatusBarPlugin; - export let uppy: Uppy - export let props: Object | undefined = {} +export let uppy: Uppy; +export const props: Object | undefined = {}; - const installPlugin = () => { - const options = { - id: 'svelte:StatusBar', - inline: true, - ...props, - target: container, - } +const installPlugin = () => { + const options = { + id: "svelte:StatusBar", + inline: true, + ...props, + target: container, + }; - uppy.use(StatusBarPlugin, options) - plugin = uppy.getPlugin(options.id) as StatusBarPlugin - } - const uninstallPlugin = (uppyInstance: Uppy = uppy) => { - if (plugin != null) uppyInstance.removePlugin(plugin) - } + uppy.use(StatusBarPlugin, options); + plugin = uppy.getPlugin(options.id) as StatusBarPlugin; +}; +const uninstallPlugin = (uppyInstance: Uppy = uppy) => { + if (plugin != null) uppyInstance.removePlugin(plugin); +}; - onMount(() => installPlugin()) +onMount(() => installPlugin()); - onDestroy(() => uninstallPlugin()) - $: { - const options = { - id: 'svelte:StatusBar', - ...props, - target: container, - } - uppy.setOptions(options) - } +onDestroy(() => uninstallPlugin()); +$: { + const options = { + id: "svelte:StatusBar", + ...props, + target: container, + }; + uppy.setOptions(options); +}
      diff --git a/packages/@uppy/svelte/src/lib/components/headless/UppyContextProvider.svelte b/packages/@uppy/svelte/src/lib/components/headless/UppyContextProvider.svelte index e1004278b..f19b9a6fd 100644 --- a/packages/@uppy/svelte/src/lib/components/headless/UppyContextProvider.svelte +++ b/packages/@uppy/svelte/src/lib/components/headless/UppyContextProvider.svelte @@ -1,12 +1,12 @@