From 584f91d05a010b62f1d006b3c179f60839a3679a Mon Sep 17 00:00:00 2001 From: Francis Li Date: Sun, 5 Jan 2025 14:35:28 -0800 Subject: [PATCH 1/5] Switch to neostandard for lint --- client/.eslintrc.cjs | 10 -- client/eslint.config.js | 44 ++------- client/package.json | 7 +- client/src/Admin/AdminRoutes.jsx | 6 +- client/src/Admin/Users/AdminUserInvite.jsx | 62 ++++++------ client/src/Admin/Users/AdminUsersList.jsx | 52 +++++----- client/src/Admin/Users/AdminUsersRoutes.jsx | 8 +- client/src/Api.js | 46 ++++----- client/src/App.jsx | 18 ++-- client/src/AppRedirects.jsx | 4 +- client/src/AppRedirectsConfig.js | 10 +- client/src/AuthContext.js | 4 +- client/src/AuthContextProvider.jsx | 2 +- client/src/Components/DropzoneUploader.jsx | 14 +-- client/src/Components/Pagination.jsx | 52 +++++----- client/src/Components/PhotoInput.jsx | 24 ++--- client/src/Header.jsx | 48 ++++----- client/src/Home.jsx | 4 +- client/src/Invites/Invite.jsx | 20 ++-- client/src/Invites/InvitesRoutes.jsx | 4 +- client/src/Login.jsx | 57 +++++------ client/src/Passwords/ForgotPassword.jsx | 36 +++---- client/src/Passwords/PasswordsRoutes.jsx | 8 +- client/src/Passwords/ResetPassword.jsx | 42 ++++---- client/src/Register.jsx | 22 ++--- client/src/RegistrationForm.jsx | 48 ++++----- client/src/StaticContext.js | 2 +- client/src/StaticContextProvider.jsx | 2 +- client/src/UnexpectedError.js | 2 +- client/src/Users/UserForm.jsx | 103 ++++++++++---------- client/src/Users/UsersRoutes.jsx | 4 +- client/src/ValidationError.jsx | 8 +- client/src/entry-server.jsx | 4 +- package-lock.json | 77 +-------------- 34 files changed, 370 insertions(+), 484 deletions(-) delete mode 100644 client/.eslintrc.cjs diff --git a/client/.eslintrc.cjs b/client/.eslintrc.cjs deleted file mode 100644 index 6910e43..0000000 --- a/client/.eslintrc.cjs +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - env: { browser: true, es2020: true }, - extends: ['eslint:recommended', 'plugin:react/recommended', 'plugin:react/jsx-runtime', 'plugin:react-hooks/recommended'], - parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, - settings: { react: { version: '18.2' } }, - plugins: ['react-refresh'], - rules: { - 'react-refresh/only-export-components': 'warn', - }, -}; diff --git a/client/eslint.config.js b/client/eslint.config.js index 238d2e4..aa78f70 100644 --- a/client/eslint.config.js +++ b/client/eslint.config.js @@ -1,38 +1,8 @@ -import js from '@eslint/js' -import globals from 'globals' -import react from 'eslint-plugin-react' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' +import neostandard from 'neostandard'; -export default [ - { ignores: ['dist'] }, - { - files: ['**/*.{js,jsx}'], - languageOptions: { - ecmaVersion: 2020, - globals: globals.browser, - parserOptions: { - ecmaVersion: 'latest', - ecmaFeatures: { jsx: true }, - sourceType: 'module', - }, - }, - settings: { react: { version: '18.3' } }, - plugins: { - react, - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, - }, - rules: { - ...js.configs.recommended.rules, - ...react.configs.recommended.rules, - ...react.configs['jsx-runtime'].rules, - ...reactHooks.configs.recommended.rules, - 'react/jsx-no-target-blank': 'off', - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, - }, -] +export default neostandard({ + ignores: [ + 'dist/*', + ], + semi: true +}); diff --git a/client/package.json b/client/package.json index ae6a637..6b39e04 100644 --- a/client/package.json +++ b/client/package.json @@ -8,7 +8,7 @@ "build": "npm run build:client && npm run build:server", "build:client": "vite build --outDir dist/client", "build:server": "vite build --ssr src/entry-server.jsx --outDir dist/server", - "lint": "eslint .", + "lint": "eslint --fix", "preview": "vite preview", "test": "" }, @@ -27,15 +27,12 @@ "react-router": "^7.1.1" }, "devDependencies": { - "@eslint/js": "^9.17.0", "@types/react": "^18.3.18", "@types/react-dom": "^18.3.5", "@vitejs/plugin-react-swc": "^3.7.2", "eslint": "^9.17.0", - "eslint-plugin-react": "^7.37.2", - "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.16", "globals": "^15.14.0", + "neostandard": "^0.12.0", "sass": "^1.83.0", "vite": "^6.0.7" }, diff --git a/client/src/Admin/AdminRoutes.jsx b/client/src/Admin/AdminRoutes.jsx index d899a60..b90acfc 100644 --- a/client/src/Admin/AdminRoutes.jsx +++ b/client/src/Admin/AdminRoutes.jsx @@ -2,11 +2,11 @@ import { Navigate, Routes, Route } from 'react-router'; import AdminUsersRoutes from './Users/AdminUsersRoutes'; -function AdminRoutes() { +function AdminRoutes () { return ( - } /> - } /> + } /> + } /> ); } diff --git a/client/src/Admin/Users/AdminUserInvite.jsx b/client/src/Admin/Users/AdminUserInvite.jsx index 232dfa8..d472848 100644 --- a/client/src/Admin/Users/AdminUserInvite.jsx +++ b/client/src/Admin/Users/AdminUserInvite.jsx @@ -9,7 +9,7 @@ import UnexpectedError from '../../UnexpectedError'; import ValidationError from '../../ValidationError'; import { useStaticContext } from '../../StaticContext'; -function AdminUserInvite() { +function AdminUserInvite () { const staticContext = useStaticContext(); const navigate = useNavigate(); const [invite, setInvite] = useState({ @@ -21,13 +21,13 @@ function AdminUserInvite() { const [isLoading, setLoading] = useState(false); const [error, setError] = useState(null); - function onChange(event) { + function onChange (event) { const newInvite = { ...invite }; newInvite[event.target.name] = event.target.value; setInvite(newInvite); } - async function onSubmit(event) { + async function onSubmit (event) { event.preventDefault(); setLoading(true); setError(null); @@ -50,72 +50,72 @@ function AdminUserInvite() { Invite a new User - {staticContext?.env?.VITE_SITE_TITLE ?? ''} -
-
-
-
-
-

Invite a new User

+
+
+
+
+
+

Invite a new User

- {error && error.message &&
{error.message}
} + {error && error.message &&
{error.message}
}
-
-