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 @@