diff --git a/package.json b/package.json index 57671f9f4..07e23883b 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "eslint-config-prettier": "7.1.0", "eslint-plugin-import": "2.22.1", "jest": "26.6.3", - "prettier": "1.19.1", + "prettier": "2.2.1", "supertest": "6.0.1", "ts-jest": "26.1.0", "ts-loader": "8.0.14", diff --git a/src/media/media-upload.entity.ts b/src/media/media-upload.entity.ts index 17ff9cdcd..7cd2d11b5 100644 --- a/src/media/media-upload.entity.ts +++ b/src/media/media-upload.entity.ts @@ -23,10 +23,10 @@ export class MediaUpload { @PrimaryColumn() id: string; - @ManyToOne(_ => Note, { nullable: false }) + @ManyToOne((_) => Note, { nullable: false }) note: Note; - @ManyToOne(_ => User, { nullable: false }) + @ManyToOne((_) => User, { nullable: false }) user: User; @Column({ diff --git a/src/monitoring/monitoring.service.ts b/src/monitoring/monitoring.service.ts index c97e10fea..92ef6452d 100644 --- a/src/monitoring/monitoring.service.ts +++ b/src/monitoring/monitoring.service.ts @@ -25,7 +25,7 @@ async function getServerVersionFromPackageJson() { const packageInfo: { version: string } = JSON.parse(rawFileContent); const versionParts: number[] = packageInfo.version .split('.') - .map(x => parseInt(x, 10)); + .map((x) => parseInt(x, 10)); versionCache = { major: versionParts[0], minor: versionParts[1], diff --git a/src/notes/author-color.entity.ts b/src/notes/author-color.entity.ts index 7e7e9bc1c..322667310 100644 --- a/src/notes/author-color.entity.ts +++ b/src/notes/author-color.entity.ts @@ -10,16 +10,12 @@ import { Note } from './note.entity'; @Entity() export class AuthorColor { - @ManyToOne( - _ => Note, - note => note.authorColors, - { - primary: true, - }, - ) + @ManyToOne((_) => Note, (note) => note.authorColors, { + primary: true, + }) note: Note; - @ManyToOne(_ => User, { + @ManyToOne((_) => User, { primary: true, }) user: User; diff --git a/src/notes/note.entity.ts b/src/notes/note.entity.ts index 87a90e397..5cffcff4b 100644 --- a/src/notes/note.entity.ts +++ b/src/notes/note.entity.ts @@ -36,36 +36,22 @@ export class Note { }) alias?: string; @OneToMany( - _ => NoteGroupPermission, - groupPermission => groupPermission.note, + (_) => NoteGroupPermission, + (groupPermission) => groupPermission.note, ) groupPermissions: NoteGroupPermission[]; - @OneToMany( - _ => NoteUserPermission, - userPermission => userPermission.note, - ) + @OneToMany((_) => NoteUserPermission, (userPermission) => userPermission.note) userPermissions: NoteUserPermission[]; @Column({ nullable: false, default: 0, }) viewcount: number; - @ManyToOne( - _ => User, - user => user.ownedNotes, - { onDelete: 'CASCADE' }, - ) + @ManyToOne((_) => User, (user) => user.ownedNotes, { onDelete: 'CASCADE' }) owner: User; - @OneToMany( - _ => Revision, - revision => revision.note, - { cascade: true }, - ) + @OneToMany((_) => Revision, (revision) => revision.note, { cascade: true }) revisions: Promise; - @OneToMany( - _ => AuthorColor, - authorColor => authorColor.note, - ) + @OneToMany((_) => AuthorColor, (authorColor) => authorColor.note) authorColors: AuthorColor[]; @Column({ @@ -77,11 +63,7 @@ export class Note { }) title?: string; - @ManyToMany( - _ => Tag, - tag => tag.notes, - { eager: true, cascade: true }, - ) + @ManyToMany((_) => Tag, (tag) => tag.notes, { eager: true, cascade: true }) @JoinTable() tags: Tag[]; diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts index a60667851..f1718aa2b 100644 --- a/src/notes/notes.service.ts +++ b/src/notes/notes.service.ts @@ -113,20 +113,22 @@ export class NotesService { // TODO: Get actual createTime createTime: new Date(), description: note.description, - editedBy: note.authorColors.map(authorColor => authorColor.user.userName), + editedBy: note.authorColors.map( + (authorColor) => authorColor.user.userName, + ), // TODO: Extract into method permissions: { owner: this.usersService.toUserDto(note.owner), - sharedToUsers: note.userPermissions.map(noteUserPermission => ({ + sharedToUsers: note.userPermissions.map((noteUserPermission) => ({ user: this.usersService.toUserDto(noteUserPermission.user), canEdit: noteUserPermission.canEdit, })), - sharedToGroups: note.groupPermissions.map(noteGroupPermission => ({ + sharedToGroups: note.groupPermissions.map((noteGroupPermission) => ({ group: noteGroupPermission.group, canEdit: noteGroupPermission.canEdit, })), }, - tags: note.tags.map(tag => tag.name), + tags: note.tags.map((tag) => tag.name), updateTime: (await this.getLastRevision(note)).createdAt, // TODO: Get actual updateUser updateUser: { diff --git a/src/notes/tag.entity.ts b/src/notes/tag.entity.ts index 77c5ef304..0164d3891 100644 --- a/src/notes/tag.entity.ts +++ b/src/notes/tag.entity.ts @@ -17,9 +17,6 @@ export class Tag { }) name: string; - @ManyToMany( - _ => Note, - note => note.tags, - ) + @ManyToMany((_) => Note, (note) => note.tags) notes: Note[]; } diff --git a/src/permissions/note-group-permission.entity.ts b/src/permissions/note-group-permission.entity.ts index 4d57accb7..68c774033 100644 --- a/src/permissions/note-group-permission.entity.ts +++ b/src/permissions/note-group-permission.entity.ts @@ -10,14 +10,10 @@ import { Note } from '../notes/note.entity'; @Entity() export class NoteGroupPermission { - @ManyToOne(_ => Group, { primary: true }) + @ManyToOne((_) => Group, { primary: true }) group: Group; - @ManyToOne( - _ => Note, - note => note.groupPermissions, - { primary: true }, - ) + @ManyToOne((_) => Note, (note) => note.groupPermissions, { primary: true }) note: Note; @Column() diff --git a/src/permissions/note-user-permission.entity.ts b/src/permissions/note-user-permission.entity.ts index bc77a01c7..62c96d9b9 100644 --- a/src/permissions/note-user-permission.entity.ts +++ b/src/permissions/note-user-permission.entity.ts @@ -10,14 +10,10 @@ import { User } from '../users/user.entity'; @Entity() export class NoteUserPermission { - @ManyToOne(_ => User, { primary: true }) + @ManyToOne((_) => User, { primary: true }) user: User; - @ManyToOne( - _ => Note, - note => note.userPermissions, - { primary: true }, - ) + @ManyToOne((_) => Note, (note) => note.userPermissions, { primary: true }) note: Note; @Column() diff --git a/src/revisions/authorship.entity.ts b/src/revisions/authorship.entity.ts index 23e658ec5..19772f320 100644 --- a/src/revisions/authorship.entity.ts +++ b/src/revisions/authorship.entity.ts @@ -27,16 +27,13 @@ export class Authorship { /** * Revisions this authorship appears in */ - @ManyToMany( - _ => Revision, - revision => revision.authorships, - ) + @ManyToMany((_) => Revision, (revision) => revision.authorships) revisions: Revision[]; /** * User this authorship represents */ - @ManyToOne(_ => User) + @ManyToOne((_) => User) user: User; @Column() diff --git a/src/revisions/revision.entity.ts b/src/revisions/revision.entity.ts index fafe618f9..e2c9e2f49 100644 --- a/src/revisions/revision.entity.ts +++ b/src/revisions/revision.entity.ts @@ -56,19 +56,12 @@ export class Revision { /** * Note this revision belongs to. */ - @ManyToOne( - _ => Note, - note => note.revisions, - { onDelete: 'CASCADE' }, - ) + @ManyToOne((_) => Note, (note) => note.revisions, { onDelete: 'CASCADE' }) note: Note; /** * All authorship objects which are used in the revision. */ - @ManyToMany( - _ => Authorship, - authorship => authorship.revisions, - ) + @ManyToMany((_) => Authorship, (authorship) => authorship.revisions) @JoinTable() authorships: Authorship[]; diff --git a/src/revisions/revisions.service.ts b/src/revisions/revisions.service.ts index ead829492..f3de1a0c2 100644 --- a/src/revisions/revisions.service.ts +++ b/src/revisions/revisions.service.ts @@ -33,7 +33,7 @@ export class RevisionsService { note: note.id, }, }); - return revisions.map(revision => this.toMetadataDto(revision)); + return revisions.map((revision) => this.toMetadataDto(revision)); } async getNoteRevision( diff --git a/src/users/auth-token.entity.ts b/src/users/auth-token.entity.ts index d237141ba..e445a014d 100644 --- a/src/users/auth-token.entity.ts +++ b/src/users/auth-token.entity.ts @@ -17,10 +17,7 @@ export class AuthToken { @PrimaryGeneratedColumn() id: number; - @ManyToOne( - _ => User, - user => user.authToken, - ) + @ManyToOne((_) => User, (user) => user.authToken) user: User; @Column() diff --git a/src/users/identity.entity.ts b/src/users/identity.entity.ts index 47638256c..73e2d8098 100644 --- a/src/users/identity.entity.ts +++ b/src/users/identity.entity.ts @@ -19,10 +19,7 @@ export class Identity { @PrimaryGeneratedColumn() id: number; - @ManyToOne( - _ => User, - user => user.identities, - ) + @ManyToOne((_) => User, (user) => user.identities) user: User; @Column() diff --git a/src/users/user.entity.ts b/src/users/user.entity.ts index 0381ce695..3b8762eeb 100644 --- a/src/users/user.entity.ts +++ b/src/users/user.entity.ts @@ -42,22 +42,13 @@ export class User { }) email?: string; - @OneToMany( - _ => Note, - note => note.owner, - ) + @OneToMany((_) => Note, (note) => note.owner) ownedNotes: Note[]; - @OneToMany( - _ => AuthToken, - authToken => authToken.user, - ) + @OneToMany((_) => AuthToken, (authToken) => authToken.user) authToken: AuthToken[]; - @OneToMany( - _ => Identity, - identity => identity.user, - ) + @OneToMany((_) => Identity, (identity) => identity.user) identities: Identity[]; // eslint-disable-next-line @typescript-eslint/no-empty-function diff --git a/test/public-api/notes.e2e-spec.ts b/test/public-api/notes.e2e-spec.ts index fe9aeb392..e308fccbb 100644 --- a/test/public-api/notes.e2e-spec.ts +++ b/test/public-api/notes.e2e-spec.ts @@ -84,9 +84,7 @@ describe('Notes', () => { it(`DELETE /notes/{note}`, async () => { await notesService.createNote('This is a test note.', 'test3'); - await request(app.getHttpServer()) - .delete('/notes/test3') - .expect(200); + await request(app.getHttpServer()).delete('/notes/test3').expect(200); return expect(notesService.getNoteByIdOrAlias('test3')).rejects.toEqual( new NotInDBError("Note with id/alias 'test3' not found."), ); diff --git a/yarn.lock b/yarn.lock index 18dcd5293..555b6bd06 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5530,10 +5530,10 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prettier@1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" + integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== pretty-format@^25.2.1, pretty-format@^25.5.0: version "25.5.0"