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 @@
${e(value)}