123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- /* 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: [
- '@babel/eslint-plugin',
- 'jest',
- 'markdown',
- 'node',
- 'prefer-import',
- 'promise',
- 'react',
- // extra:
- 'compat',
- 'jsdoc',
- 'no-only-tests',
- 'unicorn',
- ],
- parser: '@babel/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',
- // compat
- 'compat/compat': ['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/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: [
- '*.test.js',
- '*.test.ts',
- 'test/endtoend/*.js',
- 'bin/**.js',
- ],
- rules: {
- 'compat/compat': ['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[importKind="type"][source.value=/^\\.\\.?\\x2F.+\\.js$/]',
- message: 'Do not use ".js" file extension for relative import type declarations',
- }, {
- selector: 'ImportDeclaration[source.value=/^@uppy\\x2Futils\\x2Flib\\x2F.+\\.[mc]?[jt]sx?$/]',
- message: 'Do not use file extension when importing from @uppy/utils',
- }],
- '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',
- },
- },
- ],
- }
|