mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	chore(docs): contributing (#1311)
* chore(server): linting * chore: contributing pr checklist
This commit is contained in:
		
							
								
								
									
										43
									
								
								docs/docs/developer/contributing.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								docs/docs/developer/contributing.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| --- | ||||
| sidebar_position: 3 | ||||
| --- | ||||
|  | ||||
| # Contributing | ||||
|  | ||||
| Contributions are welcome! | ||||
|  | ||||
| ## PR Checklist | ||||
|  | ||||
| When contributing code through a pull request, please check the following: | ||||
|  | ||||
| ### Web Checks | ||||
|  | ||||
| - [ ] `npm run lint` (linting via ESLint) | ||||
| - [ ] `npm run format` (formatting via Prettier) | ||||
| - [ ] `npm run check` (Type checking via SvelteKit) | ||||
| - [ ] `npm test` (Tests via Jest) | ||||
|  | ||||
| :::tip | ||||
| Run all web checks with `npm run check:all` | ||||
| ::: | ||||
|  | ||||
| ### Server Checks | ||||
|  | ||||
| - [ ] `npm run lint` (linting via ESLint) | ||||
| - [ ] `npm run format` (formatting via Prettier) | ||||
| - [ ] `npm run check` (Type checking via `tsc`) | ||||
| - [ ] `npm test` (Tests via Jest) | ||||
|  | ||||
| :::tip | ||||
| Run all server checks with `npm run check:all` | ||||
| ::: | ||||
|  | ||||
| ### Open API | ||||
|  | ||||
| The Open API client libraries need to be regenerated whenever there are changes to the `immich-openapi-specs.json` file. | ||||
|  | ||||
| - [ ] `npm run api:generate` | ||||
|  | ||||
| :::tip | ||||
| This can also be run via `make api` from the project root directory (not in the `server` folder) | ||||
| ::: | ||||
| @@ -6,10 +6,7 @@ module.exports = { | ||||
|     tsconfigRootDir: __dirname, | ||||
|   }, | ||||
|   plugins: ['@typescript-eslint/eslint-plugin'], | ||||
|   extends: [ | ||||
|     'plugin:@typescript-eslint/recommended', | ||||
|     'plugin:prettier/recommended', | ||||
|   ], | ||||
|   extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'], | ||||
|   root: true, | ||||
|   env: { | ||||
|     node: true, | ||||
|   | ||||
							
								
								
									
										18
									
								
								server/.prettierignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								server/.prettierignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| .DS_Store | ||||
| node_modules | ||||
| /build | ||||
| /package | ||||
| .env | ||||
| .env.* | ||||
| !.env.example | ||||
| src/api/open-api | ||||
| *.md | ||||
| *.json | ||||
| coverage | ||||
| dist | ||||
| **/migrations/** | ||||
|  | ||||
| # Ignore files for PNPM, NPM and YARN | ||||
| pnpm-lock.yaml | ||||
| package-lock.json | ||||
| yarn.lock | ||||
| @@ -1,13 +1,13 @@ | ||||
| import {ApiProperty} from "@nestjs/swagger"; | ||||
| import {AlbumResponseDto} from "./album-response.dto"; | ||||
| import { ApiProperty } from '@nestjs/swagger'; | ||||
| import { AlbumResponseDto } from './album-response.dto'; | ||||
|  | ||||
| export class AddAssetsResponseDto { | ||||
|     @ApiProperty({ type: 'integer' }) | ||||
|     successfullyAdded!: number; | ||||
|   @ApiProperty({ type: 'integer' }) | ||||
|   successfullyAdded!: number; | ||||
|  | ||||
|     @ApiProperty() | ||||
|     alreadyInAlbum!: string[]; | ||||
|   @ApiProperty() | ||||
|   alreadyInAlbum!: string[]; | ||||
|  | ||||
|     @ApiProperty() | ||||
|     album?: AlbumResponseDto; | ||||
| } | ||||
|   @ApiProperty() | ||||
|   album?: AlbumResponseDto; | ||||
| } | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| export class CheckExistingAssetsResponseDto { | ||||
|     constructor(existingIds: string[]) { | ||||
|       this.existingIds = existingIds; | ||||
|     } | ||||
|     existingIds: string[]; | ||||
|   constructor(existingIds: string[]) { | ||||
|     this.existingIds = existingIds; | ||||
|   } | ||||
|    | ||||
|   existingIds: string[]; | ||||
| } | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import { UpdateTagDto } from './dto/update-tag.dto'; | ||||
| import { Authenticated } from '../../decorators/authenticated.decorator'; | ||||
| import { ApiTags } from '@nestjs/swagger'; | ||||
| import { AuthUserDto, GetAuthUser } from '../../decorators/auth-user.decorator'; | ||||
| import { mapTag, TagResponseDto } from "./response-dto/tag-response.dto"; | ||||
| import { mapTag, TagResponseDto } from './response-dto/tag-response.dto'; | ||||
|  | ||||
| @Authenticated() | ||||
| @ApiTags('Tag') | ||||
| @@ -14,7 +14,10 @@ export class TagController { | ||||
|   constructor(private readonly tagService: TagService) {} | ||||
|  | ||||
|   @Post() | ||||
|   create(@GetAuthUser() authUser: AuthUserDto, @Body(ValidationPipe) createTagDto: CreateTagDto): Promise<TagResponseDto> { | ||||
|   create( | ||||
|     @GetAuthUser() authUser: AuthUserDto, | ||||
|     @Body(ValidationPipe) createTagDto: CreateTagDto, | ||||
|   ): Promise<TagResponseDto> { | ||||
|     return this.tagService.create(authUser, createTagDto); | ||||
|   } | ||||
|  | ||||
| @@ -34,7 +37,7 @@ export class TagController { | ||||
|     @GetAuthUser() authUser: AuthUserDto, | ||||
|     @Param('id') id: string, | ||||
|     @Body(ValidationPipe) updateTagDto: UpdateTagDto, | ||||
|   ): Promise<TagResponseDto>  { | ||||
|   ): Promise<TagResponseDto> { | ||||
|     return this.tagService.update(authUser, id, updateTagDto); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -9,17 +9,16 @@ export const HumanReadableSize = { KiB, MiB, GiB, TiB, PiB }; | ||||
| export function asHumanReadable(bytes: number, precision = 1): string { | ||||
|   const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB']; | ||||
|  | ||||
| 	let magnitude = 0; | ||||
| 	let remainder = bytes; | ||||
| 	while (remainder >= 1024) { | ||||
| 		if (magnitude + 1 < units.length) { | ||||
| 			magnitude++; | ||||
| 			remainder /= 1024; | ||||
| 		} | ||||
| 		else { | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
|   let magnitude = 0; | ||||
|   let remainder = bytes; | ||||
|   while (remainder >= 1024) { | ||||
|     if (magnitude + 1 < units.length) { | ||||
|       magnitude++; | ||||
|       remainder /= 1024; | ||||
|     } else { | ||||
|       break; | ||||
|     } | ||||
|   } | ||||
|  | ||||
| 	return `${remainder.toFixed( magnitude == 0 ? 0 : precision )} ${units[magnitude]}`; | ||||
|   return `${remainder.toFixed(magnitude == 0 ? 0 : precision)} ${units[magnitude]}`; | ||||
| } | ||||
|   | ||||
| @@ -11,7 +11,8 @@ | ||||
|   "scripts": { | ||||
|     "prebuild": "rimraf dist", | ||||
|     "build": "nest build immich && nest build microservices && nest build cli", | ||||
|     "format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"", | ||||
|     "format": "prettier --check .", | ||||
|     "format:fix": "prettier --write .", | ||||
|     "start": "nest start", | ||||
|     "nest": "nest", | ||||
|     "start:dev": "nest start --watch", | ||||
| @@ -19,8 +20,9 @@ | ||||
|     "start:prod": "node dist/main", | ||||
|     "lint": "eslint \"{apps,libs}/**/*.ts\" --max-warnings 0", | ||||
|     "lint:fix": "npm run lint -- --fix", | ||||
|     "check:types": "tsc --noEmit", | ||||
|     "check:all": "npm run lint && npm run check:types && npm run test", | ||||
|     "check": "tsc --noEmit", | ||||
|     "check:code": "npm run format && npm run lint && npm run check", | ||||
|     "check:all": "npm run check:code && npm run test", | ||||
|     "test": "jest", | ||||
|     "test:watch": "jest --watch", | ||||
|     "test:cov": "jest --coverage", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user