diff --git a/.eslintrc.js b/.eslintrc.js index d5873c77..a319906b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,7 +7,7 @@ module.exports = { 'standard', 'eslint:recommended', 'plugin:@eslint-community/eslint-comments/recommended', - // 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended', // 'plugin:import/recommended', // 'plugin:import/typescript', // 'plugin:promise/recommended', @@ -20,7 +20,7 @@ module.exports = { sourceType: 'module', }, plugins: [ - // '@typescript-eslint', + '@typescript-eslint', // 'import', // 'promise', // 'security', @@ -139,24 +139,24 @@ module.exports = { { files: ['*.ts', '*.tsx'], parser: '@typescript-eslint/parser', - // parserOptions: { - // tsconfigRootDir: __dirname, - // project: ['./tsconfig.json', '**/tsconfig.json'], - // ecmaVersion: 'latest', - // parser: '@typescript-eslint/parser', - // sourceType: 'module', - // }, - // plugins: ['@typescript-eslint'], - // extends: [ - // 'plugin:@typescript-eslint/recommended', - // 'plugin:@typescript-eslint/recommended-requiring-type-checking', - // 'plugin:@typescript-eslint/strict', - // ], - // rules: { - // // allow explicitly defined dangling promises - // '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }], - // 'no-void': ['error', { allowAsStatement: true }], - // }, + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.json', '**/tsconfig.json'], + ecmaVersion: 'latest', + parser: '@typescript-eslint/parser', + sourceType: 'module', + }, + plugins: ['@typescript-eslint'], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'plugin:@typescript-eslint/strict', + ], + rules: { + // allow explicitly defined dangling promises + '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }], + 'no-void': ['error', { allowAsStatement: true }], + }, }, { files: ['!*.json'], diff --git a/package-lock.json b/package-lock.json index f2a27e78..3b086789 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,8 +35,8 @@ "@types/react": "^18.2.0", "@types/react-dom": "^18.0.5", "@types/react-leaflet": "^2.8.2", - "@typescript-eslint/eslint-plugin": "^5.38.1", - "@typescript-eslint/parser": "^5.38.1", + "@typescript-eslint/eslint-plugin": "^5.62.0", + "@typescript-eslint/parser": "^5.62.0", "autoprefixer": "^10.4.14", "daisyui": "^4.6.1", "eslint": "^8.24.0", @@ -111,7 +111,6 @@ "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "eslint-visitor-keys": "^3.4.3" }, @@ -131,7 +130,6 @@ "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } @@ -407,10 +405,11 @@ } }, "node_modules/@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", - "dev": true + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" }, "node_modules/@types/json5": { "version": "0.0.29", @@ -480,23 +479,33 @@ "@types/react": "*" } }, + "node_modules/@types/semver": { + "version": "7.5.8", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", + "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/unist": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.38.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.38.1.tgz", - "integrity": "sha512-ky7EFzPhqz3XlhS7vPOoMDaQnQMn+9o5ICR9CPr/6bw8HrFkzhMSxuA3gRfiJVvs7geYrSeawGJjZoZQKCOglQ==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", + "integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "5.38.1", - "@typescript-eslint/type-utils": "5.38.1", - "@typescript-eslint/utils": "5.38.1", + "@eslint-community/regexpp": "^4.4.0", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/type-utils": "5.62.0", + "@typescript-eslint/utils": "5.62.0", "debug": "^4.3.4", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "regexpp": "^3.2.0", + "natural-compare-lite": "^1.4.0", "semver": "^7.3.7", "tsutils": "^3.21.0" }, @@ -533,14 +542,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.38.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.38.1.tgz", - "integrity": "sha512-LDqxZBVFFQnQRz9rUZJhLmox+Ep5kdUmLatLQnCRR6523YV+XhRjfYzStQ4MheFA8kMAfUlclHSbu+RKdRwQKw==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", + "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "5.38.1", - "@typescript-eslint/types": "5.38.1", - "@typescript-eslint/typescript-estree": "5.38.1", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/typescript-estree": "5.62.0", "debug": "^4.3.4" }, "engines": { @@ -560,13 +570,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.38.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.38.1.tgz", - "integrity": "sha512-BfRDq5RidVU3RbqApKmS7RFMtkyWMM50qWnDAkKgQiezRtLKsoyRKIvz1Ok5ilRWeD9IuHvaidaLxvGx/2eqTQ==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", + "integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/types": "5.38.1", - "@typescript-eslint/visitor-keys": "5.38.1" + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -577,13 +588,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.38.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.38.1.tgz", - "integrity": "sha512-UU3j43TM66gYtzo15ivK2ZFoDFKKP0k03MItzLdq0zV92CeGCXRfXlfQX5ILdd4/DSpHkSjIgLLLh1NtkOJOAw==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz", + "integrity": "sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "5.38.1", - "@typescript-eslint/utils": "5.38.1", + "@typescript-eslint/typescript-estree": "5.62.0", + "@typescript-eslint/utils": "5.62.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -604,10 +616,11 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.38.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.38.1.tgz", - "integrity": "sha512-QTW1iHq1Tffp9lNfbfPm4WJabbvpyaehQ0SrvVK2yfV79SytD9XDVxqiPvdrv2LK7DGSFo91TB2FgWanbJAZXg==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", + "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", "dev": true, + "license": "MIT", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -617,13 +630,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.38.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.38.1.tgz", - "integrity": "sha512-99b5e/Enoe8fKMLdSuwrfH/C0EIbpUWmeEKHmQlGZb8msY33qn1KlkFww0z26o5Omx7EVjzVDCWEfrfCDHfE7g==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", + "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "5.38.1", - "@typescript-eslint/visitor-keys": "5.38.1", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -644,13 +658,11 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, + "license": "ISC", "bin": { "semver": "bin/semver.js" }, @@ -659,17 +671,20 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.38.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.38.1.tgz", - "integrity": "sha512-oIuUiVxPBsndrN81oP8tXnFa/+EcZ03qLqPDfSZ5xIJVm7A9V0rlkQwwBOAGtrdN70ZKDlKv+l1BeT4eSFxwXA==", + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz", + "integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==", "dev": true, + "license": "MIT", "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.38.1", - "@typescript-eslint/types": "5.38.1", - "@typescript-eslint/typescript-estree": "5.38.1", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/typescript-estree": "5.62.0", "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0" + "semver": "^7.3.7" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -682,13 +697,27 @@ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.38.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.38.1.tgz", - "integrity": "sha512-bSHr1rRxXt54+j2n4k54p4fj8AHJ49VDWtjpImOpzQj4qjAiOpPni+V1Tyajh19Api1i844F757cur8wH3YvOA==", + "node_modules/@typescript-eslint/utils/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/@typescript-eslint/visitor-keys": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", + "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", + "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/types": "5.38.1", + "@typescript-eslint/types": "5.62.0", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -2443,6 +2472,7 @@ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" @@ -2456,6 +2486,7 @@ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } @@ -3155,6 +3186,13 @@ "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true, + "license": "MIT" + }, "node_modules/has-bigints": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", @@ -4677,6 +4715,13 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true, + "license": "MIT" + }, "node_modules/node-releases": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz", diff --git a/package.json b/package.json index 337b2066..fc493e10 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "@types/react": "^18.2.0", "@types/react-dom": "^18.0.5", "@types/react-leaflet": "^2.8.2", - "@typescript-eslint/eslint-plugin": "^5.38.1", - "@typescript-eslint/parser": "^5.38.1", + "@typescript-eslint/eslint-plugin": "^5.62.0", + "@typescript-eslint/parser": "^5.62.0", "autoprefixer": "^10.4.14", "daisyui": "^4.6.1", "eslint": "^8.24.0", diff --git a/src/Components/AppShell/Content.tsx b/src/Components/AppShell/Content.tsx index 92fce768..de30e296 100644 --- a/src/Components/AppShell/Content.tsx +++ b/src/Components/AppShell/Content.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/consistent-type-definitions */ import * as React from 'react' type ContentProps = { diff --git a/src/Components/AppShell/ContextWrapper.tsx b/src/Components/AppShell/ContextWrapper.tsx index b93d6593..69bd6a1a 100644 --- a/src/Components/AppShell/ContextWrapper.tsx +++ b/src/Components/AppShell/ContextWrapper.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-return */ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { ToastContainer } from 'react-toastify' import { QuestsProvider } from '../Gaming/hooks/useQuests' diff --git a/src/Components/AppShell/NavBar.tsx b/src/Components/AppShell/NavBar.tsx index 7524939b..56355b39 100644 --- a/src/Components/AppShell/NavBar.tsx +++ b/src/Components/AppShell/NavBar.tsx @@ -1,3 +1,14 @@ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ import { useAuth } from '../Auth' import { Link, useLocation } from 'react-router-dom' import { toast } from 'react-toastify' diff --git a/src/Components/AppShell/SideBar.tsx b/src/Components/AppShell/SideBar.tsx index d2f475fd..13aa05c2 100644 --- a/src/Components/AppShell/SideBar.tsx +++ b/src/Components/AppShell/SideBar.tsx @@ -1,3 +1,10 @@ +/* eslint-disable @typescript-eslint/consistent-type-definitions */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import { useRef, useState, useEffect } from 'react' import { NavLink, useLocation } from 'react-router-dom' import { Sidenav, initTE } from 'tw-elements' @@ -7,7 +14,6 @@ import * as React from 'react' type route = { path: string - // eslint-disable-next-line no-undef icon: JSX.Element name: string submenu?: route diff --git a/src/Components/AppShell/SidebarSubmenu.tsx b/src/Components/AppShell/SidebarSubmenu.tsx index b3426732..ffb57872 100644 --- a/src/Components/AppShell/SidebarSubmenu.tsx +++ b/src/Components/AppShell/SidebarSubmenu.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import ChevronDownIcon from '@heroicons/react/24/outline/ChevronDownIcon' import { useEffect, useState } from 'react' import { Link, useLocation } from 'react-router-dom' @@ -8,7 +12,6 @@ function SidebarSubmenu({ icon, }: { path: string - // eslint-disable-next-line no-undef icon: JSX.Element name: string submenu?: any | undefined diff --git a/src/Components/AppShell/Sitemap.tsx b/src/Components/AppShell/Sitemap.tsx index 61b3466d..1e8274bd 100644 --- a/src/Components/AppShell/Sitemap.tsx +++ b/src/Components/AppShell/Sitemap.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import { useEffect, useState } from 'react' import { useItems } from '../Map/hooks/useItems' diff --git a/src/Components/AppShell/hooks/useAppState.tsx b/src/Components/AppShell/hooks/useAppState.tsx index 0124fb9d..26835d77 100644 --- a/src/Components/AppShell/hooks/useAppState.tsx +++ b/src/Components/AppShell/hooks/useAppState.tsx @@ -1,8 +1,9 @@ +/* eslint-disable @typescript-eslint/no-empty-function */ import { useCallback, useState, createContext, useContext } from 'react' import * as React from 'react' import { AssetsApi } from '../../../types' -type AppState = { +interface AppState { assetsApi: AssetsApi userType: string } diff --git a/src/Components/AppShell/hooks/useAssets.tsx b/src/Components/AppShell/hooks/useAssets.tsx new file mode 100644 index 00000000..276773ab --- /dev/null +++ b/src/Components/AppShell/hooks/useAssets.tsx @@ -0,0 +1,41 @@ +/* eslint-disable @typescript-eslint/no-empty-function */ +import { useCallback, useState, createContext, useContext } from 'react' + +import * as React from 'react' +import { AssetsApi } from '../../../types' + +type UseAssetManagerResult = ReturnType + +const AssetContext = createContext({ + api: {} as AssetsApi, + setAssetsApi: () => {}, +}) + +function useAssetsManager(): { + api: AssetsApi + setAssetsApi: (api: AssetsApi) => void +} { + const [api, setApi] = useState({} as AssetsApi) + + const setAssetsApi = useCallback((api: AssetsApi) => { + setApi(api) + }, []) + + return { api, setAssetsApi } +} + +export const AssetsProvider: React.FunctionComponent<{ + children?: React.ReactNode +}> = ({ children }) => ( + {children} +) + +export const useAssetApi = (): AssetsApi => { + const { api } = useContext(AssetContext) + return api +} + +export const useSetAssetApi = (): UseAssetManagerResult['setAssetsApi'] => { + const { setAssetsApi } = useContext(AssetContext) + return setAssetsApi +} diff --git a/src/Components/Auth/LoginPage.tsx b/src/Components/Auth/LoginPage.tsx index 91ea9650..6c9f7fd5 100644 --- a/src/Components/Auth/LoginPage.tsx +++ b/src/Components/Auth/LoginPage.tsx @@ -1,3 +1,8 @@ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-floating-promises */ import { useEffect, useState } from 'react' import { Link, useNavigate } from 'react-router-dom' import { toast } from 'react-toastify' diff --git a/src/Components/Auth/RequestPasswordPage.tsx b/src/Components/Auth/RequestPasswordPage.tsx index 016f1f0c..fd1f25b6 100644 --- a/src/Components/Auth/RequestPasswordPage.tsx +++ b/src/Components/Auth/RequestPasswordPage.tsx @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { toast } from 'react-toastify' diff --git a/src/Components/Auth/SetNewPasswordPage.tsx b/src/Components/Auth/SetNewPasswordPage.tsx index afe9f632..9e35560c 100644 --- a/src/Components/Auth/SetNewPasswordPage.tsx +++ b/src/Components/Auth/SetNewPasswordPage.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import { useState } from 'react' import { useNavigate } from 'react-router-dom' diff --git a/src/Components/Auth/SignupPage.tsx b/src/Components/Auth/SignupPage.tsx index 19ca7f3e..484a8262 100644 --- a/src/Components/Auth/SignupPage.tsx +++ b/src/Components/Auth/SignupPage.tsx @@ -1,3 +1,8 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-misused-promises */ import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' diff --git a/src/Components/Auth/useAuth.tsx b/src/Components/Auth/useAuth.tsx index f5a1cfeb..b51f8449 100644 --- a/src/Components/Auth/useAuth.tsx +++ b/src/Components/Auth/useAuth.tsx @@ -1,19 +1,26 @@ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/no-explicit-any */ import { createContext, useState, useContext, useEffect } from 'react' import * as React from 'react' import { UserApi, UserItem } from '../../types' -type AuthProviderProps = { +interface AuthProviderProps { userApi: UserApi children?: React.ReactNode } -type AuthCredentials = { +interface AuthCredentials { email: string password: string otp?: string | undefined } -type AuthContextProps = { +interface AuthContextProps { isAuthenticated: boolean user: UserItem | null login: (credentials: AuthCredentials) => Promise @@ -58,9 +65,9 @@ export const AuthProvider = ({ userApi, children }: AuthProviderProps) => { setToken(token) if (token) { const me = await userApi.getUser() - setUser(me as UserItem) + setUser(me) setLoading(false) - return me as UserItem + return me } else return undefined } catch (error) { setLoading(false) diff --git a/src/Components/Gaming/Modal.tsx b/src/Components/Gaming/Modal.tsx index 8ac44981..f6372551 100644 --- a/src/Components/Gaming/Modal.tsx +++ b/src/Components/Gaming/Modal.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import * as React from 'react' import { useEffect } from 'react' diff --git a/src/Components/Gaming/Quests.tsx b/src/Components/Gaming/Quests.tsx index 9555a724..35cdcab3 100644 --- a/src/Components/Gaming/Quests.tsx +++ b/src/Components/Gaming/Quests.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { useQuestsOpen, useSetQuestOpen } from './hooks/useQuests' import { useAuth } from '../Auth' import { useEffect, useState } from 'react' diff --git a/src/Components/Gaming/hooks/useQuests.tsx b/src/Components/Gaming/hooks/useQuests.tsx index 17e4323f..569d431c 100644 --- a/src/Components/Gaming/hooks/useQuests.tsx +++ b/src/Components/Gaming/hooks/useQuests.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-empty-function */ import { useCallback, useState, createContext, useContext } from 'react' import * as React from 'react' diff --git a/src/Components/Input/Autocomplete.tsx b/src/Components/Input/Autocomplete.tsx index ce25467a..39013c6b 100644 --- a/src/Components/Input/Autocomplete.tsx +++ b/src/Components/Input/Autocomplete.tsx @@ -1,3 +1,10 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import * as React from 'react' import { useEffect } from 'react' import { TagView } from '../Templates/TagView' @@ -10,12 +17,12 @@ export const Autocomplete = ({ setFocus, }: { inputProps: any - suggestions: Array + suggestions: any[] onSelected: (suggestion) => void - pushFilteredSuggestions?: Array + pushFilteredSuggestions?: any[] setFocus?: boolean }) => { - const [filteredSuggestions, setFilteredSuggestions] = React.useState>([]) + const [filteredSuggestions, setFilteredSuggestions] = React.useState([]) const [heighlightedSuggestion, setHeighlightedSuggestion] = React.useState(0) useEffect(() => { @@ -28,7 +35,6 @@ export const Autocomplete = ({ const inputRef = React.useRef() - // eslint-disable-next-line no-unused-vars const getSuggestionValue = (suggestion) => suggestion.name const getSuggestions = (value) => { diff --git a/src/Components/Input/SelectBox.tsx b/src/Components/Input/SelectBox.tsx index 4bcf3a09..aed5e04b 100644 --- a/src/Components/Input/SelectBox.tsx +++ b/src/Components/Input/SelectBox.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/consistent-type-definitions */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import { useState } from 'react' import InformationCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon' import * as React from 'react' diff --git a/src/Components/Input/TextAreaInput.tsx b/src/Components/Input/TextAreaInput.tsx index fc66f731..03593d2f 100644 --- a/src/Components/Input/TextAreaInput.tsx +++ b/src/Components/Input/TextAreaInput.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/consistent-type-definitions */ +/* eslint-disable @typescript-eslint/consistent-indexed-object-style */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ import * as React from 'react' import { useEffect, useRef, useState } from 'react' import Tribute from 'tributejs' diff --git a/src/Components/Input/TextInput.tsx b/src/Components/Input/TextInput.tsx index 2c1248d3..aa248c7c 100644 --- a/src/Components/Input/TextInput.tsx +++ b/src/Components/Input/TextInput.tsx @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/consistent-type-definitions */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ import { useEffect, useState } from 'react' import * as React from 'react' diff --git a/src/Components/Map/Layer.tsx b/src/Components/Map/Layer.tsx index bb308b65..5a290b5f 100644 --- a/src/Components/Map/Layer.tsx +++ b/src/Components/Map/Layer.tsx @@ -1,3 +1,12 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import * as React from 'react' import { Marker, Tooltip, useMap, useMapEvents } from 'react-leaflet' import { Item, LayerProps, Tag } from '../../types' @@ -171,7 +180,7 @@ export const Layer = ({ } let title = '' if (item.name) title = item.name - else if (item.layer?.itemNameField) title = getValue(item, item.layer.itemNameField) + else if (item.layer.itemNameField) title = getValue(item, item.layer.itemNameField) document.title = `${document.title.split('-')[0]} - ${title}` } }, @@ -195,7 +204,7 @@ export const Layer = ({ }) let title = '' if (ref.item.name) title = ref.item.name - else if (ref.item.layer?.itemNameField) + else if (ref.item.layer.itemNameField) title = getValue(ref.item.name, ref.item.layer.itemNameField) document.title = `${document.title.split('-')[0]} - ${title}` document @@ -233,7 +242,7 @@ export const Layer = ({ {items && items .filter((item) => item.layer?.name === name) - ?.filter((item) => + .filter((item) => filterTags.length === 0 ? item : filterTags.some((tag) => @@ -243,7 +252,7 @@ export const Layer = ({ ), ), ) - ?.filter((item) => item.layer && isLayerVisible(item.layer)) + .filter((item) => item.layer && isLayerVisible(item.layer)) .filter( (item) => (item.group_type && isGroupTypeVisible(item.group_type)) || @@ -254,7 +263,7 @@ export const Layer = ({ if (getValue(item, itemTextField)) item[itemTextField] = getValue(item, itemTextField) else item[itemTextField] = '' - if (item?.tags) { + if (item.tags) { item[itemTextField] = item[itemTextField] + '\n\n' item.tags.map((tag) => { if (!item[itemTextField].includes(`#${encodeTag(tag)}`)) { @@ -372,7 +381,7 @@ export const Layer = ({ // {children}} } {itemFormPopup && - itemFormPopup.layer!.name === name && + itemFormPopup.layer.name === name && (children && React.Children.toArray(children).some( (child) => React.isValidElement(child) && child.props.__TYPE === 'ItemForm', @@ -381,10 +390,10 @@ export const Layer = ({ React.isValidElement(child) && child.props.__TYPE === 'ItemForm' ? ( {child} @@ -395,10 +404,10 @@ export const Layer = ({ ) : ( <> ))} diff --git a/src/Components/Map/Subcomponents/AddButton.tsx b/src/Components/Map/Subcomponents/AddButton.tsx index c58ecf2c..de6235c2 100644 --- a/src/Components/Map/Subcomponents/AddButton.tsx +++ b/src/Components/Map/Subcomponents/AddButton.tsx @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import * as React from 'react' import { useLayers } from '../hooks/useLayers' import { useHasUserPermission } from '../hooks/usePermissions' diff --git a/src/Components/Map/Subcomponents/Controls/Control.tsx b/src/Components/Map/Subcomponents/Controls/Control.tsx index 3ff3afa2..91c1125a 100644 --- a/src/Components/Map/Subcomponents/Controls/Control.tsx +++ b/src/Components/Map/Subcomponents/Controls/Control.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import * as L from 'leaflet' import * as React from 'react' diff --git a/src/Components/Map/Subcomponents/Controls/LocateControl.tsx b/src/Components/Map/Subcomponents/Controls/LocateControl.tsx index e598a276..e3920979 100644 --- a/src/Components/Map/Subcomponents/Controls/LocateControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/LocateControl.tsx @@ -1,3 +1,9 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/prefer-ts-expect-error */ +/* eslint-disable @typescript-eslint/ban-ts-comment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import * as L from 'leaflet' import { useMap, useMapEvents } from 'react-leaflet' import 'leaflet.locatecontrol' diff --git a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx index 49a7e723..1ff35787 100644 --- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -1,3 +1,15 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/require-await */ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import * as React from 'react' import { useAddFilterTag } from '../../hooks/useFilter' import useWindowDimensions from '../../hooks/useWindowDimension' @@ -23,9 +35,9 @@ export const SearchControl = () => { const [popupOpen, setPopupOpen] = useState(false) const [value, setValue] = useState('') - const [geoResults, setGeoResults] = useState>([]) - const [tagsResults, setTagsResults] = useState>([]) - const [itemsResults, setItemsResults] = useState>([]) + const [geoResults, setGeoResults] = useState([]) + const [tagsResults, setTagsResults] = useState([]) + const [itemsResults, setItemsResults] = useState([]) const [hideSuggestions, setHideSuggestions] = useState(true) const map = useMap() @@ -62,14 +74,14 @@ export const SearchControl = () => { if (item.layer?.itemTextField) item.text = getValue(item, item.layer.itemTextField) return ( value.length > 2 && - ((item.layer?.listed && item.name?.toLowerCase().includes(value.toLowerCase())) || - item.text?.toLowerCase().includes(value.toLowerCase())) + ((item.layer?.listed && item.name.toLowerCase().includes(value.toLowerCase())) || + item.text.toLowerCase().includes(value.toLowerCase())) ) }), ) let phrase = value if (value.startsWith('#')) phrase = value.substring(1) - setTagsResults(tags.filter((tag) => tag.name?.toLowerCase().includes(phrase.toLowerCase()))) + setTagsResults(tags.filter((tag) => tag.name.toLowerCase().includes(phrase.toLowerCase()))) }, 500, [value], diff --git a/src/Components/Map/Subcomponents/Controls/TagsControl.tsx b/src/Components/Map/Subcomponents/Controls/TagsControl.tsx index ca3230bc..0f823769 100644 --- a/src/Components/Map/Subcomponents/Controls/TagsControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/TagsControl.tsx @@ -17,7 +17,7 @@ export const TagsControl = () => {
diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx index cdc9e498..65bf111e 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -1,3 +1,12 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import * as React from 'react' import { LatLng } from 'leaflet' import { Popup as LeafletPopup, useMap } from 'react-leaflet' @@ -24,7 +33,6 @@ export interface ItemFormPopupProps { export function ItemFormPopup(props: ItemFormPopupProps) { const [spinner, setSpinner] = useState(false) - // eslint-disable-next-line no-unused-vars const [popupTitle, setPopupTitle] = useState('') const formRef = useRef(null) @@ -34,7 +42,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) { const addItem = useAddItem() const updateItem = useUpdateItem() const items = useItems() - // eslint-disable-next-line no-unused-vars + const removeItem = useRemoveItem() const tags = useTags() @@ -93,7 +101,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) { try { props.layer.onlyOnePerOwner && item && - (await props.layer.api?.updateItem!({ ...formItem, id: item?.id })) + (await props.layer.api?.updateItem!({ ...formItem, id: item.id })) ;(!props.layer.onlyOnePerOwner || !item) && (await props.layer.api?.createItem!({ ...formItem, diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx index e6a9e03c..4257e144 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx @@ -1,3 +1,14 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/require-await */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import * as React from 'react' import { Item, ItemsApi } from '../../../../types' import { useHasUserPermission } from '../../hooks/usePermissions' @@ -56,10 +67,10 @@ export function HeaderView({ `${big ? '?width=160&heigth=160' : '?width=80&heigth=80'}` const title = itemNameField ? getValue(item, itemNameField) - : item.layer?.itemNameField && item && getValue(item, item.layer?.itemNameField) + : item.layer?.itemNameField && item && getValue(item, item.layer.itemNameField) const subtitle = itemSubnameField ? getValue(item, itemSubnameField) - : item.layer?.itemSubnameField && item && getValue(item, item.layer?.itemSubnameField) + : item.layer?.itemSubnameField && item && getValue(item, item.layer.itemSubnameField) const [address] = React.useState('') diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupButton.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupButton.tsx index 2dcf4107..965f0317 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupButton.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupButton.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import { Link } from 'react-router-dom' import { getValue } from '../../../../Utils/GetValue' import { Item } from '../../../../types' diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx index d2b84100..2c11baf3 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx @@ -1,8 +1,9 @@ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ import * as React from 'react' import { TextInput } from '../../../Input' import { Item } from '../../../../types' -type StartEndInputProps = { +interface StartEndInputProps { item?: Item showLabels?: boolean updateStartValue?: (value: string) => void diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/StartEndView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/StartEndView.tsx index 8b924442..f216d6e5 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/StartEndView.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/StartEndView.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ import * as React from 'react' import { Item } from '../../../../types' diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx index fb749735..56994c4c 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx @@ -1,3 +1,12 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import { Item } from '../../../../types' import { useTags } from '../../hooks/useTags' import { useAddFilterTag } from '../../hooks/useFilter' @@ -31,7 +40,7 @@ export const TextView = ({ } else if (itemTextField && item) { text = getValue(item, itemTextField) } else { - text = item?.layer?.itemTextField && item ? getValue(item, item.layer?.itemTextField) : '' + text = item?.layer?.itemTextField && item ? getValue(item, item.layer.itemTextField) : '' } if (item && text && truncate) text = truncateText(removeMarkdownKeepLinksAndParagraphs(text), 100) @@ -106,10 +115,10 @@ export const TextView = ({ return ( { e.stopPropagation() - addFilterTag(tag!) + addFilterTag(tag) }} > {decodeTag(children)} diff --git a/src/Components/Map/Subcomponents/ItemViewPopup.tsx b/src/Components/Map/Subcomponents/ItemViewPopup.tsx index e563989b..f4336ce4 100644 --- a/src/Components/Map/Subcomponents/ItemViewPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemViewPopup.tsx @@ -1,3 +1,12 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import * as React from 'react' import { Popup as LeafletPopup, useMap } from 'react-leaflet' import { Item } from '../../../types' diff --git a/src/Components/Map/Subcomponents/SelectPosition.tsx b/src/Components/Map/Subcomponents/SelectPosition.tsx index 26c6d73c..962be771 100644 --- a/src/Components/Map/Subcomponents/SelectPosition.tsx +++ b/src/Components/Map/Subcomponents/SelectPosition.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call */ export const SelectPosition = ({ setSelectNewItemPosition }: { setSelectNewItemPosition }) => { return (
diff --git a/src/Components/Map/Tags.tsx b/src/Components/Map/Tags.tsx index a5118eb8..89352561 100644 --- a/src/Components/Map/Tags.tsx +++ b/src/Components/Map/Tags.tsx @@ -27,16 +27,16 @@ export function Tags({ data, api }: { data?: Tag[]; api?: ItemsApi }) { const decodedTags = urlTags ? decodeURIComponent(urlTags) : '' const decodedTagsArray = decodedTags.split(';') if ( - decodedTagsArray?.some( + decodedTagsArray.some( (ut) => !filterTags.find((ft) => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase()), ) || - filterTags?.some( + filterTags.some( (ft) => - !decodedTagsArray?.find((ut) => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase()), + !decodedTagsArray.find((ut) => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase()), ) ) { resetFilterTags() - decodedTagsArray?.map((urlTag) => { + decodedTagsArray.map((urlTag) => { const tag = tags.find((t) => t.name.toLocaleLowerCase() === urlTag.toLocaleLowerCase()) tag && addFilterTag(tag) return null diff --git a/src/Components/Map/UtopiaMapInner.tsx b/src/Components/Map/UtopiaMapInner.tsx index 80e7d4d8..e80887a0 100644 --- a/src/Components/Map/UtopiaMapInner.tsx +++ b/src/Components/Map/UtopiaMapInner.tsx @@ -1,3 +1,11 @@ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ import { TileLayer, MapContainer, useMapEvents, GeoJSON } from 'react-leaflet' import 'leaflet/dist/leaflet.css' import * as React from 'react' @@ -99,7 +107,6 @@ export function UtopiaMapInner({ ) } - // eslint-disable-next-line no-undef const onEachFeature = (feature: Feature, layer: L.Layer) => { if (feature.properties) { layer.bindPopup(feature.properties.name) @@ -157,7 +164,7 @@ export function UtopiaMapInner({ eventHandlers={{ click: (e) => { if (selectNewItemPosition) { - e.layer!.closePopup() + e.layer.closePopup() setMapClicked({ position: e.latlng, setItemFormPopup }) } }, diff --git a/src/Components/Map/hooks/useClusterRef.tsx b/src/Components/Map/hooks/useClusterRef.tsx index b70d36de..2ee00904 100644 --- a/src/Components/Map/hooks/useClusterRef.tsx +++ b/src/Components/Map/hooks/useClusterRef.tsx @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-explicit-any */ import * as React from 'react' import { createContext, useContext, useState } from 'react' diff --git a/src/Components/Map/hooks/useDebounce.tsx b/src/Components/Map/hooks/useDebounce.tsx index 2794ff83..042890c6 100644 --- a/src/Components/Map/hooks/useDebounce.tsx +++ b/src/Components/Map/hooks/useDebounce.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { useEffect } from 'react' import { useTimeout } from './useTimeout' diff --git a/src/Components/Map/hooks/useFilter.tsx b/src/Components/Map/hooks/useFilter.tsx index 6d1eb765..72c717f2 100644 --- a/src/Components/Map/hooks/useFilter.tsx +++ b/src/Components/Map/hooks/useFilter.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable no-case-declarations */ import { useCallback, useReducer, createContext, useContext } from 'react' import * as React from 'react' @@ -121,7 +125,7 @@ function useFilterManager(initialTags: Tag[]): { const urlTags = params.get('tags') const decodedTags = urlTags ? decodeURIComponent(urlTags) : '' - if (!decodedTags?.includes(tag.name)) { + if (!decodedTags.includes(tag.name)) { params.set('tags', `${urlTags || ''}${urlTags ? ';' : ''}${tag.name}`) } if (windowDimensions.width < 786 && location.pathname.split('/').length > 2) @@ -141,7 +145,7 @@ function useFilterManager(initialTags: Tag[]): { const urlTags = params.get('tags') let newUrlTags = '' const tags = urlTags?.split(';') - if (tags?.length === 0 && urlTags?.length && urlTags?.length > 0) tags[0] = urlTags + if (tags?.length === 0 && urlTags?.length && urlTags.length > 0) tags[0] = urlTags tags?.map((urlTag) => { if (!(urlTag.toLocaleLowerCase() === name.toLocaleLowerCase())) { newUrlTags = newUrlTags + `${newUrlTags === '' ? urlTag : `;${urlTag}`}` diff --git a/src/Components/Map/hooks/useItems.tsx b/src/Components/Map/hooks/useItems.tsx index 0b75cf86..7f0c7190 100644 --- a/src/Components/Map/hooks/useItems.tsx +++ b/src/Components/Map/hooks/useItems.tsx @@ -1,3 +1,11 @@ +/* eslint-disable @typescript-eslint/require-await */ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-misused-promises */ import { useCallback, useReducer, createContext, useContext, useState } from 'react' import * as React from 'react' import { Item, LayerProps } from '../../../types' diff --git a/src/Components/Map/hooks/useLayers.tsx b/src/Components/Map/hooks/useLayers.tsx index d37197a7..b4a35468 100644 --- a/src/Components/Map/hooks/useLayers.tsx +++ b/src/Components/Map/hooks/useLayers.tsx @@ -1,8 +1,12 @@ +/* eslint-disable @typescript-eslint/no-empty-function */ import { useCallback, useReducer, createContext, useContext } from 'react' import * as React from 'react' import { LayerProps } from '../../../types' -type ActionType = { type: 'ADD LAYER'; layer: LayerProps } +interface ActionType { + type: 'ADD LAYER' + layer: LayerProps +} type UseItemManagerResult = ReturnType diff --git a/src/Components/Map/hooks/useLeafletRefs.tsx b/src/Components/Map/hooks/useLeafletRefs.tsx index 73c7a4a8..de9cd82a 100644 --- a/src/Components/Map/hooks/useLeafletRefs.tsx +++ b/src/Components/Map/hooks/useLeafletRefs.tsx @@ -1,9 +1,11 @@ +/* eslint-disable @typescript-eslint/ban-types */ +/* eslint-disable @typescript-eslint/no-empty-function */ import { useCallback, useReducer, createContext, useContext } from 'react' import * as React from 'react' import { Item } from '../../../types' import { Marker, Popup } from 'leaflet' -type LeafletRef = { +interface LeafletRef { item: Item marker: Marker popup: Popup diff --git a/src/Components/Map/hooks/usePermissions.tsx b/src/Components/Map/hooks/usePermissions.tsx index e9cbbe7c..d56b6159 100644 --- a/src/Components/Map/hooks/usePermissions.tsx +++ b/src/Components/Map/hooks/usePermissions.tsx @@ -1,3 +1,11 @@ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-explicit-any */ import { useCallback, useReducer, createContext, useContext } from 'react' import * as React from 'react' import { Item, ItemsApi, LayerProps, Permission, PermissionAction } from '../../../types' diff --git a/src/Components/Map/hooks/useSelectPosition.tsx b/src/Components/Map/hooks/useSelectPosition.tsx index 8d3cc355..855fea30 100644 --- a/src/Components/Map/hooks/useSelectPosition.tsx +++ b/src/Components/Map/hooks/useSelectPosition.tsx @@ -1,3 +1,12 @@ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ +/* eslint-disable @typescript-eslint/await-thenable */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as React from 'react' import { createContext, useContext, useEffect, useState } from 'react' import { Geometry, Item, LayerProps } from '../../../types' @@ -7,7 +16,7 @@ import { useHasUserPermission } from './usePermissions' import { LatLng } from 'leaflet' import { ItemFormPopupProps } from '../Subcomponents/ItemFormPopup' -type PolygonClickedProps = { +interface PolygonClickedProps { position: LatLng setItemFormPopup: React.Dispatch> } @@ -51,15 +60,14 @@ function useSelectPositionManager(): { mapClicked && mapClicked.setItemFormPopup({ layer: selectPosition as LayerProps, - position: mapClicked?.position, + position: mapClicked.position, }) setSelectPosition(null) } if ('text' in selectPosition) { const position = - mapClicked?.position.lng && - new Geometry(mapClicked?.position.lng, mapClicked?.position.lat) - position && itemUpdatePosition({ ...(selectPosition as Item), position }) + mapClicked?.position.lng && new Geometry(mapClicked.position.lng, mapClicked.position.lat) + position && itemUpdatePosition({ ...selectPosition, position }) setSelectPosition(null) } } @@ -70,11 +78,11 @@ function useSelectPositionManager(): { const itemUpdateParent = async (updatedItem: Item) => { if ( markerClicked?.layer?.api?.collectionName && - hasUserPermission(markerClicked?.layer?.api?.collectionName, 'update', markerClicked) + hasUserPermission(markerClicked.layer.api.collectionName, 'update', markerClicked) ) { let success = false try { - await updatedItem?.layer?.api?.updateItem!({ + await updatedItem.layer?.api?.updateItem!({ id: updatedItem.id, parent: updatedItem.parent, position: null, @@ -99,7 +107,7 @@ function useSelectPositionManager(): { const itemUpdatePosition = async (updatedItem: Item) => { let success = false try { - await updatedItem?.layer?.api?.updateItem!({ + await updatedItem.layer?.api?.updateItem!({ id: updatedItem.id, position: updatedItem.position, }) @@ -118,12 +126,12 @@ function useSelectPositionManager(): { const newRelations = markerClicked.relations || [] if (!newRelations.some((r) => r.related_items_id === id)) { - newRelations?.push({ items_id: markerClicked.id, related_items_id: id }) + newRelations.push({ items_id: markerClicked.id, related_items_id: id }) const updatedItem = { id: markerClicked.id, relations: newRelations } let success = false try { - await markerClicked?.layer?.api?.updateItem!(updatedItem) + await markerClicked.layer?.api?.updateItem!(updatedItem) success = true } catch (error) { toast.error(error.toString()) diff --git a/src/Components/Map/hooks/useTags.tsx b/src/Components/Map/hooks/useTags.tsx index 06002842..036fc232 100644 --- a/src/Components/Map/hooks/useTags.tsx +++ b/src/Components/Map/hooks/useTags.tsx @@ -1,3 +1,13 @@ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { useCallback, useReducer, createContext, useContext, useState } from 'react' import * as React from 'react' import { Item, ItemsApi, Tag } from '../../../types' @@ -77,14 +87,14 @@ function useTagsManager(initialTags: Tag[]): { tag, }) if (!tags.some((t) => t.name.toLocaleLowerCase() === tag.name.toLocaleLowerCase())) { - api?.createItem && api.createItem(tag) + api.createItem && api.createItem(tag) } } const getItemTags = useCallback( (item: Item) => { const text = - item?.layer?.itemTextField && item ? getValue(item, item.layer?.itemTextField) : undefined + item.layer?.itemTextField && item ? getValue(item, item.layer.itemTextField) : undefined const itemTagStrings = text?.match(hashTagRegex) const itemTags: Tag[] = [] itemTagStrings?.map((tag) => { diff --git a/src/Components/Map/hooks/useTimeout.tsx b/src/Components/Map/hooks/useTimeout.tsx index db8aa43e..2a49cb23 100644 --- a/src/Components/Map/hooks/useTimeout.tsx +++ b/src/Components/Map/hooks/useTimeout.tsx @@ -1,3 +1,8 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { useCallback, useEffect, useRef } from 'react' export const useTimeout = (callback, delay) => { diff --git a/src/Components/Map/setItemLocation.tsx b/src/Components/Map/setItemLocation.tsx index 9bbe1f22..7fb310a9 100644 --- a/src/Components/Map/setItemLocation.tsx +++ b/src/Components/Map/setItemLocation.tsx @@ -1,7 +1,8 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { useMap } from 'react-leaflet' export const setItemLocation = () => { - // eslint-disable-next-line no-unused-vars, react-hooks/rules-of-hooks + // eslint-disable-next-line react-hooks/rules-of-hooks const map = useMap() return
diff --git a/src/Components/Profile/ProfileForm.tsx b/src/Components/Profile/ProfileForm.tsx index 261414bb..a9a40e33 100644 --- a/src/Components/Profile/ProfileForm.tsx +++ b/src/Components/Profile/ProfileForm.tsx @@ -1,3 +1,10 @@ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ import { useItems, useUpdateItem, useAddItem } from '../Map/hooks/useItems' import { useEffect, useState } from 'react' import { getValue } from '../../Utils/GetValue' @@ -81,25 +88,25 @@ export function ProfileForm() { useEffect(() => { const newColor = - item.layer?.itemColorField && getValue(item, item.layer?.itemColorField) - ? getValue(item, item.layer?.itemColorField) + item.layer?.itemColorField && getValue(item, item.layer.itemColorField) + ? getValue(item, item.layer.itemColorField) : getItemTags(item) && getItemTags(item)[0]?.color ? getItemTags(item)[0].color - : item?.layer?.markerDefaultColor + : item.layer?.markerDefaultColor - const offers = (item?.offers ?? []).reduce((acc: Tag[], o) => { + const offers = (item.offers ?? []).reduce((acc: Tag[], o) => { const offer = tags.find((t) => t.id === o.tags_id) if (offer) acc.push(offer) return acc }, []) - const needs = (item?.needs ?? []).reduce((acc: Tag[], o) => { + const needs = (item.needs ?? []).reduce((acc: Tag[], o) => { const need = tags.find((t) => t.id === o.tags_id) if (need) acc.push(need) return acc }, []) - const relations = (item?.relations ?? []).reduce((acc: Item[], r) => { + const relations = (item.relations ?? []).reduce((acc: Item[], r) => { const relatedItem = items.find((i) => i.id === r.related_items_id) if (relatedItem) acc.push(relatedItem) return acc @@ -121,8 +128,8 @@ export function ProfileForm() { offers, needs, relations, - start: item?.start ?? '', - end: item?.end ?? '', + start: item.start ?? '', + end: item.end ?? '', }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [item, tags, items]) diff --git a/src/Components/Profile/ProfileView.tsx b/src/Components/Profile/ProfileView.tsx index c0e73fa5..03fd13bf 100644 --- a/src/Components/Profile/ProfileView.tsx +++ b/src/Components/Profile/ProfileView.tsx @@ -1,3 +1,12 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/await-thenable */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import { MapOverlayPage } from '../Templates' import { useItems, useRemoveItem, useUpdateItem } from '../Map/hooks/useItems' import { useLocation, useNavigate } from 'react-router-dom' @@ -22,9 +31,9 @@ import { useAppState } from '../AppShell/hooks/useAppState' export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi }) { const [item, setItem] = useState() const [updatePermission, setUpdatePermission] = useState(false) - const [relations, setRelations] = useState>([]) - const [offers, setOffers] = useState>([]) - const [needs, setNeeds] = useState>([]) + const [relations, setRelations] = useState([]) + const [offers, setOffers] = useState([]) + const [needs, setNeeds] = useState([]) const [loading, setLoading] = useState(false) const [template, setTemplate] = useState('') @@ -42,7 +51,7 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi const leafletRefs = useLeafletRefs() const appState = useAppState() - const [attestations, setAttestations] = useState>([]) + const [attestations, setAttestations] = useState([]) useEffect(() => { if (attestationApi) { diff --git a/src/Components/Profile/Subcomponents/ActionsButton.tsx b/src/Components/Profile/Subcomponents/ActionsButton.tsx index bcbc7382..a9636947 100644 --- a/src/Components/Profile/Subcomponents/ActionsButton.tsx +++ b/src/Components/Profile/Subcomponents/ActionsButton.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-explicit-any */ import { useState } from 'react' import { useHasUserPermission } from '../../Map/hooks/usePermissions' import DialogModal from '../../Templates/DialogModal' @@ -52,7 +56,7 @@ export function ActionButton({ setModalOpen(true) }} style={{ - backgroundColor: `${colorField && getValue(item, colorField) ? getValue(item, colorField) : getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : item?.layer?.markerDefaultColor}`, + backgroundColor: `${colorField && getValue(item, colorField) ? getValue(item, colorField) : getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : item.layer?.markerDefaultColor}`, color: '#fff', }} > @@ -76,7 +80,7 @@ export function ActionButton({ triggerAddButton() }} style={{ - backgroundColor: `${colorField && getValue(item, colorField) ? getValue(item, colorField) : getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : item?.layer?.markerDefaultColor}`, + backgroundColor: `${colorField && getValue(item, colorField) ? getValue(item, colorField) : getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : item.layer?.markerDefaultColor}`, color: '#fff', }} > diff --git a/src/Components/Profile/Subcomponents/AvatarWidget.tsx b/src/Components/Profile/Subcomponents/AvatarWidget.tsx index f4249059..ef3b4f03 100644 --- a/src/Components/Profile/Subcomponents/AvatarWidget.tsx +++ b/src/Components/Profile/Subcomponents/AvatarWidget.tsx @@ -1,3 +1,8 @@ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ import * as React from 'react' import { useState, useCallback, useRef } from 'react' import ReactCrop, { Crop, centerCrop, makeAspectCrop } from 'react-image-crop' diff --git a/src/Components/Profile/Subcomponents/ColorPicker.tsx b/src/Components/Profile/Subcomponents/ColorPicker.tsx index d9e25faa..7f8a5659 100644 --- a/src/Components/Profile/Subcomponents/ColorPicker.tsx +++ b/src/Components/Profile/Subcomponents/ColorPicker.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { useCallback, useEffect, useRef, useState } from 'react' import * as React from 'react' import { HexColorPicker } from 'react-colorful' diff --git a/src/Components/Profile/Subcomponents/ContactInfoForm.tsx b/src/Components/Profile/Subcomponents/ContactInfoForm.tsx index 70e7b034..24a8b9f5 100644 --- a/src/Components/Profile/Subcomponents/ContactInfoForm.tsx +++ b/src/Components/Profile/Subcomponents/ContactInfoForm.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ import * as React from 'react' import { TextInput } from '../../Input' import { FormState } from '../Templates/OnepagerForm' diff --git a/src/Components/Profile/Subcomponents/ContactInfoView.tsx b/src/Components/Profile/Subcomponents/ContactInfoView.tsx index 5b2cf6c9..38d090e8 100644 --- a/src/Components/Profile/Subcomponents/ContactInfoView.tsx +++ b/src/Components/Profile/Subcomponents/ContactInfoView.tsx @@ -1,3 +1,8 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ import { Link } from 'react-router-dom' import { useAppState } from '../../AppShell/hooks/useAppState' import { Item } from '../../../types' diff --git a/src/Components/Profile/Subcomponents/FormHeader.tsx b/src/Components/Profile/Subcomponents/FormHeader.tsx index 86ccf924..d58a70b3 100644 --- a/src/Components/Profile/Subcomponents/FormHeader.tsx +++ b/src/Components/Profile/Subcomponents/FormHeader.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable react/prop-types */ import { TextInput } from '../../Input' import { AvatarWidget } from './AvatarWidget' diff --git a/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx b/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx index 53bf733b..3708e53f 100644 --- a/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx +++ b/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx @@ -1,10 +1,13 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ import * as React from 'react' import ComboBoxInput from '../../Input/ComboBoxInput' import { Item } from '../../../types' import { useEffect } from 'react' import { FormState } from '../Templates/OnepagerForm' -type groupType = { +interface groupType { groupTypes_id: { name: string color: string diff --git a/src/Components/Profile/Subcomponents/LinkedItemsHeaderView.tsx b/src/Components/Profile/Subcomponents/LinkedItemsHeaderView.tsx index b4a37a29..0dafb1a1 100644 --- a/src/Components/Profile/Subcomponents/LinkedItemsHeaderView.tsx +++ b/src/Components/Profile/Subcomponents/LinkedItemsHeaderView.tsx @@ -1,3 +1,10 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-empty-function */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { useEffect } from 'react' import { getValue } from '../../../Utils/GetValue' import { Item } from '../../../types' @@ -31,10 +38,10 @@ export function LinkedItemsHeaderView({ appState.assetsApi.url + getValue(item, item.layer?.itemAvatarField) const title = itemNameField ? getValue(item, itemNameField) - : item.layer?.itemNameField && item && getValue(item, item.layer?.itemNameField) + : item.layer?.itemNameField && item && getValue(item, item.layer.itemNameField) const subtitle = itemSubnameField ? getValue(item, itemSubnameField) - : item.layer?.itemSubnameField && item && getValue(item, item.layer?.itemSubnameField) + : item.layer?.itemSubnameField && item && getValue(item, item.layer.itemSubnameField) useEffect(() => {}, [item]) diff --git a/src/Components/Profile/Subcomponents/PlusButton.tsx b/src/Components/Profile/Subcomponents/PlusButton.tsx index 72755cb1..70cbcdd3 100644 --- a/src/Components/Profile/Subcomponents/PlusButton.tsx +++ b/src/Components/Profile/Subcomponents/PlusButton.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import { LayerProps } from '../../../types' import { useHasUserPermission } from '../../Map/hooks/usePermissions' diff --git a/src/Components/Profile/Subcomponents/ProfileStartEndForm.tsx b/src/Components/Profile/Subcomponents/ProfileStartEndForm.tsx index feebaf24..3ffc48cb 100644 --- a/src/Components/Profile/Subcomponents/ProfileStartEndForm.tsx +++ b/src/Components/Profile/Subcomponents/ProfileStartEndForm.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ import * as React from 'react' import { PopupStartEndInput } from '../../Map' import { Item } from '../../../types' diff --git a/src/Components/Profile/Subcomponents/ProfileTextForm.tsx b/src/Components/Profile/Subcomponents/ProfileTextForm.tsx index 0100f792..d1f8a99d 100644 --- a/src/Components/Profile/Subcomponents/ProfileTextForm.tsx +++ b/src/Components/Profile/Subcomponents/ProfileTextForm.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-explicit-any */ import * as React from 'react' import { TextAreaInput } from '../../Input' import { FormState } from '../Templates/OnepagerForm' diff --git a/src/Components/Profile/Subcomponents/ProfileTextView.tsx b/src/Components/Profile/Subcomponents/ProfileTextView.tsx index 0e58e217..10227f0f 100644 --- a/src/Components/Profile/Subcomponents/ProfileTextView.tsx +++ b/src/Components/Profile/Subcomponents/ProfileTextView.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Item } from '../../../types' import { getValue } from '../../../Utils/GetValue' import { TextView } from '../../Map' diff --git a/src/Components/Profile/Subcomponents/RelationCard.tsx b/src/Components/Profile/Subcomponents/RelationCard.tsx index 277e1ae4..30d84ea4 100644 --- a/src/Components/Profile/Subcomponents/RelationCard.tsx +++ b/src/Components/Profile/Subcomponents/RelationCard.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ // eslint-disable-next-line react/prop-types const RelationCard = ({ title, description, imageSrc }) => (
diff --git a/src/Components/Profile/Subcomponents/SocialShareBar.tsx b/src/Components/Profile/Subcomponents/SocialShareBar.tsx index 5c246bd1..bd627431 100644 --- a/src/Components/Profile/Subcomponents/SocialShareBar.tsx +++ b/src/Components/Profile/Subcomponents/SocialShareBar.tsx @@ -2,12 +2,13 @@ import { toast } from 'react-toastify' import SocialShareButton from './SocialShareButton' const SocialShareBar = ({ - // eslint-disable-next-line react/prop-types url, - // eslint-disable-next-line react/prop-types title, - // eslint-disable-next-line react/prop-types platforms = ['facebook', 'twitter', 'linkedin', 'xing', 'email'], +}: { + url: string + title: string + platforms?: string[] }) => { const copyLink = () => { navigator.clipboard @@ -15,7 +16,7 @@ const SocialShareBar = ({ .then(() => { toast.success('link copied to clipboard') }) - .catch((error) => { + .catch((error: never) => { toast.error('Fehler beim Kopieren des Links: ', error) }) } diff --git a/src/Components/Profile/Subcomponents/SocialShareButton.tsx b/src/Components/Profile/Subcomponents/SocialShareButton.tsx index 58b6aaa5..e77bd56e 100644 --- a/src/Components/Profile/Subcomponents/SocialShareButton.tsx +++ b/src/Components/Profile/Subcomponents/SocialShareButton.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import * as React from 'react' const platformConfigs = { @@ -70,8 +74,15 @@ const platformConfigs = { }, } -// eslint-disable-next-line react/prop-types -const SocialShareButton = ({ platform, url, title }) => { +const SocialShareButton = ({ + platform, + url, + title, +}: { + platform: string + url: string + title: string +}) => { const config = platformConfigs[platform] if (!config) { diff --git a/src/Components/Profile/Subcomponents/TagsWidget.tsx b/src/Components/Profile/Subcomponents/TagsWidget.tsx index 753ac6e4..9f79dd89 100644 --- a/src/Components/Profile/Subcomponents/TagsWidget.tsx +++ b/src/Components/Profile/Subcomponents/TagsWidget.tsx @@ -1,3 +1,9 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import * as React from 'react' import { useEffect, useState } from 'react' import { useTags } from '../../Map/hooks/useTags' @@ -11,10 +17,10 @@ export const TagsWidget = ({ placeholder, containerStyle, defaultTags, onUpdate const [input, setInput] = useState('') const [isKeyReleased, setIsKeyReleased] = useState(false) const tags = useTags() - const [pushFilteredSuggestions, setPushFilteredSuggestions] = useState>([]) + const [pushFilteredSuggestions, setPushFilteredSuggestions] = useState([]) const [focusInput, setFocusInput] = useState(false) - const [currentTags, setCurrentTags] = useState>(defaultTags) + const [currentTags, setCurrentTags] = useState(defaultTags) useEffect(() => { setCurrentTags(defaultTags) diff --git a/src/Components/Profile/Templates/FlexForm.tsx b/src/Components/Profile/Templates/FlexForm.tsx index 6b570da4..cd046046 100644 --- a/src/Components/Profile/Templates/FlexForm.tsx +++ b/src/Components/Profile/Templates/FlexForm.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import * as React from 'react' import { Item } from '../../../types' import { FormState } from './OnepagerForm' diff --git a/src/Components/Profile/Templates/FlexView.tsx b/src/Components/Profile/Templates/FlexView.tsx index f9243fee..e677c025 100644 --- a/src/Components/Profile/Templates/FlexView.tsx +++ b/src/Components/Profile/Templates/FlexView.tsx @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import { GroupSubHeaderView } from '../Subcomponents/GroupSubHeaderView' import { ProfileTextView } from '../Subcomponents/ProfileTextView' import { ContactInfoView } from '../Subcomponents/ContactInfoView' diff --git a/src/Components/Profile/Templates/OnepagerForm.tsx b/src/Components/Profile/Templates/OnepagerForm.tsx index 2663747d..865c9763 100644 --- a/src/Components/Profile/Templates/OnepagerForm.tsx +++ b/src/Components/Profile/Templates/OnepagerForm.tsx @@ -1,10 +1,12 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ import * as React from 'react' import { Item, Tag } from '../../../types' import { TextAreaInput } from '../../Input' import { GroupSubheaderForm } from '../Subcomponents/GroupSubheaderForm' import { ContactInfoForm } from '../Subcomponents/ContactInfoForm' -export type FormState = { +export interface FormState { color: string id: string group_type: string diff --git a/src/Components/Profile/Templates/OnepagerView.tsx b/src/Components/Profile/Templates/OnepagerView.tsx index 5de70e1c..21640a5a 100644 --- a/src/Components/Profile/Templates/OnepagerView.tsx +++ b/src/Components/Profile/Templates/OnepagerView.tsx @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import { Item } from '../../../types' import { TextView } from '../../Map' import { ContactInfoView } from '../Subcomponents/ContactInfoView' diff --git a/src/Components/Profile/Templates/SimpleForm.tsx b/src/Components/Profile/Templates/SimpleForm.tsx index c77c6df3..68fd1a06 100644 --- a/src/Components/Profile/Templates/SimpleForm.tsx +++ b/src/Components/Profile/Templates/SimpleForm.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { TextAreaInput } from '../../Input' // eslint-disable-next-line react/prop-types diff --git a/src/Components/Profile/Templates/TabsForm.tsx b/src/Components/Profile/Templates/TabsForm.tsx index 38f47a8e..fc5d2ecd 100644 --- a/src/Components/Profile/Templates/TabsForm.tsx +++ b/src/Components/Profile/Templates/TabsForm.tsx @@ -1,3 +1,10 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable react/prop-types */ import { useCallback, useEffect, useState } from 'react' import { TextAreaInput } from '../../Input' diff --git a/src/Components/Profile/Templates/TabsView.tsx b/src/Components/Profile/Templates/TabsView.tsx index 48ee6e51..a376897d 100644 --- a/src/Components/Profile/Templates/TabsView.tsx +++ b/src/Components/Profile/Templates/TabsView.tsx @@ -1,3 +1,11 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { StartEndView, TextView } from '../../Map' import { TagView } from '../../Templates/TagView' import { LinkedItemsHeaderView } from '../Subcomponents/LinkedItemsHeaderView' @@ -21,11 +29,11 @@ export const TabsView = ({ linkItem, unlinkItem, }: { - attestations: Array + attestations: any[] item: Item - offers: Array - needs: Array - relations: Array + offers: Tag[] + needs: Tag[] + relations: Item[] updatePermission: boolean loading: boolean linkItem: (id: string) => Promise @@ -110,7 +118,7 @@ export const TabsView = ({ className={ 'tw-tab tw-font-bold !tw-ps-2 !tw-pe-2 [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]' } - aria-label={`${item.layer?.itemType.icon_as_labels && activeTab !== 2 ? '❤️' : '❤️\u00A0Credibility'}`} + aria-label={`${item.layer.itemType.icon_as_labels && activeTab !== 2 ? '❤️' : '❤️\u00A0Credibility'}`} checked={activeTab === 2 && true} onChange={() => updateActiveTab(2)} /> @@ -178,8 +186,8 @@ export const TabsView = ({ type='radio' name='my_tabs_2' role='tab' - className={`tw-tab tw-font-bold !tw-ps-2 !tw-pe-2 ${!(item.layer?.itemType.icon_as_labels && activeTab !== 3) && 'tw-min-w-[10.4em]'} [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]`} - aria-label={`${item.layer?.itemType.icon_as_labels && activeTab !== 3 ? '♻️' : '♻️\u00A0Offers & Needs'}`} + className={`tw-tab tw-font-bold !tw-ps-2 !tw-pe-2 ${!(item.layer.itemType.icon_as_labels && activeTab !== 3) && 'tw-min-w-[10.4em]'} [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]`} + aria-label={`${item.layer.itemType.icon_as_labels && activeTab !== 3 ? '♻️' : '♻️\u00A0Offers & Needs'}`} checked={activeTab === 3 && true} onChange={() => updateActiveTab(3)} /> @@ -195,7 +203,7 @@ export const TabsView = ({
{offers.map((o) => ( { addFilterTag(o) @@ -212,7 +220,7 @@ export const TabsView = ({

Needs

{needs.map((n) => ( - addFilterTag(n)} /> + addFilterTag(n)} /> ))}
@@ -232,7 +240,7 @@ export const TabsView = ({ name='my_tabs_2' role='tab' className='tw-tab tw-font-bold !tw-ps-2 !tw-pe-2 [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]' - aria-label={`${item.layer?.itemType.icon_as_labels && activeTab !== 7 ? '🔗' : '🔗\u00A0Relations'}`} + aria-label={`${item.layer.itemType.icon_as_labels && activeTab !== 7 ? '🔗' : '🔗\u00A0Relations'}`} checked={activeTab === 7 && true} onChange={() => updateActiveTab(7)} /> diff --git a/src/Components/Profile/UserSettings.tsx b/src/Components/Profile/UserSettings.tsx index 1784c3cf..20813730 100644 --- a/src/Components/Profile/UserSettings.tsx +++ b/src/Components/Profile/UserSettings.tsx @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import * as React from 'react' import { MapOverlayPage } from '../Templates' import { useNavigate } from 'react-router-dom' diff --git a/src/Components/Profile/hooks/useClickOutside.tsx b/src/Components/Profile/hooks/useClickOutside.tsx index 0f61ec9c..4217f0e6 100644 --- a/src/Components/Profile/hooks/useClickOutside.tsx +++ b/src/Components/Profile/hooks/useClickOutside.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import { useEffect } from 'react' // Improved version of https://usehooks.com/useOnClickOutside/ diff --git a/src/Components/Profile/itemFunctions.ts b/src/Components/Profile/itemFunctions.ts index 4eccacdb..05e0d8da 100644 --- a/src/Components/Profile/itemFunctions.ts +++ b/src/Components/Profile/itemFunctions.ts @@ -1,3 +1,14 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import * as React from 'react' import { Item } from '../../types' import { encodeTag } from '../../Utils/FormatTags' @@ -140,7 +151,7 @@ export const onUpdateItem = async ( ) => { let changedItem = {} as Item - const offerUpdates: Array = [] + const offerUpdates: any[] = [] // check for new offers await state.offers?.map((o) => { const existingOffer = item?.offers?.find((t) => t.tags_id === o.id) @@ -150,7 +161,7 @@ export const onUpdateItem = async ( return null }) - const needsUpdates: Array = [] + const needsUpdates: any[] = [] await state.needs?.map((n) => { const existingNeed = item?.needs?.find((t) => t.tags_id === n.id) @@ -181,8 +192,8 @@ export const onUpdateItem = async ( ...(state.needs.length > 0 && { needs: needsUpdates }), } - const offersState: Array = [] - const needsState: Array = [] + const offersState: any[] = [] + const needsState: any[] = [] state.offers.map((o) => { offersState.push({ items_id: item?.id, tags_id: o.id }) diff --git a/src/Components/Templates/AttestationForm.tsx b/src/Components/Templates/AttestationForm.tsx index 424a66f1..f616dd25 100644 --- a/src/Components/Templates/AttestationForm.tsx +++ b/src/Components/Templates/AttestationForm.tsx @@ -1,3 +1,12 @@ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/require-await */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-floating-promises */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import * as React from 'react' import { MapOverlayPage } from './MapOverlayPage' import { useItems } from '../Map/hooks/useItems' @@ -11,7 +20,7 @@ import { toast } from 'react-toastify' export const AttestationForm = ({ api }: { api?: ItemsApi }) => { const items = useItems() const appState = useAppState() - const [users, setUsers] = useState>() + const [users, setUsers] = useState() const navigate = useNavigate() useEffect(() => { @@ -36,7 +45,7 @@ export const AttestationForm = ({ api }: { api?: ItemsApi }) => { } const sendAttestation = async () => { - const to: Array = [] + const to: any[] = [] users?.map((u) => to.push({ directus_users_id: u.user_created.id })) api?.createItem && diff --git a/src/Components/Templates/CardPage.tsx b/src/Components/Templates/CardPage.tsx index 53481ee0..9722f6e3 100644 --- a/src/Components/Templates/CardPage.tsx +++ b/src/Components/Templates/CardPage.tsx @@ -11,7 +11,7 @@ export function CardPage({ title: string hideTitle?: boolean children?: React.ReactNode - parents?: Array<{ name: string; path: string }> + parents?: { name: string; path: string }[] }) { return (
diff --git a/src/Components/Templates/CircleLayout.tsx b/src/Components/Templates/CircleLayout.tsx index 1405eb01..f36b8681 100644 --- a/src/Components/Templates/CircleLayout.tsx +++ b/src/Components/Templates/CircleLayout.tsx @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { useEffect, useRef } from 'react' export const CircleLayout = ({ diff --git a/src/Components/Templates/DateUserInfo.tsx b/src/Components/Templates/DateUserInfo.tsx index b87cc88f..25662a84 100644 --- a/src/Components/Templates/DateUserInfo.tsx +++ b/src/Components/Templates/DateUserInfo.tsx @@ -1,3 +1,8 @@ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ import { useState } from 'react' import { timeAgo } from '../../Utils/TimeAgo' import { Item } from '../../types' diff --git a/src/Components/Templates/DialogModal.tsx b/src/Components/Templates/DialogModal.tsx index d6351374..8951048e 100644 --- a/src/Components/Templates/DialogModal.tsx +++ b/src/Components/Templates/DialogModal.tsx @@ -7,7 +7,7 @@ const isClickInsideRectangle = (e: MouseEvent, element: HTMLElement) => { return e.clientX > r.left && e.clientX < r.right && e.clientY > r.top && e.clientY < r.bottom } -type Props = { +interface Props { title: string isOpened: boolean onClose: () => void @@ -43,7 +43,7 @@ const DialogModal = ({ if (isOpened) { return ( {i.layer?.itemType.show_start_end && } {i.layer?.itemType.show_text && ( - + )}
diff --git a/src/Components/Templates/MapOverlayPage.tsx b/src/Components/Templates/MapOverlayPage.tsx index 265ab7b4..1e5d86cd 100644 --- a/src/Components/Templates/MapOverlayPage.tsx +++ b/src/Components/Templates/MapOverlayPage.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import * as L from 'leaflet' import * as React from 'react' import { useNavigate } from 'react-router-dom' diff --git a/src/Components/Templates/MarketView.tsx b/src/Components/Templates/MarketView.tsx index e0af1459..8b5adc31 100644 --- a/src/Components/Templates/MarketView.tsx +++ b/src/Components/Templates/MarketView.tsx @@ -1,3 +1,8 @@ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import { useEffect, useState } from 'react' import { useItems } from '../Map/hooks/useItems' import { Tag } from '../../types' @@ -24,8 +29,8 @@ function groupAndCount(arr) { } export const MarketView = () => { - const [offers, setOffers] = useState>([]) - const [needs, setNeeds] = useState>([]) + const [offers, setOffers] = useState([]) + const [needs, setNeeds] = useState([]) const navigate = useNavigate() const items = useItems() @@ -35,13 +40,13 @@ export const MarketView = () => { setOffers([]) setNeeds([]) items.map((i) => { - i?.layer?.itemOffersField && + i.layer?.itemOffersField && getValue(i, i.layer.itemOffersField)?.map((o) => { const tag = tags.find((t) => t.id === o.tags_id) tag && setOffers((current) => [...current, tag]) return null }) - i?.layer?.itemNeedsField && + i.layer?.itemNeedsField && getValue(i, i.layer.itemNeedsField)?.map((n) => { const tag = tags.find((t) => t.id === n.tags_id) tag && setNeeds((current) => [...current, tag]) diff --git a/src/Components/Templates/OverlayItemsIndexPage.tsx b/src/Components/Templates/OverlayItemsIndexPage.tsx index 63a5cabf..61502f07 100644 --- a/src/Components/Templates/OverlayItemsIndexPage.tsx +++ b/src/Components/Templates/OverlayItemsIndexPage.tsx @@ -1,3 +1,10 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/prefer-optional-chain */ +/* eslint-disable @typescript-eslint/no-misused-promises */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ import { useEffect, useRef, useState } from 'react' import { Item } from '../../types' import { PopupStartEndInput } from '../Map' @@ -122,7 +129,7 @@ export const OverlayItemsIndexPage = ({
{items - ?.filter((i) => i.layer?.name === layerName) + .filter((i) => i.layer?.name === layerName) .filter((item) => filterTags.length === 0 ? item @@ -133,7 +140,7 @@ export const OverlayItemsIndexPage = ({ ), ), ) - ?.sort((a, b) => { + .sort((a, b) => { // Convert date_created to milliseconds, handle undefined by converting to lowest possible date (0 milliseconds) const dateA = a.date_updated ? new Date(a.date_updated).getTime() @@ -147,7 +154,7 @@ export const OverlayItemsIndexPage = ({ : 0 return dateB - dateA // Subtracts milliseconds which are numbers }) - ?.map((i, k) => ( + .map((i, k) => (
{ const items = useItems() const users = items.filter((i) => i.layer?.itemType.name === appState.userType) - const [selectedUsers, setSelectedUsers] = useState>([]) + const [selectedUsers, setSelectedUsers] = useState([]) return ( diff --git a/src/Components/Templates/TagView.tsx b/src/Components/Templates/TagView.tsx index 0ed5e18e..db080fb1 100644 --- a/src/Components/Templates/TagView.tsx +++ b/src/Components/Templates/TagView.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import * as React from 'react' import { decodeTag } from '../../Utils/FormatTags' import { Tag } from '../../types' diff --git a/src/Components/Templates/TitleCard.tsx b/src/Components/Templates/TitleCard.tsx index 2638f747..9c904cc0 100644 --- a/src/Components/Templates/TitleCard.tsx +++ b/src/Components/Templates/TitleCard.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ +/* eslint-disable @typescript-eslint/no-explicit-any */ import Subtitle from '../Typography/Subtitle' import * as React from 'react' diff --git a/src/Components/Typography/ErrorText.tsx b/src/Components/Typography/ErrorText.tsx index c99f194a..d8f9e051 100644 --- a/src/Components/Typography/ErrorText.tsx +++ b/src/Components/Typography/ErrorText.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ import * as React from 'react' // eslint-disable-next-line react/prop-types diff --git a/src/Utils/GetValue.ts b/src/Utils/GetValue.ts index 7732b461..c2d73ed3 100644 --- a/src/Utils/GetValue.ts +++ b/src/Utils/GetValue.ts @@ -1,3 +1,6 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ export function getValue(obj, path) { if (!obj || typeof path !== 'string') return undefined diff --git a/src/Utils/MarkerIconFactory.ts b/src/Utils/MarkerIconFactory.ts index 2bd1d700..9ddc8c40 100644 --- a/src/Utils/MarkerIconFactory.ts +++ b/src/Utils/MarkerIconFactory.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ import * as L from 'leaflet' const createSvg = (shape: string, markerColor: string, borderColor: string) => { diff --git a/src/Utils/RandomColor.ts b/src/Utils/RandomColor.ts index 1b7b6469..daa5e1c7 100644 --- a/src/Utils/RandomColor.ts +++ b/src/Utils/RandomColor.ts @@ -1,10 +1,15 @@ +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-unsafe-call */ const goldenRatioConjugate = 0.618033988749895 export const randomColor = () => { return hsvToHex((Math.random() + goldenRatioConjugate) % 1, 0.8, 0.7) } -function hsvToHex(h, s, v) { +function hsvToHex(h: number, s: number, v: number) { let r, g, b const i = Math.floor(h * 6) const f = h * 6 - i @@ -53,6 +58,6 @@ const rgbToHex = (r, g, b) => [r, g, b] .map((x) => { const hex = x.toString(16) - return hex.length === 1 ? '0' + hex : hex + return hex.length === 1 ? `0${hex}` : hex }) .join('') diff --git a/src/Utils/ReverseGeocoder.ts b/src/Utils/ReverseGeocoder.ts index cfe99fc6..3879b291 100644 --- a/src/Utils/ReverseGeocoder.ts +++ b/src/Utils/ReverseGeocoder.ts @@ -27,9 +27,9 @@ export async function reverseGeocode(lat: number, lon: number): Promise const address = response.data.address // Extrahiere Straße, Hausnummer und Ort - const street = address.road || '' - const houseNumber = address.house_number || '' - const city = address.city || address.town || address.village || '' + const street = address.road ?? '' + const houseNumber = address.house_number ?? '' + const city = address.city ?? address.town ?? address.village ?? '' // Formatiere die Adresse const formattedAddress = `${street} ${houseNumber}, ${city}`.trim() diff --git a/src/index.tsx b/src/index.tsx index 238e8272..91ca338b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -39,8 +39,8 @@ export { export { TextInput, TextAreaInput, SelectBox } from './Components/Input' declare global { - // eslint-disable-next-line no-unused-vars interface Window { + // eslint-disable-next-line @typescript-eslint/no-explicit-any my_modal_3: any } } diff --git a/src/types.ts b/src/types.ts index 26038fe5..3032a95b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import * as React from 'react' import { ItemFormPopupProps } from './Components/Map/Subcomponents/ItemFormPopup' @@ -82,7 +83,7 @@ export class Geometry { } } -export type Relation = { +export interface Relation { related_items_id: string [key: string]: any } @@ -102,8 +103,8 @@ export class Item { relations?: Relation[] parent?: string subname?: string - public_edit?: boolean; - // eslint-disable-next-line no-undef + public_edit?: boolean + slug?: string; [key: string]: any constructor( id: string, @@ -127,7 +128,7 @@ export interface AssetsApi { url: string } -export type Profile = { +export interface Profile { id?: string avatar?: string color?: string @@ -136,7 +137,7 @@ export type Profile = { geoposition?: Geometry } -export type UserItem = { +export interface UserItem { id?: string role?: any email?: string @@ -156,7 +157,7 @@ export interface UserApi { passwordReset(token: string, new_password: string) } -export type PermissionCondition = { +export interface PermissionCondition { user_created?: { _eq: string // Erwartet den speziellen Wert "$CURRENT_USER" oder eine spezifische UUID } @@ -167,7 +168,7 @@ export type PermissionCondition = { export type PermissionAction = 'create' | 'read' | 'update' | 'delete' -export type Permission = { +export interface Permission { id?: string policy: any collection: string