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 754b098 commit 4ae6f9e
Show file tree
Hide file tree
Showing 30 changed files with 67 additions and 139 deletions.
1 change: 1 addition & 0 deletions apps/nextjs-app/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
ignorePatterns: [...getDefaultIgnorePatterns(), '.next', '.out'],
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/regexp',
'@your-org/eslint-config-bases/jest',
Expand Down
2 changes: 2 additions & 0 deletions apps/nextjs-app/config/tests/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ const customRender = (ui: ReactElement, options?: any) =>
});

// re-export everything
// eslint-disable-next-line import-x/export
export * from '@testing-library/react';
export { default as userEvent } from '@testing-library/user-event';

// override render method
// eslint-disable-next-line import-x/export
export { customRender as render };
18 changes: 12 additions & 6 deletions apps/nextjs-app/next-i18next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import path from 'node:path';

const debugI18n = ['true', 1].includes(
process?.env?.NEXTJS_DEBUG_I18N ?? 'false'
);
Expand All @@ -8,6 +6,17 @@ const localePublicFolder = undefined;

export const defaultLocale = 'en';

const getLocalesPath = async () => {
if ('window' in globalThis) {
return localePublicFolder;
}
// eslint-disable-next-line unicorn/prefer-node-protocol,unicorn/import-style
const path = await import('path').then((mod) => mod.default);
return path.resolve('../../packages/common-i18n/src/locales');
};

const localePath = await getLocalesPath();

/**
* @type {import('next-i18next').UserConfig}
*/
Expand All @@ -29,8 +38,5 @@ export default {
escapeValue: false,
},
*/
localePath:
'window' in globalThis
? localePublicFolder
: path.resolve('../../packages/common-i18n/src/locales'),
localePath,
};

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions packages/common-i18n/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
ignorePatterns: [...getDefaultIgnorePatterns()],
extends: [
'@your-org/eslint-config-bases/typescript',
'@your-org/eslint-config-bases/import-x',
// Apply prettier and disable incompatible rules
'@your-org/eslint-config-bases/prettier-plugin',
],
Expand Down
1 change: 1 addition & 0 deletions packages/core-lib/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
ignorePatterns: [...getDefaultIgnorePatterns()],
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/regexp',
'@your-org/eslint-config-bases/jest',
Expand Down
2 changes: 1 addition & 1 deletion packages/core-lib/config/test/setupVitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ const jestCompatOverride = {
spyOn: vi.spyOn,
};

(global as unknown as Record<'jest', unknown>).jest = jestCompatOverride;
(globalThis as unknown as Record<'jest', unknown>).jest = jestCompatOverride;
3 changes: 2 additions & 1 deletion packages/core-lib/config/test/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/export */
import { cleanup, render } from '@testing-library/react';
import type React from 'react';

Expand All @@ -20,7 +19,9 @@ const customRender = (ui: React.ReactElement, options = {}) =>
...options,
});

// eslint-disable-next-line import-x/export
export * from '@testing-library/react';
export { default as userEvent } from '@testing-library/user-event';
// override render export
// eslint-disable-next-line import-x/export
export { customRender as render };
18 changes: 9 additions & 9 deletions packages/core-lib/src/hooks/__tests__/use-promise.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('usePromise', () => {
const callback = vi.fn();
const promiseFn = async (deps: Deps) => {
callback(deps);
return Promise.resolve(expected);
return expected;
};

const { result, rerender } = renderHook(() =>
Expand All @@ -21,7 +21,7 @@ describe('usePromise', () => {
// initial data
const initialValue = result.current;
expect(result.current.data).toBeNull();
expect(result.current.isLoading).toStrictEqual(true);
expect(result.current.isLoading).toBe(true);
expect(result.current.error).toBeNull();

// resolved data
Expand All @@ -32,13 +32,13 @@ describe('usePromise', () => {
expect(callback).toHaveBeenCalledTimes(1);

expect(result.current.data).toStrictEqual(expected);
expect(result.current.isLoading).toStrictEqual(false);
expect(result.current.isLoading).toBe(false);
expect(result.current.error).toBeNull();

rerender();
expect(callback).toHaveBeenCalledTimes(1);
expect(result.current.data).toStrictEqual(expected);
expect(result.current.isLoading).toStrictEqual(false);
expect(result.current.isLoading).toBe(false);
expect(result.current.error).toBeNull();
});

Expand All @@ -55,7 +55,7 @@ describe('usePromise', () => {
// initial data
const initialValue = result.current;
expect(result.current.data).toBeNull();
expect(result.current.isLoading).toStrictEqual(true);
expect(result.current.isLoading).toBe(true);
expect(result.current.error).toBeNull();

// resolved data
Expand All @@ -65,22 +65,22 @@ describe('usePromise', () => {

expect(callback).toHaveBeenCalledTimes(1);
expect(result.current.error).toBeInstanceOf(Error);
expect(result.current.isLoading).toStrictEqual(false);
expect(result.current.error?.message).toStrictEqual('cool');
expect(result.current.isLoading).toBe(false);
expect(result.current.error?.message).toBe('cool');
});

it('should call the promise when forceReload is called', async () => {
const callback = vi.fn();
const promiseFn = async () => {
callback();
return Promise.resolve(0);
return 0;
};

const { result } = renderHook(() => usePromise(promiseFn, {}));
// initial data
const initialValue = result.current;
expect(result.current.data).toBeNull();
expect(result.current.isLoading).toStrictEqual(true);
expect(result.current.isLoading).toBe(true);
expect(result.current.error).toBeNull();

// resolved data
Expand Down
2 changes: 1 addition & 1 deletion packages/core-lib/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig((options) => ({
format: ['esm'],
platform: 'browser',
target: ['es2020', 'chrome80', 'edge18', 'firefox70', 'node18'],
tsconfig: new URL('./tsconfig.build.json', import.meta.url).pathname,
tsconfig: new URL('tsconfig.build.json', import.meta.url).pathname,
sourcemap: !options.watch,
minify: !options.watch,
}));
1 change: 1 addition & 0 deletions packages/db-main-prisma/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
ignorePatterns: [...getDefaultIgnorePatterns(), 'src/generated'],
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/regexp',
// Apply prettier and disable incompatible rules
Expand Down
2 changes: 1 addition & 1 deletion packages/db-main-prisma/e2e/e2e-dsn-services.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const getAndCheckDatabaseDsn = async (): Promise<string> => {
const { dsn, port, host } = getValidatedDsn();
const reachable = await isPortReachable(port as unknown as number, {
host: host,
timeout: 5_000,
timeout: 5000,
});

if (!reachable) {
Expand Down
17 changes: 9 additions & 8 deletions packages/db-main-prisma/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ async function main() {
console.log(`Seeding finished.`);
}

main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
try {
await main();
} catch (e) {
console.error(e);
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
} finally {
await prisma.$disconnect();
}
4 changes: 2 additions & 2 deletions packages/db-main-prisma/src/seeds/PoemSeeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const poems: Prisma.PoemCreateInput[] = [
].map((poem) => {
const sanitizedContent = poem.content
// @link http://www.unicode.org/reports/tr18/#RL1.6
.split(/(\r\n|[\n\v\f\r\x85\u2028\u2029])/)
.split(/(\r\n|[\n\v\f\r\u0085\u2028\u2029])/)
.map((line) => line.trim())
.filter((line) => line.length > 0)
.join('\n')
Expand Down Expand Up @@ -303,7 +303,7 @@ const poemData = poems.map((p) => {

export class PoemSeeds extends AbstractSeed {
execute = async (): Promise<void> => {
for await (const p of poemData) {
for (const p of poemData) {
const { keywords, ...poemWithoutKeywords } = p;
const poem = await this.prisma.poem.upsert({
where: {
Expand Down
4 changes: 2 additions & 2 deletions packages/db-main-prisma/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./src",
"target": "ESNext",
"target": "esnext",
"lib": ["esnext"],
"module": "ES2020",
"module": "esnext",
"noEmit": false,
"incremental": true,
"paths": {},
Expand Down
2 changes: 1 addition & 1 deletion packages/db-main-prisma/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig((options) => {
format: ['esm'],
platform: 'node',
target: ['node18'],
tsconfig: new URL('./tsconfig.build.json', import.meta.url).pathname,
tsconfig: new URL('tsconfig.build.json', import.meta.url).pathname,
sourcemap: !options.watch,
// Do not minify node only packages to let patching possible by the consumer (ie: patch-package)
minify: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-bases/src/bases/sonar.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
'warn',
{
// For NextJs styled-jsx <style jsx>{`...`}</style>
ignore: ['jsx'],
ignore: ['jsx', 'css'],
},
],
},
Expand Down
1 change: 1 addition & 0 deletions packages/ts-utils/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
ignorePatterns: [...getDefaultIgnorePatterns()],
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/regexp',
'@your-org/eslint-config-bases/jest',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stringToFloat, stringToSafeInteger } from '../';
import { stringToFloat, stringToSafeInteger } from '..';

describe('StringConvert tests', () => {
describe('stringtoSafeInteger', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
isParsableSafeInteger,
isPlainObject,
isPresent,
} from '../';
} from '..';

describe('Typeguards tests', () => {
describe('isNonEmptyString', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/ui-lib/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
ignorePatterns: [...getDefaultIgnorePatterns(), '/storybook-static'],
extends: [
'@your-org/eslint-config-bases/typescript',
'@your-org/eslint-config-bases/import-x',
'@your-org/eslint-config-bases/regexp',
'@your-org/eslint-config-bases/sonar',
'@your-org/eslint-config-bases/jest',
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-lib/config/test/setupVitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ const jestCompatOverride = {
spyOn: vi.spyOn,
};

(global as unknown as Record<'jest', unknown>).jest = jestCompatOverride;
(globalThis as unknown as Record<'jest', unknown>).jest = jestCompatOverride;
3 changes: 2 additions & 1 deletion packages/ui-lib/config/test/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/export */
import { cleanup, render } from '@testing-library/react';
import type React from 'react';

Expand All @@ -20,7 +19,9 @@ const customRender = (ui: React.ReactElement, options = {}) =>
...options,
});

// eslint-disable-next-line import-x/export
export * from '@testing-library/react';
export { default as userEvent } from '@testing-library/user-event';
// override render export
// eslint-disable-next-line import-x/export
export { customRender as render };
Loading

0 comments on commit 4ae6f9e

Please sign in to comment.