From a5aecd98eb333bc702acbfd473bd2b0ab33b677d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Vanvelthem?= Date: Sun, 20 Oct 2024 19:54:12 +0200 Subject: [PATCH] fix: lint with latest rules --- apps/nextjs-app/.eslintrc.cjs | 3 ++- apps/nextjs-app/package.json | 2 +- apps/nextjs-app/src/config/build-env.config.mjs | 1 - apps/nextjs-app/src/layouts/admin/AdminSidebar.tsx | 1 - apps/nextjs-app/src/lib/env/utils.mjs | 2 +- packages/eslint-config-bases/src/bases/sonar.js | 5 +++++ 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/nextjs-app/.eslintrc.cjs b/apps/nextjs-app/.eslintrc.cjs index 7a6a3540c83..1c53689c014 100644 --- a/apps/nextjs-app/.eslintrc.cjs +++ b/apps/nextjs-app/.eslintrc.cjs @@ -21,7 +21,7 @@ module.exports = { extends: [ '@your-org/eslint-config-bases/typescript', '@your-org/eslint-config-bases/import-x', - // '@your-org/eslint-config-bases/sonar', + '@your-org/eslint-config-bases/sonar', '@your-org/eslint-config-bases/regexp', '@your-org/eslint-config-bases/jest', '@your-org/eslint-config-bases/react', @@ -39,6 +39,7 @@ module.exports = { // For the sake of example // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/anchor-is-valid.md 'jsx-a11y/anchor-is-valid': 'off', + 'sonarjs/anchor-is-valid': 'off', 'jsx-a11y/label-has-associated-control': 'off', }, overrides: [ diff --git a/apps/nextjs-app/package.json b/apps/nextjs-app/package.json index db7ff2f705a..1aa87b19d3a 100644 --- a/apps/nextjs-app/package.json +++ b/apps/nextjs-app/package.json @@ -24,7 +24,7 @@ "dev": "next", "fix-all-files": "eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs,.mdx,.graphql --fix", "flamegraph-home": "npx 0x --output-dir './.debug/flamegraph/{pid}.0x' --on-port 'autocannon http://localhost:$PORT --duration 20' -- node ../../node_modules/.bin/next start", - "lint": "eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs,.mdx,.graphql --cache --cache-location ../../.cache/eslint/nextjs-app.eslintcache", + "lint": "TIMING=1 eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs,.mdx,.graphql --cache --cache-location ../../.cache/eslint/nextjs-app.eslintcache", "start": "next start", "test": "yarn test-unit", "test-e2e": "cross-env E2E_WEBSERVER_MODE=BUILD_AND_START playwright test", diff --git a/apps/nextjs-app/src/config/build-env.config.mjs b/apps/nextjs-app/src/config/build-env.config.mjs index 873d7412196..5c9bc655706 100644 --- a/apps/nextjs-app/src/config/build-env.config.mjs +++ b/apps/nextjs-app/src/config/build-env.config.mjs @@ -13,7 +13,6 @@ const isProd = process.env.NODE_ENV === 'production'; const falseOnCi = !isCI; /** - * @todo working with jsdoc/mjs is limited, see later on how to improve this * @satisfies { Record<`NEXT_BUILD_ENV_${string}`, import('zod').ZodSchema> } */ const schema = { diff --git a/apps/nextjs-app/src/layouts/admin/AdminSidebar.tsx b/apps/nextjs-app/src/layouts/admin/AdminSidebar.tsx index 051ed9b1b0c..971a082a72e 100644 --- a/apps/nextjs-app/src/layouts/admin/AdminSidebar.tsx +++ b/apps/nextjs-app/src/layouts/admin/AdminSidebar.tsx @@ -3,7 +3,6 @@ import type { FC } from 'react'; import { TextAvatar } from '@/components/avatar/TextAvatar'; export const AdminSidebar: FC = () => { - // @todo better to use middleware or https://next-auth.js.org/getting-started/client#custom-client-session-handling // const { data: session, status } = useSession(); const { data: session } = useSession(); const user = session?.user; diff --git a/apps/nextjs-app/src/lib/env/utils.mjs b/apps/nextjs-app/src/lib/env/utils.mjs index f309a1b2aab..2385acb5bbb 100644 --- a/apps/nextjs-app/src/lib/env/utils.mjs +++ b/apps/nextjs-app/src/lib/env/utils.mjs @@ -3,7 +3,7 @@ import pc from 'picocolors'; import { z } from 'zod'; -const isRunningInNode = process !== undefined; +const isRunningInNode = process != undefined; const isTestEnv = process.env.NODE_ENV === 'test'; export const truthyStrEnvValue = ['true', '1']; diff --git a/packages/eslint-config-bases/src/bases/sonar.js b/packages/eslint-config-bases/src/bases/sonar.js index 29065263f94..1a1827cde3b 100644 --- a/packages/eslint-config-bases/src/bases/sonar.js +++ b/packages/eslint-config-bases/src/bases/sonar.js @@ -18,6 +18,9 @@ module.exports = { excludedFiles: filePatterns.nonCodeFile, files: filePatterns.anyCode, rules: { + // better handled by jsx-a11y plugin + 'sonarjs/anchor-is-valid': 'off', + 'sonarjs/label-has-associated-control': 'off', // Typescript-eslint does the job well enough 'sonarjs/no-misused-promises': 'off', // Because plugin unused-import does it better (autofix) @@ -28,6 +31,8 @@ module.exports = { 'sonarjs/sonar-no-unused-vars': 'off', // because it's handled by typescript-eslint 'sonarjs/deprecation': 'off', + // it makes too much noise + 'sonarjs/sonar-prefer-read-only-props': 'off', // because it doesn't play well with exactOptionalTypes 'sonarjs/no-redundant-optional': 'off', 'sonarjs/jsx-no-useless-fragment': 'off',