From f1156f5276bcb135c20bbeae7d6d5dfdde03e002 Mon Sep 17 00:00:00 2001 From: lotyp Date: Mon, 17 Jul 2023 13:04:17 +0300 Subject: [PATCH] chore: apply linters --- apps/web/.eslintrc.cjs | 4 +-- apps/web/jest.config.js | 6 +--- ...taged.config.js => lint-staged.config.cjs} | 0 apps/web/next.config.mjs | 35 +++++-------------- apps/web/sentry.client.config.ts | 4 +-- apps/web/src/config/validated-server-env.mjs | 6 +--- .../features/auth/components/LoginForm.tsx | 15 ++------ apps/web/src/pages/_document.tsx | 15 ++------ apps/web/src/themes/shared/browser-fonts.js | 9 +---- apps/web/tailwind.config.ts | 5 +-- 10 files changed, 20 insertions(+), 79 deletions(-) rename apps/web/{lint-staged.config.js => lint-staged.config.cjs} (100%) diff --git a/apps/web/.eslintrc.cjs b/apps/web/.eslintrc.cjs index 6cafb570..ce830e09 100644 --- a/apps/web/.eslintrc.cjs +++ b/apps/web/.eslintrc.cjs @@ -7,9 +7,7 @@ // Workaround for https://github.com/eslint/eslint/issues/3458 (re-export of @rushstack/eslint-patch) require('@wayofdev/eslint-config-bases/patch/modern-module-resolution') -const { - getDefaultIgnorePatterns, -} = require('@wayofdev/eslint-config-bases/helpers') +const { getDefaultIgnorePatterns } = require('@wayofdev/eslint-config-bases/helpers') module.exports = { root: true, diff --git a/apps/web/jest.config.js b/apps/web/jest.config.js index 2354414d..bb6f982c 100644 --- a/apps/web/jest.config.js +++ b/apps/web/jest.config.js @@ -52,11 +52,7 @@ const config = { // false by default, overrides in cli, ie: yarn test:unit --collect-coverage=true collectCoverage: false, coverageDirectory: '/../coverage', - collectCoverageFrom: [ - '/**/*.{ts,tsx,js,jsx}', - '!**/*.test.{js,ts}', - '!**/__mock__/*', - ], + collectCoverageFrom: ['/**/*.{ts,tsx,js,jsx}', '!**/*.test.{js,ts}', '!**/__mock__/*'], transformIgnorePatterns: ['/node_modules/(?!@vercel/analytics)/'], } diff --git a/apps/web/lint-staged.config.js b/apps/web/lint-staged.config.cjs similarity index 100% rename from apps/web/lint-staged.config.js rename to apps/web/lint-staged.config.cjs diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs index 9c175846..f6ce4444 100644 --- a/apps/web/next.config.mjs +++ b/apps/web/next.config.mjs @@ -21,11 +21,7 @@ import { getValidatedServerEnv } from './src/config/validated-server-env.mjs' // validate server env getValidatedServerEnv() -const workspaceRoot = path.resolve( - path.dirname(url.fileURLToPath(import.meta.url)), - '..', - '..' -) +const workspaceRoot = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..', '..') /** * Once supported replace by node / eslint / ts and out of experimental, replace by @@ -41,18 +37,10 @@ const isProd = process.env.NODE_ENV === 'production' const isCI = trueEnv.includes(process.env?.CI ?? 'false') const enableCSP = true -const NEXT_STANDALONE_BUILD = trueEnv.includes( - process.env?.NEXT_STANDALONE_BUILD ?? 'false' -) -const NEXT_IGNORE_TYPE_CHECK = trueEnv.includes( - process.env?.NEXT_IGNORE_TYPE_CHECK ?? 'false' -) -const NEXT_IGNORE_ESLINT = trueEnv.includes( - process.env?.NEXT_IGNORE_ESLINT ?? 'false' -) -const SENTRY_UPLOAD_DRY_RUN = trueEnv.includes( - process.env?.SENTRY_UPLOAD_DRY_RUN ?? 'false' -) +const NEXT_STANDALONE_BUILD = trueEnv.includes(process.env?.NEXT_STANDALONE_BUILD ?? 'false') +const NEXT_IGNORE_TYPE_CHECK = trueEnv.includes(process.env?.NEXT_IGNORE_TYPE_CHECK ?? 'false') +const NEXT_IGNORE_ESLINT = trueEnv.includes(process.env?.NEXT_IGNORE_ESLINT ?? 'false') +const SENTRY_UPLOAD_DRY_RUN = trueEnv.includes(process.env?.SENTRY_UPLOAD_DRY_RUN ?? 'false') const DISABLE_SENTRY = trueEnv.includes(process.env?.DISABLE_SENTRY ?? 'false') const SENTRY_DEBUG = trueEnv.includes(process.env?.SENTRY_DEBUG ?? 'false') const SENTRY_TRACING = trueEnv.includes(process.env?.SENTRY_TRACING ?? 'false') @@ -62,9 +50,7 @@ const SENTRY_TRACING = trueEnv.includes(process.env?.SENTRY_TRACING ?? 'false') * to deliver an image or deploy the files. * @link https://nextjs.org/docs/advanced-features/source-maps */ -const disableSourceMaps = trueEnv.includes( - process.env?.NEXT_DISABLE_SOURCEMAPS ?? 'false' -) +const disableSourceMaps = trueEnv.includes(process.env?.NEXT_DISABLE_SOURCEMAPS ?? 'false') if (disableSourceMaps) { console.log( @@ -116,10 +102,7 @@ const secureHeaders = createSecureHeaders({ }, ...(enableCSP && process.env.NODE_ENV === 'production' ? { - forceHTTPSRedirect: [ - true, - { maxAge: 60 * 60 * 24 * 4, includeSubDomains: true }, - ], + forceHTTPSRedirect: [true, { maxAge: 60 * 60 * 24 * 4, includeSubDomains: true }], } : {}), referrerPolicy: 'same-origin', @@ -185,9 +168,7 @@ const nextConfig = { // Standalone build // @link https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files-experimental - ...(NEXT_STANDALONE_BUILD - ? { output: 'standalone', outputFileTracing: true } - : {}), + ...(NEXT_STANDALONE_BUILD ? { output: 'standalone', outputFileTracing: true } : {}), experimental: { // @link https://nextjs.org/docs/advanced-features/output-file-tracing#caveats diff --git a/apps/web/sentry.client.config.ts b/apps/web/sentry.client.config.ts index e4a5ae30..6c209b68 100644 --- a/apps/web/sentry.client.config.ts +++ b/apps/web/sentry.client.config.ts @@ -13,9 +13,7 @@ sentryInit({ // @see https://develop.sentry.dev/sdk/performance/ // To turn it off, remove the line // @see https://github.com/getsentry/sentry-javascript/discussions/4503#discussioncomment-2143116 - tracesSampleRate: ['false', '0'].includes(process.env.SENTRY_TRACING ?? '') - ? undefined - : 1, + tracesSampleRate: ['false', '0'].includes(process.env.SENTRY_TRACING ?? '') ? undefined : 1, // Note: The Replay integration only needs to be added to your sentry.client.config.js file. // It will not run if it is added into sentry.server.config.js. diff --git a/apps/web/src/config/validated-server-env.mjs b/apps/web/src/config/validated-server-env.mjs index 8759b5e3..a920fec9 100644 --- a/apps/web/src/config/validated-server-env.mjs +++ b/apps/web/src/config/validated-server-env.mjs @@ -24,11 +24,7 @@ export const getValidatedServerEnv = () => { process.exit(1) } else { throw new Error( - `Invalid server env(s): ${JSON.stringify( - parsedEnv.error.format(), - null, - 2 - )}}` + `Invalid server env(s): ${JSON.stringify(parsedEnv.error.format(), null, 2)}}` ) } } diff --git a/apps/web/src/features/auth/components/LoginForm.tsx b/apps/web/src/features/auth/components/LoginForm.tsx index 64fc76f4..1c32ef30 100644 --- a/apps/web/src/features/auth/components/LoginForm.tsx +++ b/apps/web/src/features/auth/components/LoginForm.tsx @@ -38,12 +38,7 @@ export const LoginForm: FC = _props => { // callbackUrl: '/', redirect: false, }) - const { - ok = false, - url, - status = 500, - error = 'Server or network Error', - } = result ?? {} + const { ok = false, url, status = 500, error = 'Server or network Error' } = result ?? {} if (ok) { console.log('Will redirect to ' + url) @@ -67,9 +62,7 @@ export const LoginForm: FC = _props => { placeholder="Username or email" className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" /> - {errors?.username && ( -

{errors.username.message}

- )} + {errors?.username &&

{errors.username.message}

}