From 97e018da3e9ec628b0994fbcdc04f4f1c8eee76e Mon Sep 17 00:00:00 2001 From: Dave Bellawatt <17937472+dcordz@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:08:17 -0400 Subject: [PATCH] inertia - fix eslint - https://github.com/t3-oss/create-t3-turbo/issues/984\#issuecomment-2210934687 --- app/frontend/components/LoginBubbles.tsx | 2 +- .../bill/BillSummaryTextWithLink.tsx | 4 +- app/frontend/entrypoints/application.tsx | 2 +- .../hooks/elements/useOpenCloseElement.ts | 12 +- app/frontend/hooks/useAxios.ts | 8 +- app/frontend/hooks/useCancellable.ts | 2 - app/frontend/sway_constants/locales.ts | 2 - eslint.config.js | 8 +- package-lock.json | 111 +++++++++++++----- package.json | 9 +- 10 files changed, 105 insertions(+), 55 deletions(-) diff --git a/app/frontend/components/LoginBubbles.tsx b/app/frontend/components/LoginBubbles.tsx index b4f3fc34..799a98fd 100644 --- a/app/frontend/components/LoginBubbles.tsx +++ b/app/frontend/components/LoginBubbles.tsx @@ -35,7 +35,7 @@ const LoginBubbles: React.FC = ({ title, isBubbles, children }) => { return img; }), ); - } catch (error) {} + } catch (_error) {} }, []); return ( diff --git a/app/frontend/components/bill/BillSummaryTextWithLink.tsx b/app/frontend/components/bill/BillSummaryTextWithLink.tsx index 40bbf943..391db6ce 100644 --- a/app/frontend/components/bill/BillSummaryTextWithLink.tsx +++ b/app/frontend/components/bill/BillSummaryTextWithLink.tsx @@ -12,9 +12,7 @@ const extractAnchorTextFromString = (string: string): [string, string, string][] => { const matches = [] as [string, string, string][]; string.replace(/[^<]*(([^<]+)<\/a>)/g, function (...args: string[]) { - // eslint-disable-line - // eslint-disable-next-line - // @ts-ignore + // @ts-expect-error - Argument of type 'any[]' is not assignable to parameter of type '[string, string, string]'. matches.push(Array.prototype.slice.call(args, 1, 4)); return ""; }); diff --git a/app/frontend/entrypoints/application.tsx b/app/frontend/entrypoints/application.tsx index 25eb0afc..759eacf5 100644 --- a/app/frontend/entrypoints/application.tsx +++ b/app/frontend/entrypoints/application.tsx @@ -36,7 +36,7 @@ document.addEventListener("DOMContentLoaded", () => { const LayoutComponent = NO_AUTH_LAYOUTS.includes(pageName.toLowerCase()) ? NoAuthLayout : LayoutWithPage; return Promise.resolve(pages[`../pages/${pageName}.tsx`]()).then((_page) => { - let page = _page && "default" in _page ? _page.default : _page; + const page = _page && "default" in _page ? _page.default : _page; if (page) { page.layout = page.layout || LayoutComponent; diff --git a/app/frontend/hooks/elements/useOpenCloseElement.ts b/app/frontend/hooks/elements/useOpenCloseElement.ts index 98dfcdaf..d2aa0d52 100644 --- a/app/frontend/hooks/elements/useOpenCloseElement.ts +++ b/app/frontend/hooks/elements/useOpenCloseElement.ts @@ -9,7 +9,7 @@ export interface IDimensions { } export const useOpenCloseElement = ( - ref: React.RefObject, // eslint-disable-line + ref: React.RefObject, defaultState = false, ): [boolean, React.Dispatch>] => { const [open, setOpen] = useState(defaultState); @@ -17,15 +17,9 @@ export const useOpenCloseElement = ( const handleClose = useCallback(() => setOpen(false), []); const esc = useCallback((e: KeyboardEvent) => e.code === KEYCODE_ESC, []); - const outside = useCallback( - (e: Event) => ref.current && !ref.current.contains(e.target), - [ref], - ); + const outside = useCallback((e: Event) => ref.current && !ref.current.contains(e.target), [ref]); - const handleClick = useCallback( - (e: Event) => outside(e) && handleClose(), - [outside, handleClose], - ); + const handleClick = useCallback((e: Event) => outside(e) && handleClose(), [outside, handleClose]); const handleKeyDown = useCallback( (e: KeyboardEvent) => esc(e) && outside(e) && handleClose(), [esc, outside, handleClose], diff --git a/app/frontend/hooks/useAxios.ts b/app/frontend/hooks/useAxios.ts index 9ae6d074..49f96a24 100644 --- a/app/frontend/hooks/useAxios.ts +++ b/app/frontend/hooks/useAxios.ts @@ -52,8 +52,12 @@ const handleAxiosError = (ex: AxiosError | Error) => { }; const handleRoutedResponse = (result: IRoutableResponse) => { - result.phone && localStorage.setItem("@sway/phone", removeNonDigits(result.phone)); - result.route && router.visit(result.route); + if (result.phone) { + localStorage.setItem("@sway/phone", removeNonDigits(result.phone)); + } + if (result.route) { + router.visit(result.route); + } }; /* diff --git a/app/frontend/hooks/useCancellable.ts b/app/frontend/hooks/useCancellable.ts index 41d00ba8..d86ae2eb 100644 --- a/app/frontend/hooks/useCancellable.ts +++ b/app/frontend/hooks/useCancellable.ts @@ -21,9 +21,7 @@ export const useCancellable = () => { return useCallback( async (promise: Promise, onCancel?: () => void) => - // eslint-disable-next-line new Promise(async (resolve, reject) => { - // NOSONAR try { const result = await promise; if (isMounted()) { diff --git a/app/frontend/sway_constants/locales.ts b/app/frontend/sway_constants/locales.ts index 492d5be0..5b7e7a61 100644 --- a/app/frontend/sway_constants/locales.ts +++ b/app/frontend/sway_constants/locales.ts @@ -1,7 +1,5 @@ - export const CONGRESS_LOCALE_NAME = "congress-congress-united_states"; -// eslint-disable-next-line export enum ELocaleName { BALTIMORE = "baltimore-maryland-united_states", BALTIMORE_COUNTY = "baltimore_county-maryland-united_states", diff --git a/eslint.config.js b/eslint.config.js index 1a2104f2..f30e00c0 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -7,6 +7,7 @@ import rulesOfHooks from "eslint-plugin-react-hooks"; import eslintImport from "eslint-plugin-import"; import typescriptParser from "@typescript-eslint/parser"; import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import { fixupPluginRules } from "@eslint/compat"; export default [ // pluginJs.configs.recommended, @@ -33,7 +34,7 @@ export default [ plugins: { "@typescript-eslint": typescriptEslint, "react-refresh": reactRefresh, - "react-hooks": rulesOfHooks, + "react-hooks": fixupPluginRules(rulesOfHooks), import: eslintImport, }, }, @@ -48,8 +49,9 @@ export default [ rules: { "react-refresh/only-export-components": ["warn", { allowConstantExport: true }], - "react-hooks/rules-of-hooks": "error", - "react-hooks/exhaustive-deps": "warn", + // "react-hooks/rules-of-hooks": "error", + // "react-hooks/exhaustive-deps": "warn", + ...rulesOfHooks.configs.recommended.rules, // "react/prop-types": "off", // "react/react-in-jsx-scope": "off", diff --git a/package-lock.json b/package-lock.json index cd3a74ee..b69c0a39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@react-google-maps/api": "^2.19.3", "@sentry/react": "^8.26.0", "@sentry/tracing": "^7.114.0", - "axios": "^1.7.4", + "axios": "^1.7.5", "bootstrap": "^5.3.3", "chart.js": "^4.4.4", "copy-to-clipboard": "^3.3.3", @@ -38,7 +38,8 @@ "yup": "^1.4.0" }, "devDependencies": { - "@eslint/js": "^9.9.0", + "@eslint/compat": "^1.1.1", + "@eslint/js": "^9.9.1", "@types/eslint__js": "^8.42.3", "@types/lodash": "^4.17.7", "@types/node": "^20.12.13", @@ -46,8 +47,8 @@ "@types/react-dom": "^18.3.0", "@vitejs/plugin-react": "^4.3.1", "dart-sass": "^1.25.0", - "eslint": "^9.9.0", - "eslint-import-resolver-typescript": "^3.6.1", + "eslint": "^9.9.1", + "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-import": "^2.29.1", "eslint-plugin-jsx-a11y": "^6.9.0", "eslint-plugin-promise": "^7.1.0", @@ -967,10 +968,20 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint/compat": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.1.1.tgz", + "integrity": "sha512-lpHyRyplhGPL5mGEh6M9O5nnKk0Gz4bFI+Zu6tKlPpDUN7XshWvH9C/px4UVm87IAANE0W81CEsNGbS1KlzXpA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@eslint/config-array": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.17.1.tgz", - "integrity": "sha512-BlYOpej8AQ8Ev9xVqroV7a02JK3SkBAaN9GfMMH9W6Ch8FlQlkjGw4Ir7+FgYwfirivAf4t+GtzuAxqfukmISA==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", + "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -1020,9 +1031,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.9.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.9.0.tgz", - "integrity": "sha512-hhetes6ZHP3BlXLxmd8K2SNgkhNSi+UcecbnwWKwpP7kyi/uC75DJ1lOOBO3xrC4jyojtGE3YxKZPHfk4yrgug==", + "version": "9.9.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.9.1.tgz", + "integrity": "sha512-xIDQRsfg5hNBqHz04H1R3scSVwmI+KUbqjsQKHKQ1DAUSaUjYPReZZmS/5PNiKu1fUvzDd6H7DEDKACSEhu+TQ==", "dev": true, "license": "MIT", "engines": { @@ -1258,6 +1269,16 @@ "node": ">= 8" } }, + "node_modules/@nolyfill/is-core-module": { + "version": "1.0.39", + "resolved": "https://registry.npmjs.org/@nolyfill/is-core-module/-/is-core-module-1.0.39.tgz", + "integrity": "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.4.0" + } + }, "node_modules/@popperjs/core": { "version": "2.11.8", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", @@ -2588,9 +2609,9 @@ } }, "node_modules/axios": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", - "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz", + "integrity": "sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", @@ -3846,17 +3867,17 @@ } }, "node_modules/eslint": { - "version": "9.9.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.9.0.tgz", - "integrity": "sha512-JfiKJrbx0506OEerjK2Y1QlldtBxkAlLxT5OEcRF8uaQ86noDe2k31Vw9rnSWv+MXZHj7OOUV/dA0AhdLFcyvA==", + "version": "9.9.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.9.1.tgz", + "integrity": "sha512-dHvhrbfr4xFQ9/dq+jcVneZMyRYLjggWjk6RVsIiHsP8Rz6yZ8LvZ//iU4TrZF+SXWG+JkNF2OyiZRvzgRDqMg==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.11.0", - "@eslint/config-array": "^0.17.1", + "@eslint/config-array": "^0.18.0", "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.9.0", + "@eslint/js": "9.9.1", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.3.0", "@nodelib/fs.walk": "^1.2.8", @@ -3926,17 +3947,19 @@ } }, "node_modules/eslint-import-resolver-typescript": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.1.tgz", - "integrity": "sha512-xgdptdoi5W3niYeuQxKmzVDTATvLYqhpwmykwsh7f6HIOStGWEIL9iqZgQDF9u9OEzrRwR8no5q2VT+bjAujTg==", + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.3.tgz", + "integrity": "sha512-ud9aw4szY9cCT1EWWdGv1L1XR6hh2PaRWif0j2QjQ0pgTY/69iw+W0Z4qZv5wHahOl8isEr+k/JnyAqNQkLkIA==", "dev": true, + "license": "ISC", "dependencies": { - "debug": "^4.3.4", - "enhanced-resolve": "^5.12.0", - "eslint-module-utils": "^2.7.4", - "fast-glob": "^3.3.1", - "get-tsconfig": "^4.5.0", - "is-core-module": "^2.11.0", + "@nolyfill/is-core-module": "1.0.39", + "debug": "^4.3.5", + "enhanced-resolve": "^5.15.0", + "eslint-module-utils": "^2.8.1", + "fast-glob": "^3.3.2", + "get-tsconfig": "^4.7.5", + "is-bun-module": "^1.0.2", "is-glob": "^4.0.3" }, "engines": { @@ -3947,7 +3970,16 @@ }, "peerDependencies": { "eslint": "*", - "eslint-plugin-import": "*" + "eslint-plugin-import": "*", + "eslint-plugin-import-x": "*" + }, + "peerDependenciesMeta": { + "eslint-plugin-import": { + "optional": true + }, + "eslint-plugin-import-x": { + "optional": true + } } }, "node_modules/eslint-module-utils": { @@ -5273,6 +5305,29 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-bun-module": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.1.0.tgz", + "integrity": "sha512-4mTAVPlrXpaN3jtF0lsnPCMGnq4+qZjVIKq0HCpfcqf8OC1SM5oATCIAPM5V5FN05qp2NNnFndphmdZS9CV3hA==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.6.3" + } + }, + "node_modules/is-bun-module/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", diff --git a/package.json b/package.json index a7dc88b8..94f83e67 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "@react-google-maps/api": "^2.19.3", "@sentry/react": "^8.26.0", "@sentry/tracing": "^7.114.0", - "axios": "^1.7.4", + "axios": "^1.7.5", "bootstrap": "^5.3.3", "chart.js": "^4.4.4", "copy-to-clipboard": "^3.3.3", @@ -38,7 +38,8 @@ "yup": "^1.4.0" }, "devDependencies": { - "@eslint/js": "^9.9.0", + "@eslint/compat": "^1.1.1", + "@eslint/js": "^9.9.1", "@types/eslint__js": "^8.42.3", "@types/lodash": "^4.17.7", "@types/node": "^20.12.13", @@ -46,8 +47,8 @@ "@types/react-dom": "^18.3.0", "@vitejs/plugin-react": "^4.3.1", "dart-sass": "^1.25.0", - "eslint": "^9.9.0", - "eslint-import-resolver-typescript": "^3.6.1", + "eslint": "^9.9.1", + "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-import": "^2.29.1", "eslint-plugin-jsx-a11y": "^6.9.0", "eslint-plugin-promise": "^7.1.0",