Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[web] Add ESLint to enforce HMR how vite likes it

Manav Rathi64231c73f146
diff --git a/web/docs/dependencies.md b/web/docs/dependencies.md
index 813f0e3c9c..285adc8da5 100644
--- a/web/docs/dependencies.md
+++ b/web/docs/dependencies.md
@@ -17,6 +17,8 @@ package:
- "eslint-plugin-react-hooks", "eslint-plugin-react-namespace-import" - Some
React specific ESLint rules and configurations that are used by the
workspaces that have React code.
+- "eslint-plugin-react-refresh" - A plugin to ensure that React components are
+ exported in a way that they can be HMR-ed.
- "prettier-plugin-organize-imports" - A Prettier plugin to sort imports.
- "prettier-plugin-packagejson" - A Prettier plugin to also prettify
`package.json`.
diff --git a/web/packages/build-config/eslintrc-react.js b/web/packages/build-config/eslintrc-react.js
index 13df31cfd1..7a0f04fe5d 100644
--- a/web/packages/build-config/eslintrc-react.js
+++ b/web/packages/build-config/eslintrc-react.js
@@ -5,5 +5,12 @@ module.exports = {
"plugin:react/recommended",
"plugin:react-hooks/recommended",
],
+ plugins: ["react-refresh"],
settings: { react: { version: "18.2" } },
+ rules: {
+ "react-refresh/only-export-components": [
+ "warn",
+ { allowConstantExport: true },
+ ],
+ },
};
diff --git a/web/packages/build-config/package.json b/web/packages/build-config/package.json
index 52a29fb6a7..e46bb96b1c 100644
--- a/web/packages/build-config/package.json
+++ b/web/packages/build-config/package.json
@@ -7,6 +7,7 @@
"@typescript-eslint/parser": "^7",
"eslint-plugin-react": "^7.34",
"eslint-plugin-react-hooks": "^4.6",
+ "eslint-plugin-react-refresh": "^0.4.6",
"prettier-plugin-organize-imports": "^3.2",
"prettier-plugin-packagejson": "^2.4"
}
diff --git a/web/yarn.lock b/web/yarn.lock
index 90300ce698..fdb81b959e 100644
--- a/web/yarn.lock
+++ b/web/yarn.lock
@@ -2290,6 +2290,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-refresh@^0.4.6:
+ version "0.4.6"
+ resolved "https://registry.yarnpkg.com/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.6.tgz#e8e8accab681861baed00c5c12da70267db0936f"
+ integrity sha512-NjGXdm7zgcKRkKMua34qVO9doI7VOxZ6ancSvBELJSSoX97jyndXcSoa8XBh69JoB31dNz3EEzlMcizZl7LaMA==
+
eslint-plugin-react@^7.33.2:
version "7.33.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.33.2.tgz#69ee09443ffc583927eafe86ffebb470ee737608"
@@ -3311,7 +3316,7 @@ [email protected]:
dependencies:
libsodium "^0.7.0"
[email protected], 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==