From 2f691acd3f8449f182168e084797656ba22f011a Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 28 Sep 2023 15:47:52 +0100 Subject: [PATCH] meta: add Prettier (#4707) JS files are ignored for now because we want to migrate them to TS anyway. MD files are also ignored to minimize the diff. ESLint is run twice twice on TS files in case it conflicts with Prettier. --- .eslintrc.js | 19 ++++++++++++++++--- .prettierignore | 7 +++++++ .prettierrc.js | 14 ++++++++++++++ e2e/clients/index.html | 2 +- examples/transloadit/index.html | 2 +- package.json | 9 ++++++++- yarn.lock | 22 ++++++++++++++++++++++ 7 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.js diff --git a/.eslintrc.js b/.eslintrc.js index 84b9bee40..0b6c41675 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,7 +8,7 @@ const svgPresentationAttributes = [ module.exports = { root: true, - extends: ['transloadit'], + extends: ['transloadit', 'prettier'], env: { es6: true, jest: true, @@ -63,7 +63,6 @@ module.exports = { // rules we want to enforce 'array-callback-return': 'error', 'func-names': 'error', - 'implicit-arrow-linebreak': 'error', 'import/no-dynamic-require': 'error', 'import/no-extraneous-dependencies': 'error', 'max-len': 'error', @@ -142,6 +141,7 @@ module.exports = { { files: [ '*.jsx', + '*.tsx', 'packages/@uppy/react-native/**/*.js', ], parser: 'espree', @@ -358,6 +358,7 @@ module.exports = { 'test/**/*.ts', '*.test.js', '*.test-d.ts', + '*.test-d.tsx', 'postcss.config.js', '.eslintrc.js', 'private/**/*.js', @@ -474,11 +475,23 @@ module.exports = { }, }, { - files: ['**/react/*.md/*.js', '**/react.md/*.js', '**/react-*.md/*.js'], + 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: ['e2e/**/*.ts'], extends: ['plugin:cypress/recommended'], diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..cfebd2d97 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,7 @@ +node_modules/ +*.js +*.jsx +*.cjs +*.mjs +*.md +*.lock diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 000000000..df02f7bc1 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,14 @@ +module.exports = { + proseWrap: 'always', + singleQuote: true, + trailingComma: 'all', + semi: false, + overrides: [ + { + files: 'packages/@uppy/angular/**', + options: { + semi: true, + }, + }, + ], +} diff --git a/e2e/clients/index.html b/e2e/clients/index.html index 05311bd03..398cc569a 100644 --- a/e2e/clients/index.html +++ b/e2e/clients/index.html @@ -18,6 +18,6 @@
  • dashboard-ui
  • dashboard-vue
  • - diff --git a/examples/transloadit/index.html b/examples/transloadit/index.html index 22c804590..e695fda9c 100644 --- a/examples/transloadit/index.html +++ b/examples/transloadit/index.html @@ -56,7 +56,7 @@ -
    +