Skip to content

Commit

Permalink
fix: lint with latest rules
Browse files Browse the repository at this point in the history
  • Loading branch information
belgattitude committed Oct 20, 2024
1 parent 9935c62 commit 754b098
Show file tree
Hide file tree
Showing 40 changed files with 150 additions and 331 deletions.
4 changes: 2 additions & 2 deletions apps/nextjs-app/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
ignorePatterns: [...getDefaultIgnorePatterns(), '.next', '.out'],
extends: [
'@your-org/eslint-config-bases/typescript',
'@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',
Expand Down Expand Up @@ -55,7 +55,7 @@ module.exports = {
},
},
{
files: ['src/pages/\\_*.{ts,tsx}'],
files: [String.raw`src/pages/\_*.{ts,tsx}`],
rules: {
'react/display-name': 'off',
},
Expand Down
1 change: 0 additions & 1 deletion apps/nextjs-app/config/tests/I18nextTestStubProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { I18nNamespace } from '@/lib/i18n/I18nNamespace.types';
* Fully wrapped strategy for i18next, you can use stub/mocks as well
* @link {https://react.i18next.com/misc/testing}
*/
// eslint-disable-next-line import/no-named-as-default-member
void i18next.use(initReactI18next).init({
lng: 'en',
fallbackLng: 'en',
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-app/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { devices, type PlaywrightTestConfig } from '@playwright/test';
*/
const config: PlaywrightTestConfig = {
testDir: '.',
timeout: 6_000,
timeout: 6000,
/* Maximum time one test can run for. */
/* Opt out of parallel tests on CI. */
// workers: process.env.CI ? 1 : undefined,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-app/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
8 changes: 4 additions & 4 deletions apps/nextjs-app/next-i18next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';

const debugI18n = ['true', 1].includes(
process?.env?.NEXTJS_DEBUG_I18N ?? 'false'
Expand Down Expand Up @@ -30,7 +30,7 @@ export default {
},
*/
localePath:
typeof window === 'undefined'
? path.resolve('../../packages/common-i18n/src/locales')
: localePublicFolder,
'window' in globalThis
? localePublicFolder
: path.resolve('../../packages/common-i18n/src/locales'),
};
2 changes: 1 addition & 1 deletion apps/nextjs-app/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const workspaceRoot = path.resolve(
* @type {import('type-fest').PackageJson}
*/
const packageJson = JSON.parse(
readFileSync(new URL('./package.json', import.meta.url)).toString('utf-8')
readFileSync(new URL('package.json', import.meta.url)).toString('utf8')
);

const isProd = process.env.NODE_ENV === 'production';
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"@tailwindcss/forms": "0.5.9",
"@tailwindcss/typography": "0.5.15",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.2",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "16.0.1",
"@testing-library/user-event": "14.5.2",
"@types/cors": "2.8.17",
Expand All @@ -141,7 +141,7 @@
"dotenv-flow-cli": "1.1.1",
"es-check": "7.2.1",
"eslint": "8.57.1",
"eslint-config-next": "14.2.15",
"eslint-config-next": "15.0.0-rc.1",
"eslint-plugin-tailwindcss": "3.17.5",
"is-ci": "3.0.1",
"jsdom": "25.0.1",
Expand Down
144 changes: 0 additions & 144 deletions apps/nextjs-app/playwright.config.old.ts

This file was deleted.

4 changes: 2 additions & 2 deletions apps/nextjs-app/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { devices, type PlaywrightTestConfig } from '@playwright/test';

const isCI = ['true', '1'].includes(process.env?.CI ?? '');

const outputDir = new URL('./e2e/.out', import.meta.url).pathname;
const outputDir = new URL('e2e/.out', import.meta.url).pathname;
const testDir = new URL('e2e', import.meta.url).pathname;

// Reference: https://playwright.dev/docs/test-configuration
const config: PlaywrightTestConfig = {
testDir: testDir,
timeout: 6_000,
timeout: 6000,
/* Maximum time one test can run for. */
/* Opt out of parallel tests on CI. */
// workers: process.env.CI ? 1 : undefined,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-app/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Sentry.init({
console.log('Sentry event', event);
console.log('Sentry hint', hint);
}
return Promise.resolve(event);
return event;
},
ignoreErrors: [
/**
Expand Down
10 changes: 5 additions & 5 deletions apps/nextjs-app/src/config/app-cache.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {

const appCacheDsn = process.env.APP_CACHE_DSN ?? null;

export const appCache = !appCacheDsn
? new MapCacheAdapter()
: new IoRedisCacheAdapter({
export const appCache = appCacheDsn
? new IoRedisCacheAdapter({
connection: getIoRedisOptionsFromDsn(appCacheDsn, {
connectTimeout: 3_000,
connectTimeout: 3000,
maxRetriesPerRequest: 2,
}),
});
})
: new MapCacheAdapter();
13 changes: 6 additions & 7 deletions apps/nextjs-app/src/config/next-auth.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createHttpUnauthorized } from '@/lib/auth/error';
import { getServerRuntimeEnv } from './server-runtime-env.config.mjs';

const serverRuntimeEnv = getServerRuntimeEnv();
const oneDayInSeconds = 86400;
const oneDayInSeconds = 86_400;

/**
* @todo Remove this once oauth is ready
Expand Down Expand Up @@ -58,8 +58,7 @@ export const nextAuthConfig: NextAuthOptions = {
email,
password
);
if (staticAllowedDemoAdminUser)
return Promise.resolve(staticAllowedDemoAdminUser);
if (staticAllowedDemoAdminUser) return staticAllowedDemoAdminUser;

throw createHttpUnauthorized('Invalid credentials');
},
Expand Down Expand Up @@ -96,17 +95,17 @@ export const nextAuthConfig: NextAuthOptions = {
},
*/
async redirect({ url, baseUrl }) {
return Promise.resolve(url.startsWith(baseUrl) ? url : baseUrl);
return url.startsWith(baseUrl) ? url : baseUrl;
},
// async session({ session, token, user }) {
async session({ session, token }) {
return Promise.resolve({
return {
...session,
user: {
...session.user,
role: token.role,
},
});
};
},
async jwt({ token, user, trigger }) {
if (trigger === 'signUp') {
Expand All @@ -115,7 +114,7 @@ export const nextAuthConfig: NextAuthOptions = {
if (user) {
token.role = user.role;
}
return Promise.resolve(token);
return token;
},
},
pages: {
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs-app/src/layouts/admin/AdminSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ export const AdminSidebar: FC = () => {
<label className="whites mx-2 flex h-fit w-full cursor-pointer p-0 hover:bg-gray-4">
<div className="flex flex-row gap-4 p-4">
<div className="avatar-square avatar avatar-md">
{user !== undefined ? (
{user === undefined ? null : (
<TextAvatar name={user.name ?? 'Demo User'} />
) : null}
)}
{/* <img src={user?.image ?? } alt="avatar" /> */}
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('getBuildEnv', () => {
});
expect(
(buildEnv as unknown as typeof injectedEnv).NEXT_BUILD_ENV_OUTPUT
).toStrictEqual('classic');
).toBe('classic');
});

describe('boolean coercion', () => {
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs-app/src/lib/env/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const exitOrThrowError = (zodSafeParseError) => {
Object.keys(zodSafeParseError.error.flatten().fieldErrors).join(',')
);
console.error(JSON.stringify(zodSafeParseError.error.format(), null, 2));
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
} else {
throw new Error(
Expand Down
8 changes: 4 additions & 4 deletions apps/nextjs-app/src/lib/factory/ky.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export class KyFactory {
constructor(private props: Props) {}
create = (options?: Omit<Options, 'hooks'>): typeof Ky => {
const hooks: Options['hooks'] =
this.props.onAuthFailure !== undefined
? {
this.props.onAuthFailure === undefined
? {}
: {
afterResponse: [
async (request, options, response): Promise<Response> => {
const { status } = response;
Expand All @@ -27,8 +28,7 @@ export class KyFactory {
return response;
},
],
}
: {};
};

return Ky.create({
prefixUrl: this.props.baseUrl,
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs-app/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ MyDocument.getInitialProps = async (ctx) => {
if (process.env.NEXT_MANUAL_SIG_HANDLE) {
// this should be added in your custom _document
process.on('SIGTERM', () => {
console.log('Received SIGTERM: ', 'cleaning up');
console.log('Received SIGTERM:', 'cleaning up');
process.exit(0);
});

process.on('SIGINT', () => {
console.log('Received SIGINT: ', 'cleaning up');
console.log('Received SIGINT:', 'cleaning up');
process.exit(0);
});
}
Expand Down
Loading

0 comments on commit 754b098

Please sign in to comment.