fix: format code

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-07-19 12:24:51 +02:00
parent d75d406e67
commit 34bf8f16b1
14 changed files with 46 additions and 22 deletions

View file

@ -43,6 +43,7 @@ export const MarkdownBody = createParamDecorator(
(target, key): void => {
if (key === undefined) {
throw new Error(
// eslint-disable-next-line @typescript-eslint/no-base-to-string
`Could not enhance param decorator for target ${target.toString()} because key is undefined`,
);
}
@ -52,6 +53,7 @@ export const MarkdownBody = createParamDecorator(
);
if (!ownPropertyDescriptor) {
throw new Error(
// eslint-disable-next-line @typescript-eslint/no-base-to-string
`Could not get property descriptor for target ${target.toString()} and key ${key.toString()}`,
);
}

View file

@ -22,6 +22,6 @@ export async function getFirstIdentityFromUser(
return undefined;
}
return identities.find(
(aIdentity) => aIdentity.providerType === providerType,
(aIdentity) => aIdentity.providerType === (providerType as string),
);
}

View file

@ -77,6 +77,7 @@ export class ImgurBackend implements MediaBackend {
headers: { Authorization: `Client-ID ${this.config.clientID}` },
},
).then((res) => ImgurBackend.checkStatus(res));
// eslint-disable-next-line @typescript-eslint/no-base-to-string
this.logger.debug(`Response: ${result.toString()}`, 'deleteFile');
this.logger.log(`Deleted ${fileName}`, 'deleteFile');
return;

View file

@ -370,13 +370,15 @@ describe('NotesService', () => {
const groupPermissions = await newNote.groupPermissions;
expect(groupPermissions).toHaveLength(2);
expect(groupPermissions[0].canEdit).toEqual(
everyoneDefaultAccessPermission !== DefaultAccessLevel.WRITE,
everyoneDefaultAccessPermission !==
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[0].group).name).toEqual(
SpecialGroup.EVERYONE,
);
expect(groupPermissions[1].canEdit).toEqual(
loggedinDefaultAccessPermission === DefaultAccessLevel.WRITE,
loggedinDefaultAccessPermission ===
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[1].group).name).toEqual(
SpecialGroup.LOGGED_IN,
@ -394,13 +396,15 @@ describe('NotesService', () => {
const groupPermissions = await newNote.groupPermissions;
expect(groupPermissions).toHaveLength(2);
expect(groupPermissions[0].canEdit).toEqual(
everyoneDefaultAccessPermission === DefaultAccessLevel.WRITE,
everyoneDefaultAccessPermission ===
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[0].group).name).toEqual(
SpecialGroup.EVERYONE,
);
expect(groupPermissions[1].canEdit).toEqual(
loggedinDefaultAccessPermission === DefaultAccessLevel.WRITE,
loggedinDefaultAccessPermission ===
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[1].group).name).toEqual(
SpecialGroup.LOGGED_IN,
@ -417,13 +421,15 @@ describe('NotesService', () => {
const groupPermissions = await newNote.groupPermissions;
expect(groupPermissions).toHaveLength(2);
expect(groupPermissions[0].canEdit).toEqual(
everyoneDefaultAccessPermission !== DefaultAccessLevel.WRITE,
everyoneDefaultAccessPermission !==
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[0].group).name).toEqual(
SpecialGroup.EVERYONE,
);
expect(groupPermissions[1].canEdit).toEqual(
loggedinDefaultAccessPermission === DefaultAccessLevel.WRITE,
loggedinDefaultAccessPermission ===
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[1].group).name).toEqual(
SpecialGroup.LOGGED_IN,
@ -442,13 +448,15 @@ describe('NotesService', () => {
const groupPermissions = await newNote.groupPermissions;
expect(groupPermissions).toHaveLength(2);
expect(groupPermissions[0].canEdit).toEqual(
everyoneDefaultAccessPermission === DefaultAccessLevel.WRITE,
everyoneDefaultAccessPermission ===
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[0].group).name).toEqual(
SpecialGroup.EVERYONE,
);
expect(groupPermissions[1].canEdit).toEqual(
loggedinDefaultAccessPermission === DefaultAccessLevel.WRITE,
loggedinDefaultAccessPermission ===
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[1].group).name).toEqual(
SpecialGroup.LOGGED_IN,
@ -471,13 +479,15 @@ describe('NotesService', () => {
const groupPermissions = await newNote.groupPermissions;
expect(groupPermissions).toHaveLength(2);
expect(groupPermissions[0].canEdit).toEqual(
everyoneDefaultAccessPermission === DefaultAccessLevel.WRITE,
everyoneDefaultAccessPermission ===
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[0].group).name).toEqual(
SpecialGroup.EVERYONE,
);
expect(groupPermissions[1].canEdit).toEqual(
loggedinDefaultAccessPermission === DefaultAccessLevel.WRITE,
loggedinDefaultAccessPermission ===
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[1].group).name).toEqual(
SpecialGroup.LOGGED_IN,
@ -505,7 +515,8 @@ describe('NotesService', () => {
const groupPermissions = await newNote.groupPermissions;
expect(groupPermissions).toHaveLength(1);
expect(groupPermissions[0].canEdit).toEqual(
loggedinDefaultAccessPermission === DefaultAccessLevel.WRITE,
loggedinDefaultAccessPermission ===
(DefaultAccessLevel.WRITE as string),
);
expect((await groupPermissions[0].group).name).toEqual(
SpecialGroup.LOGGED_IN,

View file

@ -47,8 +47,8 @@ async function findNotePermissionByGroup(
function isSpecialGroup(group: Group): boolean {
return (
group.special &&
(group.name === SpecialGroup.LOGGED_IN ||
group.name === SpecialGroup.EVERYONE)
(group.name === (SpecialGroup.LOGGED_IN as string) ||
group.name === (SpecialGroup.EVERYONE as string))
);
}

View file

@ -37,10 +37,12 @@ export const userCanEdit = (
const mayWriteViaGroupPermission =
!!user &&
permissions.sharedToGroups.some(
(value) => value.groupName === SpecialGroup.LOGGED_IN && value.canEdit
(value) =>
value.groupName === (SpecialGroup.LOGGED_IN as string) && value.canEdit
)
const everyoneMayWriteViaGroupPermission = permissions.sharedToGroups.some(
(value) => value.groupName === SpecialGroup.EVERYONE && value.canEdit
(value) =>
value.groupName === (SpecialGroup.EVERYONE as string) && value.canEdit
)
return (
isOwner ||

View file

@ -68,6 +68,7 @@ export class RealtimeDoc extends EventEmitter2<RealtimeDocEvents> {
* @return The current note content.
*/
public getCurrentContent(): string {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
return this.getMarkdownContentChannel().toString()
}

View file

@ -29,12 +29,15 @@ describe('y-doc-sync-adapter', () => {
const textClient2 = docClient2.getMarkdownContentChannel()
textServer.observe(() =>
// eslint-disable-next-line @typescript-eslint/no-base-to-string
console.log('textServer', new Date(), textServer.toString())
)
textClient1.observe(() =>
// eslint-disable-next-line @typescript-eslint/no-base-to-string
console.log('textClient1', new Date(), textClient1.toString())
)
textClient2.observe(() =>
// eslint-disable-next-line @typescript-eslint/no-base-to-string
console.log('textClient2', new Date(), textClient2.toString())
)
@ -206,8 +209,11 @@ describe('y-doc-sync-adapter', () => {
textClient1.insert(0, 'test3')
textClient2.insert(0, 'test4')
// eslint-disable-next-line @typescript-eslint/no-base-to-string
expect(textServer.toString()).toBe('test4test3test2This is a test note')
// eslint-disable-next-line @typescript-eslint/no-base-to-string
expect(textClient1.toString()).toBe('test4test3test2This is a test note')
// eslint-disable-next-line @typescript-eslint/no-base-to-string
expect(textClient2.toString()).toBe('test4test3test2This is a test note')
docServer.destroy()

View file

@ -15,6 +15,7 @@ import { useEffect } from 'react'
export const useBindYTextToRedux = (realtimeDoc: RealtimeDoc): void => {
useEffect(() => {
const yText = realtimeDoc.getMarkdownContentChannel()
// eslint-disable-next-line @typescript-eslint/no-base-to-string
const yTextCallback = () => setNoteContent(yText.toString())
yText.observe(yTextCallback)
return () => yText.unobserve(yTextCallback)

View file

@ -16,7 +16,7 @@ export const extractEmojiShortCode = (emoji: EmojiClickEventDetail): string | un
return undefined
}
let skinToneModifier = ''
if ((emoji.emoji as NativeEmoji).skins && emoji.skinTone !== 0) {
if ((emoji.emoji as NativeEmoji).skins && (emoji.skinTone as number) !== 0) {
skinToneModifier = `:skin-tone-${emoji.skinTone as number}:`
}
return `:${emoji.emoji.shortcodes[0]}:${skinToneModifier}`

View file

@ -22,8 +22,8 @@ export const PermissionSectionSpecialGroups: React.FC<PermissionDisabledProps> =
const isOwner = useIsOwner()
const specialGroupEntries = useMemo(() => {
const groupEveryone = groupPermissions.find((entry) => entry.groupName === SpecialGroup.EVERYONE)
const groupLoggedIn = groupPermissions.find((entry) => entry.groupName === SpecialGroup.LOGGED_IN)
const groupEveryone = groupPermissions.find((entry) => entry.groupName === (SpecialGroup.EVERYONE as string))
const groupLoggedIn = groupPermissions.find((entry) => entry.groupName === (SpecialGroup.LOGGED_IN as string))
return {
everyone: groupEveryone

View file

@ -55,7 +55,7 @@ export const SplitDivider: React.FC<SplitDividerProps> = ({
const className = useMemo(() => {
return concatCssClasses(styles.middle, {
[styles.open]: forceOpen,
[styles[dividerButtonsShift]]: dividerButtonsShift !== ''
[styles[dividerButtonsShift]]: dividerButtonsShift !== DividerButtonsShift.NO_SHIFT
})
}, [dividerButtonsShift, forceOpen])

View file

@ -27,7 +27,7 @@ export interface OnOffButtonGroupProps {
export const OnOffButtonGroup: React.FC<OnOffButtonGroupProps> = ({ onSelect, value }) => {
const buttonGroupValue = useMemo(() => (value ? OnOffState.ON : OnOffState.OFF), [value])
const onButtonSelect = useCallback(
(value: number) => {
(value: OnOffState) => {
onSelect(value === OnOffState.ON)
},
[onSelect]

View file

@ -32,7 +32,7 @@ export const ProfilePage: React.FC = () => {
<Row className='h-100 flex justify-content-center'>
<Col lg={6}>
<ProfileDisplayName />
<ShowIf condition={userProvider === AuthProviderType.LOCAL}>
<ShowIf condition={userProvider === (AuthProviderType.LOCAL as string)}>
<ProfileChangePassword />
</ShowIf>
<ProfileAccessTokens />