mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-22 15:11:37 +03:00
feat: add rule 'sonarjs/no-identical-functions' (#2905)
This commit is contained in:
parent
bc14d54cfa
commit
3eed009270
@ -157,6 +157,7 @@ const config = {
|
||||
'sonarjs/no-duplicated-branches': 'error',
|
||||
'sonarjs/no-collection-size-mischeck': 'error',
|
||||
'sonarjs/no-useless-catch': 'error',
|
||||
'sonarjs/no-identical-functions': 'error',
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
@ -62,16 +62,4 @@ export class AuthResolver {
|
||||
ctx.req.user = 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';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { render } from '@testing-library/react';
|
||||
import type { ReactElement } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
@ -130,15 +131,19 @@ describe('render filter', () => {
|
||||
await result.findByText('false');
|
||||
result.unmount();
|
||||
});
|
||||
test('date condition function change', async () => {
|
||||
const dateFunction = filterMatcher.match(tDate.create());
|
||||
assertExists(dateFunction);
|
||||
const Wrapper = () => {
|
||||
|
||||
const WrapperCreator = (fn: FilterMatcherDataType) =>
|
||||
function Wrapper(): ReactElement {
|
||||
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} />;
|
||||
};
|
||||
|
||||
test('date condition function change', async () => {
|
||||
const dateFunction = filterMatcher.match(tDate.create());
|
||||
assertExists(dateFunction);
|
||||
const Wrapper = WrapperCreator(dateFunction);
|
||||
const result = render(<Wrapper />);
|
||||
const dom = await result.findByTestId('filter-name');
|
||||
dom.click();
|
||||
@ -148,12 +153,7 @@ describe('render filter', () => {
|
||||
test('date condition variable change', async () => {
|
||||
const dateFunction = filterMatcher.match(tDate.create());
|
||||
assertExists(dateFunction);
|
||||
const Wrapper = () => {
|
||||
const [value, onChange] = useState(
|
||||
filter(dateFunction, ref('Created'), [new Date(2023, 5, 29).getTime()])
|
||||
);
|
||||
return <Condition value={value} onChange={onChange} />;
|
||||
};
|
||||
const Wrapper = WrapperCreator(dateFunction);
|
||||
const result = render(<Wrapper />);
|
||||
const dom = await result.findByTestId('variable-name');
|
||||
dom.click();
|
||||
|
Loading…
Reference in New Issue
Block a user