From 8dac7e494031b1018d194eaf1b98ee11f446cbdc Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 14:29:32 +0530 Subject: [PATCH 1/9] Lint React imports Refs: https://github.com/jsx-eslint/eslint-plugin-react/issues/2628 https://github.com/gonstoll/eslint-plugin-react-namespace-import --- packages/build-config/eslintrc-typescript.js | 12 ++++++++++-- packages/build-config/package.json | 1 + packages/ui/components/Card.tsx | 2 ++ yarn.lock | 9 +++++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/build-config/eslintrc-typescript.js b/packages/build-config/eslintrc-typescript.js index 783330cad8..faaa0bfa8a 100644 --- a/packages/build-config/eslintrc-typescript.js +++ b/packages/build-config/eslintrc-typescript.js @@ -5,11 +5,19 @@ module.exports = { "plugin:@typescript-eslint/strict-type-checked", "plugin:@typescript-eslint/stylistic-type-checked", ], - plugins: ["@typescript-eslint"], + plugins: ["@typescript-eslint", "react-namespace-import"], parser: "@typescript-eslint/parser", parserOptions: { project: true, }, - ignorePatterns: [".eslintrc.js"], root: true, + ignorePatterns: [".eslintrc.js"], + rules: { + // The recommended way to import React is: + // + // import * as React from "react"; + // + // This rule enforces that. + "react-namespace-import/no-namespace-import": "error", + }, }; diff --git a/packages/build-config/package.json b/packages/build-config/package.json index 4bacb61f38..d3278c3f58 100644 --- a/packages/build-config/package.json +++ b/packages/build-config/package.json @@ -5,6 +5,7 @@ "devDependencies": { "@typescript-eslint/eslint-plugin": "^7", "@typescript-eslint/parser": "^7", + "eslint-plugin-react-namespace-import": "^1.0.5", "prettier-plugin-organize-imports": "^3.2.4" } } diff --git a/packages/ui/components/Card.tsx b/packages/ui/components/Card.tsx index 6853d236be..ee19e9f52f 100644 --- a/packages/ui/components/Card.tsx +++ b/packages/ui/components/Card.tsx @@ -1,3 +1,5 @@ +import * as React from "react"; + export const Card: React.FC = () => { return
Hello
; }; diff --git a/yarn.lock b/yarn.lock index e82a02da75..3dda3d3b94 100644 --- a/yarn.lock +++ b/yarn.lock @@ -579,7 +579,7 @@ "@sentry/types" "7.77.0" "@sentry/utils" "7.77.0" -"@sentry/cli@1.75.0", "@sentry/cli@^1.74.6": +"@sentry/cli@^1.74.6": version "1.75.0" resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-1.75.0.tgz#4a5e71b5619cd4e9e6238cc77857c66f6b38d86a" integrity sha512-vT8NurHy00GcN8dNqur4CMIYvFH3PaKdkX3qllVvi4syybKqjwoz+aWRCvprbYv0knweneFkLt1SmBWqazUMfA== @@ -1978,6 +1978,11 @@ eslint-plugin-jsx-a11y@^6.7.1: resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3" integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g== +eslint-plugin-react-namespace-import@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-namespace-import/-/eslint-plugin-react-namespace-import-1.0.5.tgz#9da74bb169d13336a187abd3c42e22d2fe10f91d" + integrity sha512-0gUj6hSRL8cTxyLtVvbu/Rzr3aEmO4fUyJIc3qkGum2Lth+atx3z/JJgBd+PUpaksdv0D6gmBBHwjmn/nPAobQ== + eslint-plugin-react@^7.33.2, eslint-plugin-react@latest: version "7.33.2" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.33.2.tgz#69ee09443ffc583927eafe86ffebb470ee737608" @@ -2976,7 +2981,7 @@ libsodium-wrappers@0.7.9: dependencies: libsodium "^0.7.0" -libsodium@0.7.9, libsodium@^0.7.0: +libsodium@^0.7.0: version "0.7.9" resolved "https://registry.yarnpkg.com/libsodium/-/libsodium-0.7.9.tgz#4bb7bcbf662ddd920d8795c227ae25bbbfa3821b" integrity sha512-gfeADtR4D/CM0oRUviKBViMGXZDgnFdMKMzHsvBdqLBHd9ySi6EtYnmuhHVDDYgYpAO8eU8hEY+F8vIUAPh08A== From 7a6ff68eb10dcf31d573633d74e2c0f8425933b5 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 14:46:02 +0530 Subject: [PATCH 2/9] prettier-plugin-packagejson --- .prettierrc.json | 5 +- package.json | 10 ++-- packages/accounts/package.json | 4 +- packages/build-config/package.json | 3 +- packages/eslint-config/package.json | 8 +-- packages/next/package.json | 6 +-- yarn.lock | 84 ++++++++++++++++++++++++++++- 7 files changed, 102 insertions(+), 18 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index f657075f0c..8b06525972 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,4 +1,7 @@ { "tabWidth": 4, - "plugins": ["prettier-plugin-organize-imports"] + "plugins": [ + "prettier-plugin-organize-imports", + "prettier-plugin-packagejson" + ] } diff --git a/package.json b/package.json index 9687da8c2c..4e1e216473 100644 --- a/package.json +++ b/package.json @@ -14,20 +14,20 @@ "build:photos": "yarn workspace photos next build", "dev": "yarn dev:photos", "dev:accounts": "yarn workspace accounts next dev", + "dev:albums": "yarn workspace photos next dev -p 3002", "dev:auth": "yarn workspace auth next dev", "dev:cast": "yarn workspace cast next dev", "dev:photos": "yarn workspace photos next dev", - "dev:albums": "yarn workspace photos next dev -p 3002", "lint": "yarn prettier --check . && yarn workspaces run eslint .", "lint-fix": "yarn prettier --write . && yarn workspaces run eslint --fix ." }, + "resolutions": { + "@sentry/cli": "1.75.0", + "libsodium": "0.7.9" + }, "devDependencies": { "eslint": "^8", "prettier": "^3", "typescript": "^5" - }, - "resolutions": { - "@sentry/cli": "1.75.0", - "libsodium": "0.7.9" } } diff --git a/packages/accounts/package.json b/packages/accounts/package.json index ebfa03eb02..695c057683 100644 --- a/packages/accounts/package.json +++ b/packages/accounts/package.json @@ -3,8 +3,8 @@ "version": "0.0.0", "private": true, "scripts": { - "lint": "eslint .", - "build": "yarn lint && tsc" + "build": "yarn lint && tsc", + "lint": "eslint ." }, "dependencies": { "@/next": "*", diff --git a/packages/build-config/package.json b/packages/build-config/package.json index d3278c3f58..47aff3276b 100644 --- a/packages/build-config/package.json +++ b/packages/build-config/package.json @@ -6,6 +6,7 @@ "@typescript-eslint/eslint-plugin": "^7", "@typescript-eslint/parser": "^7", "eslint-plugin-react-namespace-import": "^1.0.5", - "prettier-plugin-organize-imports": "^3.2.4" + "prettier-plugin-organize-imports": "^3.2.4", + "prettier-plugin-packagejson": "^2.4.12" } } diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 39ab38a29b..a886b015ea 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,11 +1,8 @@ { "name": "@ente/eslint-config", - "main": "index.js", "version": "1.0.0", + "main": "index.js", "dependencies": {}, - "standard": { - "parser": "babel-eslint" - }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^7", "@typescript-eslint/parser": "^7", @@ -13,5 +10,8 @@ "eslint-config-next": "latest", "eslint-config-prettier": "latest", "eslint-plugin-react": "latest" + }, + "standard": { + "parser": "babel-eslint" } } diff --git a/packages/next/package.json b/packages/next/package.json index 090cca445c..5f40a32df9 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -2,11 +2,11 @@ "name": "@/next", "version": "0.0.0", "private": true, - "devDependencies": { - "@/build-config": "*" - }, "dependencies": { "@/ui": "*", "next": "^14.1" + }, + "devDependencies": { + "@/build-config": "*" } } diff --git a/yarn.lock b/yarn.lock index 3dda3d3b94..15b9f14657 100644 --- a/yarn.lock +++ b/yarn.lock @@ -511,6 +511,11 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== +"@pkgr/core@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" + integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== + "@polka/url@^1.0.0-next.24": version "1.0.0-next.24" resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.24.tgz#58601079e11784d20f82d0585865bb42305c4df3" @@ -1688,6 +1693,16 @@ dequal@^2.0.3: resolved "https://registry.yarnpkg.com/dequal/-/dequal-2.0.3.tgz#2644214f1997d39ed0ee0ece72335490a7ac67be" integrity sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA== +detect-indent@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-7.0.1.tgz#cbb060a12842b9c4d333f1cac4aa4da1bb66bc25" + integrity sha512-Mc7QhQ8s+cLrnUfU/Ji94vG/r8M26m8f++vyres4ZoojaRDpZ1eSIh/EpzLNwlWuvzSZ3UbDFspjFvTDXe6e/g== + +detect-newline@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-4.0.1.tgz#fcefdb5713e1fb8cb2839b8b6ee22e6716ab8f23" + integrity sha512-qE3Veg1YXzGHQhlA6jzebZN2qVf6NX+A7m7qlhCGG30dJixrAQhYOsJjsnBjJkCSmuOPpCk30145fr8FV0bzog== + dir-glob@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" @@ -2120,7 +2135,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.2.9, fast-glob@^3.3.1: +fast-glob@^3.2.9, fast-glob@^3.3.0, fast-glob@^3.3.1: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== @@ -2301,6 +2316,11 @@ get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.1, get-intrinsic@ has-symbols "^1.0.3" hasown "^2.0.0" +get-stdin@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-9.0.0.tgz#3983ff82e03d56f1b2ea0d3e60325f39d703a575" + integrity sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA== + get-symbol-description@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.0.2.tgz#533744d5aa20aca4e079c8e5daf7fd44202821f5" @@ -2325,6 +2345,11 @@ get-user-locale@^2.3: "@types/lodash.memoize" "^4.1.7" lodash.memoize "^4.1.1" +git-hooks-list@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/git-hooks-list/-/git-hooks-list-3.1.0.tgz#386dc531dcc17474cf094743ff30987a3d3e70fc" + integrity sha512-LF8VeHeR7v+wAbXqfgRlTSX/1BJR9Q1vEMR8JAz1cEg6GX07+zyj3sAdDvYjj/xnlIfVuGgj4qBei1K3hKH+PA== + glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -2399,6 +2424,17 @@ globby@^11.1.0: merge2 "^1.4.1" slash "^3.0.0" +globby@^13.1.2: + version "13.2.2" + resolved "https://registry.yarnpkg.com/globby/-/globby-13.2.2.tgz#63b90b1bf68619c2135475cbd4e71e66aa090592" + integrity sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w== + dependencies: + dir-glob "^3.0.1" + fast-glob "^3.3.0" + ignore "^5.2.4" + merge2 "^1.4.1" + slash "^4.0.0" + gopd@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" @@ -2740,6 +2776,11 @@ is-path-inside@^3.0.3: resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== +is-plain-obj@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-4.1.0.tgz#d65025edec3657ce032fd7db63c97883eaed71f0" + integrity sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg== + is-plain-object@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" @@ -3495,6 +3536,14 @@ prettier-plugin-organize-imports@^3.2.4: resolved "https://registry.yarnpkg.com/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-3.2.4.tgz#77967f69d335e9c8e6e5d224074609309c62845e" integrity sha512-6m8WBhIp0dfwu0SkgfOxJqh+HpdyfqSSLfKKRZSFbDuEQXDDndb8fTpRWkUrX/uBenkex3MgnVk0J3b3Y5byog== +prettier-plugin-packagejson@^2.4.12: + version "2.4.12" + resolved "https://registry.yarnpkg.com/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.4.12.tgz#eeb917dad83ae42d0caccc9f26d3728b5c4f2434" + integrity sha512-hifuuOgw5rHHTdouw9VrhT8+Nd7UwxtL1qco8dUfd4XUFQL6ia3xyjSxhPQTsGnSYFraTWy5Omb+MZm/OWDTpQ== + dependencies: + sort-package-json "2.8.0" + synckit "0.9.0" + prettier@^3: version "3.2.5" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368" @@ -4004,6 +4053,29 @@ slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== +slash@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7" + integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== + +sort-object-keys@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/sort-object-keys/-/sort-object-keys-1.1.3.tgz#bff833fe85cab147b34742e45863453c1e190b45" + integrity sha512-855pvK+VkU7PaKYPc+Jjnmt4EzejQHyhhF33q31qG8x7maDzkeFhAAThdCYay11CISO+qAMwjOBP+fPZe0IPyg== + +sort-package-json@2.8.0: + version "2.8.0" + resolved "https://registry.yarnpkg.com/sort-package-json/-/sort-package-json-2.8.0.tgz#6a46439ad0fef77f091e678e103f03ecbea575c8" + integrity sha512-PxeNg93bTJWmDGnu0HADDucoxfFiKkIr73Kv85EBThlI1YQPdc0XovBgg2llD0iABZbu2SlKo8ntGmOP9wOj/g== + dependencies: + detect-indent "^7.0.1" + detect-newline "^4.0.0" + get-stdin "^9.0.0" + git-hooks-list "^3.0.0" + globby "^13.1.2" + is-plain-obj "^4.1.0" + sort-object-keys "^1.1.3" + "source-map-js@>=0.6.2 <2.0.0", source-map-js@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" @@ -4169,6 +4241,14 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== +synckit@0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.9.0.tgz#5b33b458b3775e4466a5b377fba69c63572ae449" + integrity sha512-7RnqIMq572L8PeEzKeBINYEJDDxpcH8JEgLwUqBd3TkofhFRbkq4QLR0u+36avGAhCRbk2nnmjcW9SE531hPDg== + dependencies: + "@pkgr/core" "^0.1.0" + tslib "^2.6.2" + tapable@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" @@ -4264,7 +4344,7 @@ tsconfig-paths@^3.15.0: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@^2.0.0, tslib@^2.0.3, tslib@^2.4.0: +tslib@^2.0.0, tslib@^2.0.3, tslib@^2.4.0, tslib@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== From 5b74c81c6c81367e7d96f2f6f4617e5a42abda7e Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 14:49:20 +0530 Subject: [PATCH 3/9] Remove unnecessary scripts section --- packages/accounts/package.json | 4 ---- yarn.lock | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/accounts/package.json b/packages/accounts/package.json index 695c057683..b26c365db0 100644 --- a/packages/accounts/package.json +++ b/packages/accounts/package.json @@ -2,10 +2,6 @@ "name": "@ente/accounts", "version": "0.0.0", "private": true, - "scripts": { - "build": "yarn lint && tsc", - "lint": "eslint ." - }, "dependencies": { "@/next": "*", "@ente/eslint-config": "*", diff --git a/yarn.lock b/yarn.lock index 15b9f14657..0d2e46a825 100644 --- a/yarn.lock +++ b/yarn.lock @@ -584,7 +584,7 @@ "@sentry/types" "7.77.0" "@sentry/utils" "7.77.0" -"@sentry/cli@^1.74.6": +"@sentry/cli@1.75.0", "@sentry/cli@^1.74.6": version "1.75.0" resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-1.75.0.tgz#4a5e71b5619cd4e9e6238cc77857c66f6b38d86a" integrity sha512-vT8NurHy00GcN8dNqur4CMIYvFH3PaKdkX3qllVvi4syybKqjwoz+aWRCvprbYv0knweneFkLt1SmBWqazUMfA== @@ -3022,7 +3022,7 @@ libsodium-wrappers@0.7.9: dependencies: libsodium "^0.7.0" -libsodium@^0.7.0: +libsodium@0.7.9, libsodium@^0.7.0: version "0.7.9" resolved "https://registry.yarnpkg.com/libsodium/-/libsodium-0.7.9.tgz#4bb7bcbf662ddd920d8795c227ae25bbbfa3821b" integrity sha512-gfeADtR4D/CM0oRUviKBViMGXZDgnFdMKMzHsvBdqLBHd9ySi6EtYnmuhHVDDYgYpAO8eU8hEY+F8vIUAPh08A== From 8f5b462736b3b98b4346e786d459fbbef5162c9a Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 15:13:57 +0530 Subject: [PATCH 4/9] Add eslint-plugin-react-hooks --- packages/build-config/eslintrc-typescript.js | 1 + packages/build-config/package.json | 1 + yarn.lock | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/build-config/eslintrc-typescript.js b/packages/build-config/eslintrc-typescript.js index faaa0bfa8a..faec25874e 100644 --- a/packages/build-config/eslintrc-typescript.js +++ b/packages/build-config/eslintrc-typescript.js @@ -2,6 +2,7 @@ module.exports = { extends: [ "eslint:recommended", + "plugin:react-hooks/recommended", "plugin:@typescript-eslint/strict-type-checked", "plugin:@typescript-eslint/stylistic-type-checked", ], diff --git a/packages/build-config/package.json b/packages/build-config/package.json index 47aff3276b..204515f838 100644 --- a/packages/build-config/package.json +++ b/packages/build-config/package.json @@ -5,6 +5,7 @@ "devDependencies": { "@typescript-eslint/eslint-plugin": "^7", "@typescript-eslint/parser": "^7", + "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-namespace-import": "^1.0.5", "prettier-plugin-organize-imports": "^3.2.4", "prettier-plugin-packagejson": "^2.4.12" diff --git a/yarn.lock b/yarn.lock index 0d2e46a825..85dcbd1b08 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1988,7 +1988,7 @@ eslint-plugin-jsx-a11y@^6.7.1: object.entries "^1.1.7" object.fromentries "^2.0.7" -"eslint-plugin-react-hooks@^4.5.0 || 5.0.0-canary-7118f5dd7-20230705": +"eslint-plugin-react-hooks@^4.5.0 || 5.0.0-canary-7118f5dd7-20230705", eslint-plugin-react-hooks@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3" integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g== From 666cd002c7014f7fdca703d9564c5281f2d6bfe4 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 15:25:31 +0530 Subject: [PATCH 5/9] Split react and non-react lints --- .../build-config/eslintrc-typescript-react.js | 24 +++++++++++++++++++ packages/build-config/eslintrc-typescript.js | 11 +-------- packages/next/.eslintrc.js | 2 +- packages/ui/.eslintrc.js | 2 +- 4 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 packages/build-config/eslintrc-typescript-react.js diff --git a/packages/build-config/eslintrc-typescript-react.js b/packages/build-config/eslintrc-typescript-react.js new file mode 100644 index 0000000000..faec25874e --- /dev/null +++ b/packages/build-config/eslintrc-typescript-react.js @@ -0,0 +1,24 @@ +/* eslint-env node */ +module.exports = { + extends: [ + "eslint:recommended", + "plugin:react-hooks/recommended", + "plugin:@typescript-eslint/strict-type-checked", + "plugin:@typescript-eslint/stylistic-type-checked", + ], + plugins: ["@typescript-eslint", "react-namespace-import"], + parser: "@typescript-eslint/parser", + parserOptions: { + project: true, + }, + root: true, + ignorePatterns: [".eslintrc.js"], + rules: { + // The recommended way to import React is: + // + // import * as React from "react"; + // + // This rule enforces that. + "react-namespace-import/no-namespace-import": "error", + }, +}; diff --git a/packages/build-config/eslintrc-typescript.js b/packages/build-config/eslintrc-typescript.js index faec25874e..6b3a3c457b 100644 --- a/packages/build-config/eslintrc-typescript.js +++ b/packages/build-config/eslintrc-typescript.js @@ -2,23 +2,14 @@ module.exports = { extends: [ "eslint:recommended", - "plugin:react-hooks/recommended", "plugin:@typescript-eslint/strict-type-checked", "plugin:@typescript-eslint/stylistic-type-checked", ], - plugins: ["@typescript-eslint", "react-namespace-import"], + plugins: ["@typescript-eslint"], parser: "@typescript-eslint/parser", parserOptions: { project: true, }, root: true, ignorePatterns: [".eslintrc.js"], - rules: { - // The recommended way to import React is: - // - // import * as React from "react"; - // - // This rule enforces that. - "react-namespace-import/no-namespace-import": "error", - }, }; diff --git a/packages/next/.eslintrc.js b/packages/next/.eslintrc.js index 72519a5735..4bc0524ffb 100644 --- a/packages/next/.eslintrc.js +++ b/packages/next/.eslintrc.js @@ -1,5 +1,5 @@ module.exports = { - extends: ["@/build-config/eslintrc-typescript"], + extends: ["@/build-config/eslintrc-typescript-react"], parserOptions: { tsconfigRootDir: __dirname, }, diff --git a/packages/ui/.eslintrc.js b/packages/ui/.eslintrc.js index a9a3393e03..7372de7294 100644 --- a/packages/ui/.eslintrc.js +++ b/packages/ui/.eslintrc.js @@ -1,5 +1,5 @@ module.exports = { - extends: ["@/build-config/eslintrc-typescript"], + extends: ["@/build-config/eslintrc-typescript-react"], parserOptions: { tsconfigRootDir: __dirname, }, From 990e51a9040eeae26c50253073d348033050f8bc Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 16:33:47 +0530 Subject: [PATCH 6/9] Move down react dependencies --- apps/accounts/package.json | 3 +-- apps/photos/package.json | 1 - packages/ui/package.json | 8 +++++--- yarn.lock | 7 +++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/accounts/package.json b/apps/accounts/package.json index 6a50ed08fc..40c6472e2f 100644 --- a/apps/accounts/package.json +++ b/apps/accounts/package.json @@ -9,7 +9,6 @@ "@ente/shared": "*" }, "devDependencies": { - "@types/node": "^14.6.4", - "@types/react": "^18" + "@types/node": "^14.6.4" } } diff --git a/apps/photos/package.json b/apps/photos/package.json index 972f1788d5..7e1636e753 100644 --- a/apps/photos/package.json +++ b/apps/photos/package.json @@ -68,7 +68,6 @@ "@types/leaflet": "^1.9.3", "@types/node": "^14.6.4", "@types/photoswipe": "^4.1.1", - "@types/react": "^18", "@types/react-collapse": "^5.0.1", "@types/react-datepicker": "^4.15.0", "@types/react-select": "^4.0.15", diff --git a/packages/ui/package.json b/packages/ui/package.json index 332dc906bf..756d1158ac 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -11,11 +11,13 @@ "get-user-locale": "^2.3", "i18next": "^23.10", "i18next-http-backend": "^2.5", - "react": "18.2.0", - "react-dom": "18.2.0", + "react": "^18", + "react-dom": "^18", "react-i18next": "^14" }, "devDependencies": { - "@/build-config": "*" + "@/build-config": "*", + "@types/react": "^18", + "@types/react-dom": "^18" } } diff --git a/yarn.lock b/yarn.lock index 85dcbd1b08..fb11588e8b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -880,7 +880,7 @@ date-fns "^2.0.1" react-popper "^2.2.5" -"@types/react-dom@*": +"@types/react-dom@*", "@types/react-dom@^18": version "18.2.19" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.19.tgz#b84b7c30c635a6c26c6a6dfbb599b2da9788be58" integrity sha512-aZvQL6uUbIJpjZk4U8JZGbau9KDeAwMfmhyWorxgBkqDIEf6ROjRozcmPIicqsUwPUjbkDfHKgGee1Lq65APcA== @@ -3631,7 +3631,7 @@ react-datepicker@^4.16.0: react-onclickoutside "^6.13.0" react-popper "^2.3.0" -react-dom@18.2.0: +react-dom@^18: version "18.2.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.2.0.tgz#22aaf38708db2674ed9ada224ca4aa708d821e3d" integrity sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g== @@ -3761,7 +3761,7 @@ react-window@^1.8.6: "@babel/runtime" "^7.0.0" memoize-one ">=3.1.1 <6" -react@18.2.0: +react@^18: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5" integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ== @@ -4099,7 +4099,6 @@ streamsearch@^1.1.0: integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== "string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0: - name string-width-cjs version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== From e72e7e2f3ae7a7f275b3ea02abb43b8827ffa34f Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 16:37:46 +0530 Subject: [PATCH 7/9] Omit patch numbers --- packages/build-config/package.json | 8 ++++---- packages/utils/package.json | 2 +- yarn.lock | 11 ++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/build-config/package.json b/packages/build-config/package.json index 204515f838..d7271be98b 100644 --- a/packages/build-config/package.json +++ b/packages/build-config/package.json @@ -5,9 +5,9 @@ "devDependencies": { "@typescript-eslint/eslint-plugin": "^7", "@typescript-eslint/parser": "^7", - "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-namespace-import": "^1.0.5", - "prettier-plugin-organize-imports": "^3.2.4", - "prettier-plugin-packagejson": "^2.4.12" + "eslint-plugin-react-hooks": "^4.6", + "eslint-plugin-react-namespace-import": "^1.0", + "prettier-plugin-organize-imports": "^3.2", + "prettier-plugin-packagejson": "^2.4" } } diff --git a/packages/utils/package.json b/packages/utils/package.json index 088348e11f..f03674fbe0 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -5,7 +5,7 @@ "dependencies": { "is-electron": "^2.2", "libsodium-wrappers": "0.7.9", - "yup": "^1.3.3" + "yup": "^1.3" }, "devDependencies": { "@/build-config": "*", diff --git a/yarn.lock b/yarn.lock index fb11588e8b..a51ed7f969 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1988,12 +1988,12 @@ eslint-plugin-jsx-a11y@^6.7.1: object.entries "^1.1.7" object.fromentries "^2.0.7" -"eslint-plugin-react-hooks@^4.5.0 || 5.0.0-canary-7118f5dd7-20230705", eslint-plugin-react-hooks@^4.6.0: +"eslint-plugin-react-hooks@^4.5.0 || 5.0.0-canary-7118f5dd7-20230705", eslint-plugin-react-hooks@^4.6: version "4.6.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3" integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g== -eslint-plugin-react-namespace-import@^1.0.5: +eslint-plugin-react-namespace-import@^1.0: version "1.0.5" resolved "https://registry.yarnpkg.com/eslint-plugin-react-namespace-import/-/eslint-plugin-react-namespace-import-1.0.5.tgz#9da74bb169d13336a187abd3c42e22d2fe10f91d" integrity sha512-0gUj6hSRL8cTxyLtVvbu/Rzr3aEmO4fUyJIc3qkGum2Lth+atx3z/JJgBd+PUpaksdv0D6gmBBHwjmn/nPAobQ== @@ -3531,12 +3531,12 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prettier-plugin-organize-imports@^3.2.4: +prettier-plugin-organize-imports@^3.2: version "3.2.4" resolved "https://registry.yarnpkg.com/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-3.2.4.tgz#77967f69d335e9c8e6e5d224074609309c62845e" integrity sha512-6m8WBhIp0dfwu0SkgfOxJqh+HpdyfqSSLfKKRZSFbDuEQXDDndb8fTpRWkUrX/uBenkex3MgnVk0J3b3Y5byog== -prettier-plugin-packagejson@^2.4.12: +prettier-plugin-packagejson@^2.4: version "2.4.12" resolved "https://registry.yarnpkg.com/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.4.12.tgz#eeb917dad83ae42d0caccc9f26d3728b5c4f2434" integrity sha512-hifuuOgw5rHHTdouw9VrhT8+Nd7UwxtL1qco8dUfd4XUFQL6ia3xyjSxhPQTsGnSYFraTWy5Omb+MZm/OWDTpQ== @@ -4099,6 +4099,7 @@ streamsearch@^1.1.0: integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== "string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0: + name string-width-cjs version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -4634,7 +4635,7 @@ yocto-queue@^0.1.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== -yup@^1.3.3: +yup@^1.3: version "1.3.3" resolved "https://registry.yarnpkg.com/yup/-/yup-1.3.3.tgz#d2f6020ad1679754c5f8178a29243d5447dead04" integrity sha512-v8QwZSsHH2K3/G9WSkp6mZKO+hugKT1EmnMqLNUcfu51HU9MDyhlETT/JgtzprnrnQHPWsjc6MUDMBp/l9fNnw== From d15deb1cb0b3d48b6f77dd158c15633319a08931 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 17:01:07 +0530 Subject: [PATCH 8/9] Document NODE_VERSION --- apps/accounts/package.json | 3 --- apps/photos/package.json | 1 - docs/deploy.md | 21 +++++++++++++++++++++ packages/next/package.json | 3 ++- yarn.lock | 7 +------ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/apps/accounts/package.json b/apps/accounts/package.json index 40c6472e2f..3136b0e809 100644 --- a/apps/accounts/package.json +++ b/apps/accounts/package.json @@ -7,8 +7,5 @@ "@ente/accounts": "*", "@ente/eslint-config": "*", "@ente/shared": "*" - }, - "devDependencies": { - "@types/node": "^14.6.4" } } diff --git a/apps/photos/package.json b/apps/photos/package.json index 7e1636e753..1a088c99d9 100644 --- a/apps/photos/package.json +++ b/apps/photos/package.json @@ -66,7 +66,6 @@ "@next/bundle-analyzer": "^14.1", "@types/bs58": "^4.0.1", "@types/leaflet": "^1.9.3", - "@types/node": "^14.6.4", "@types/photoswipe": "^4.1.1", "@types/react-collapse": "^5.0.1", "@types/react-datepicker": "^4.15.0", diff --git a/docs/deploy.md b/docs/deploy.md index 8838204c00..aff3dbd59d 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -32,11 +32,32 @@ see the Cloudflare dashboard for the latest: - _testing.ente.io_: `main` - _web.ente.io_: `photos-release` - _auth.ente.io_: `auth-release` +- _accounts.ente.io_: `accounts-release` +- _cast.ente.io_: `cast-release` Thus to trigger a, say, production deployment of the photos app, we can open and merge a PR into the `photos-release` branch. Cloudflare will then build and deploy the code to _web.ente.io_. +Apart from this, there are also some subdomains: + +- `albums.ente.io` is a CNAME alias to the production deployment + (`web.ente.io`). However, when the code detects that it is being served from + `albums.ente.io`, it redirects to the `/shared-albums` page (Enhancement: + serve it as a separate app with a smaller bundle size). + +- `payments.ente.io` and `family.ente.io` are currently in a separate + repositories (Enhancement: bring them in here). + +In Cloudflare Pages setting the following environment variables are defined: + +- `NODE_VERSION`: Determines which version of Node is used when we do `yarn + build:foo`. Currently this is set to `20.10.0`. The major version here should + match that of `@types/node` in our dev dependencies. + +- `SENTRY_AUTH_TOKEN`: An encrypted environment variable that is used by the + Sentry Webpack Plugin to upload sourcemaps during the build. + ## Adding a new app 1. Add a mapping in `scripts/deploy.sh`. diff --git a/packages/next/package.json b/packages/next/package.json index 5f40a32df9..03f2c17b54 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -7,6 +7,7 @@ "next": "^14.1" }, "devDependencies": { - "@/build-config": "*" + "@/build-config": "*", + "@types/node": "^20" } } diff --git a/yarn.lock b/yarn.lock index a51ed7f969..be4cf6488f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -826,18 +826,13 @@ resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== -"@types/node@*": +"@types/node@*", "@types/node@^20": version "20.11.20" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.20.tgz#f0a2aee575215149a62784210ad88b3a34843659" integrity sha512-7/rR21OS+fq8IyHTgtLkDK949uzsa6n8BkziAKtPVpugIkO6D+/ooXMvzXxDnZrmtXVfjb1bKQafYpb8s89LOg== dependencies: undici-types "~5.26.4" -"@types/node@^14.6.4": - version "14.18.63" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.63.tgz#1788fa8da838dbb5f9ea994b834278205db6ca2b" - integrity sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ== - "@types/offscreencanvas@~2019.3.0": version "2019.3.0" resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553" From 0f800a801134cd8bf812493ad43bdfeb4ff62af4 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 24 Feb 2024 17:05:49 +0530 Subject: [PATCH 9/9] Update NODE_VERSION 20.10.0 -> 20.11.1 --- docs/deploy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deploy.md b/docs/deploy.md index aff3dbd59d..2919b1785a 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -52,7 +52,7 @@ Apart from this, there are also some subdomains: In Cloudflare Pages setting the following environment variables are defined: - `NODE_VERSION`: Determines which version of Node is used when we do `yarn - build:foo`. Currently this is set to `20.10.0`. The major version here should + build:foo`. Currently this is set to `20.11.1`. The major version here should match that of `@types/node` in our dev dependencies. - `SENTRY_AUTH_TOKEN`: An encrypted environment variable that is used by the