From fd7b69364a5e12fa1032e2900f099d1414dcb53b Mon Sep 17 00:00:00 2001 From: Philip <4144601+philipbrembeck@users.noreply.github.com> Date: Sun, 27 Oct 2024 19:49:07 +0100 Subject: [PATCH] chore(ESLint): Migrate to flatConfig --- .eslintrc.json | 45 ---------------- .vscode/settings.json | 4 +- eslint.config.mjs | 60 +++++++++++++++++++++ package.json | 1 + pnpm-lock.yaml | 61 ++++++++++++++++++++++ src/components/Scanner/ViewportScanner.tsx | 2 - src/components/elements/modalwrapper.tsx | 2 + src/components/elements/share.tsx | 1 + 8 files changed, 128 insertions(+), 48 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.mjs diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index f978d3f7..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "root": true, - "extends": [ - "next/core-web-vitals", - "plugin:@typescript-eslint/strict", - "plugin:@typescript-eslint/stylistic", - "plugin:import/recommended", - "plugin:import/typescript" - ], - "plugins": ["@typescript-eslint", "import"], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "./tsconfig.json", - "ecmaVersion": 2022, - "sourceType": "module" - }, - "settings": { - "import/resolver": { - "typescript": { - "project": "./tsconfig.json" - }, - "node": true - } - }, - "rules": { - "import/order": [ - "error", - { - "groups": [ - "builtin", - "external", - "internal", - "parent", - "sibling", - "index" - ], - "newlines-between": "always", - "alphabetize": { - "order": "asc", - "caseInsensitive": true - } - } - ] - } -} diff --git a/.vscode/settings.json b/.vscode/settings.json index 450326ba..f1ff0d68 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,8 +15,10 @@ } ], "eslint.options": { - "overrideConfigFile": ".eslintrc.json" + "overrideConfigFile": "eslint.config.mjs" }, + "eslint.useFlatConfig": true, + "eslint.enable": true, "typescript.tsdk": "node_modules/typescript", "typescript.enablePromptUseWorkspaceTsdk": true } diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..c18eb969 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,60 @@ +import nextPlugin from "@next/eslint-plugin-next"; +import tsPlugin from "@typescript-eslint/eslint-plugin"; +import tsParser from "@typescript-eslint/parser"; +import importPlugin from "eslint-plugin-import"; +import reactCompiler from 'eslint-plugin-react-compiler' + +export default [ + { + languageOptions: { + ecmaVersion: 2022, + sourceType: "module", + parser: tsParser, + parserOptions: { + project: "./tsconfig.json" + } + }, + plugins: { + "@typescript-eslint": tsPlugin, + "import": importPlugin, + "@next/next": nextPlugin, + 'react-compiler': reactCompiler, + }, + files: ["**/*.{js,jsx,ts,tsx}"], + settings: { + "import/resolver": { + "typescript": { + "project": "./tsconfig.json" + }, + "node": true + } + }, + rules: { + ...nextPlugin.configs["core-web-vitals"].rules, + ...nextPlugin.configs["recommended"].rules, + ...tsPlugin.configs["strict"].rules, + ...tsPlugin.configs["stylistic"].rules, + ...importPlugin.configs["recommended"].rules, + ...importPlugin.configs["typescript"].rules, + 'react-compiler/react-compiler': 'warn', + "import/order": [ + "error", + { + "groups": [ + "builtin", + "external", + "internal", + "parent", + "sibling", + "index" + ], + "newlines-between": "always", + "alphabetize": { + "order": "asc", + "caseInsensitive": true + } + } + ] + } + } +]; \ No newline at end of file diff --git a/package.json b/package.json index c8eeeea1..e36284b1 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "eslint-config-sznm": "^2.0.3", "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-import": "^2.31.0", + "eslint-plugin-react-compiler": "19.0.0-beta-8a03594-20241020", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "ts-node": "^10.9.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b017dde5..39acd33e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -114,6 +114,9 @@ importers: eslint-plugin-import: specifier: ^2.31.0 version: 2.31.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0)(typescript@5.6.3))(eslint-import-resolver-typescript@3.6.3)(eslint@9.13.0) + eslint-plugin-react-compiler: + specifier: 19.0.0-beta-8a03594-20241020 + version: 19.0.0-beta-8a03594-20241020(eslint@9.13.0) jest: specifier: ^29.7.0 version: 29.7.0(@types/node@22.8.1)(ts-node@10.9.2(@types/node@22.8.1)(typescript@5.6.3)) @@ -303,6 +306,13 @@ packages: peerDependencies: '@babel/core': ^7.0.0 + '@babel/plugin-proposal-private-methods@7.18.6': + resolution: {integrity: sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==} + engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead. + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2': resolution: {integrity: sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==} engines: {node: '>=6.9.0'} @@ -2236,6 +2246,12 @@ packages: eslint-config-prettier: optional: true + eslint-plugin-react-compiler@19.0.0-beta-8a03594-20241020: + resolution: {integrity: sha512-bYg1COih1s3r14IV/AKdQs/SN7CQmNI0ZaMtPdgZ6gp1S1Q/KGP9P43w7R6dHJ4wYpuMBvekNJHQdVu+x6UM+A==} + engines: {node: ^14.17.0 || ^16.0.0 || >= 18.0.0} + peerDependencies: + eslint: 9.13.0 + eslint-plugin-react-hooks@4.6.2: resolution: {integrity: sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==} engines: {node: '>=10'} @@ -2559,6 +2575,12 @@ packages: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} + hermes-estree@0.20.1: + resolution: {integrity: sha512-SQpZK4BzR48kuOg0v4pb3EAGNclzIlqMj3Opu/mu7bbAoFw6oig6cEt/RAi0zTFW/iW6Iz9X9ggGuZTAZ/yZHg==} + + hermes-parser@0.20.1: + resolution: {integrity: sha512-BL5P83cwCogI8D7rrDCgsFY0tdYUtmFP9XaXtl2IQjC+2Xo+4okjfXintlTxcIwl4qeGddEl28Z11kbVIw0aNA==} + html-encoding-sniffer@3.0.0: resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==} engines: {node: '>=12'} @@ -4214,6 +4236,15 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} + zod-validation-error@3.4.0: + resolution: {integrity: sha512-ZOPR9SVY6Pb2qqO5XHt+MkkTRxGXb4EVtnjc9JpXUOtUB1T9Ru7mZOT361AN3MsetVe7R0a1KZshJDZdgp9miQ==} + engines: {node: '>=18.0.0'} + peerDependencies: + zod: ^3.18.0 + + zod@3.23.8: + resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} + snapshots: '@aashutoshrathi/word-wrap@1.2.6': {} @@ -4430,6 +4461,12 @@ snapshots: '@babel/helper-environment-visitor': 7.24.6 '@babel/helper-plugin-utils': 7.24.6 + '@babel/plugin-proposal-private-methods@7.18.6(@babel/core@7.24.4)': + dependencies: + '@babel/core': 7.24.4 + '@babel/helper-create-class-features-plugin': 7.24.6(@babel/core@7.24.4) + '@babel/helper-plugin-utils': 7.25.9 + '@babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2(@babel/core@7.24.4)': dependencies: '@babel/core': 7.24.4 @@ -6692,6 +6729,18 @@ snapshots: optionalDependencies: eslint-config-prettier: 9.1.0(eslint@9.13.0) + eslint-plugin-react-compiler@19.0.0-beta-8a03594-20241020(eslint@9.13.0): + dependencies: + '@babel/core': 7.24.4 + '@babel/parser': 7.24.6 + '@babel/plugin-proposal-private-methods': 7.18.6(@babel/core@7.24.4) + eslint: 9.13.0 + hermes-parser: 0.20.1 + zod: 3.23.8 + zod-validation-error: 3.4.0(zod@3.23.8) + transitivePeerDependencies: + - supports-color + eslint-plugin-react-hooks@4.6.2(eslint@9.13.0): dependencies: eslint: 9.13.0 @@ -7061,6 +7110,12 @@ snapshots: dependencies: function-bind: 1.1.2 + hermes-estree@0.20.1: {} + + hermes-parser@0.20.1: + dependencies: + hermes-estree: 0.20.1 + html-encoding-sniffer@3.0.0: dependencies: whatwg-encoding: 2.0.0 @@ -9099,3 +9154,9 @@ snapshots: yn@3.1.1: {} yocto-queue@0.1.0: {} + + zod-validation-error@3.4.0(zod@3.23.8): + dependencies: + zod: 3.23.8 + + zod@3.23.8: {} diff --git a/src/components/Scanner/ViewportScanner.tsx b/src/components/Scanner/ViewportScanner.tsx index efddf3c2..dd3e0661 100644 --- a/src/components/Scanner/ViewportScanner.tsx +++ b/src/components/Scanner/ViewportScanner.tsx @@ -74,8 +74,6 @@ export function ViewportScanner({ onDetected, setScanning }: ScannerProps) { Quagga.offDetected(onDetected); Quagga.stop(); }; - // Disabled here, as we only want to run this once - // eslint-disable-next-line react-hooks/exhaustive-deps }, []); if (isHidden) return null; diff --git a/src/components/elements/modalwrapper.tsx b/src/components/elements/modalwrapper.tsx index aadbe4a3..af408458 100644 --- a/src/components/elements/modalwrapper.tsx +++ b/src/components/elements/modalwrapper.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react-compiler/react-compiler */ "use client"; import React, { @@ -82,6 +83,7 @@ const ModalWrapper = ({ return ( <> + z { + // eslint-disable-next-line react-compiler/react-compiler window.location.href = shareUrl; document.querySelector(".btn-dark")?.click(); };