mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
feat: add rule 'sonarjs/no-identical-functions' (#2905)
This commit is contained in:
@@ -157,6 +157,7 @@ const config = {
|
|||||||
'sonarjs/no-duplicated-branches': 'error',
|
'sonarjs/no-duplicated-branches': 'error',
|
||||||
'sonarjs/no-collection-size-mischeck': 'error',
|
'sonarjs/no-collection-size-mischeck': 'error',
|
||||||
'sonarjs/no-useless-catch': 'error',
|
'sonarjs/no-useless-catch': 'error',
|
||||||
|
'sonarjs/no-identical-functions': 'error',
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,16 +62,4 @@ export class AuthResolver {
|
|||||||
ctx.req.user = user;
|
ctx.req.user = user;
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => UserType)
|
|
||||||
async signUp(
|
|
||||||
@Context() ctx: { req: Request },
|
|
||||||
@Args('email') email: string,
|
|
||||||
@Args('password') password: string,
|
|
||||||
@Args('name') name: string
|
|
||||||
) {
|
|
||||||
const user = await this.auth.register(name, email, password);
|
|
||||||
ctx.req.user = user;
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import type {
|
|||||||
} from '@affine/env/filter';
|
} from '@affine/env/filter';
|
||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
import { render } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
|
import type { ReactElement } from 'react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { describe, expect, test } from 'vitest';
|
import { describe, expect, test } from 'vitest';
|
||||||
|
|
||||||
@@ -130,15 +131,19 @@ describe('render filter', () => {
|
|||||||
await result.findByText('false');
|
await result.findByText('false');
|
||||||
result.unmount();
|
result.unmount();
|
||||||
});
|
});
|
||||||
test('date condition function change', async () => {
|
|
||||||
const dateFunction = filterMatcher.match(tDate.create());
|
const WrapperCreator = (fn: FilterMatcherDataType) =>
|
||||||
assertExists(dateFunction);
|
function Wrapper(): ReactElement {
|
||||||
const Wrapper = () => {
|
|
||||||
const [value, onChange] = useState(
|
const [value, onChange] = useState(
|
||||||
filter(dateFunction, ref('Created'), [new Date(2023, 5, 29).getTime()])
|
filter(fn, ref('Created'), [new Date(2023, 5, 29).getTime()])
|
||||||
);
|
);
|
||||||
return <Condition value={value} onChange={onChange} />;
|
return <Condition value={value} onChange={onChange} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
test('date condition function change', async () => {
|
||||||
|
const dateFunction = filterMatcher.match(tDate.create());
|
||||||
|
assertExists(dateFunction);
|
||||||
|
const Wrapper = WrapperCreator(dateFunction);
|
||||||
const result = render(<Wrapper />);
|
const result = render(<Wrapper />);
|
||||||
const dom = await result.findByTestId('filter-name');
|
const dom = await result.findByTestId('filter-name');
|
||||||
dom.click();
|
dom.click();
|
||||||
@@ -148,12 +153,7 @@ describe('render filter', () => {
|
|||||||
test('date condition variable change', async () => {
|
test('date condition variable change', async () => {
|
||||||
const dateFunction = filterMatcher.match(tDate.create());
|
const dateFunction = filterMatcher.match(tDate.create());
|
||||||
assertExists(dateFunction);
|
assertExists(dateFunction);
|
||||||
const Wrapper = () => {
|
const Wrapper = WrapperCreator(dateFunction);
|
||||||
const [value, onChange] = useState(
|
|
||||||
filter(dateFunction, ref('Created'), [new Date(2023, 5, 29).getTime()])
|
|
||||||
);
|
|
||||||
return <Condition value={value} onChange={onChange} />;
|
|
||||||
};
|
|
||||||
const result = render(<Wrapper />);
|
const result = render(<Wrapper />);
|
||||||
const dom = await result.findByTestId('variable-name');
|
const dom = await result.findByTestId('variable-name');
|
||||||
dom.click();
|
dom.click();
|
||||||
|
|||||||
Reference in New Issue
Block a user