From b72721dc69c66c13c33be1d2ce2c4514e95122e7 Mon Sep 17 00:00:00 2001 From: mifi Date: Wed, 24 May 2023 10:46:41 -0400 Subject: [PATCH] Prettier! --- .eslintrc.js | 19 +++++++++++++++++++ .npmignore | 11 ++++++----- .prettierrc.js | 7 +++++++ src/domain/errors/ApiError.ts | 12 ++++++------ src/domain/errors/DatabaseError.ts | 12 ++++++------ src/domain/errors/ServiceError.ts | 16 ++++++++-------- src/types/ApiResponse.ts | 8 ++++---- src/types/Payload.ts | 2 +- 8 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .prettierrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..36bacbc --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,19 @@ +/* eslint-env node */ +module.exports = { + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:import/errors', + 'plugin:prettier/recommended', + 'prettier', + ], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + settings: { + 'import/parsers': { + '@typescript-eslint/parser': ['.ts', '.tsx'], + }, + 'import/resolver': 'typescript', + }, + root: true, +}; diff --git a/.npmignore b/.npmignore index bcade60..bfecfd5 100644 --- a/.npmignore +++ b/.npmignore @@ -1,8 +1,9 @@ +.build.yarnrc.yml +.drone.yml +.prettierrc +.yarnrc.yml +babel.config.* +jest.config.* src tsconfig.json tslint.json -.prettierrc -.yarnrc.yml -.drone.yml -babel.config.* -jest.config.* \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..f0c3079 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + parser: 'typescript', + printWidth: 120, + trailingComma: 'all', + tabWidth: 4, + singleQuote: true, +}; diff --git a/src/domain/errors/ApiError.ts b/src/domain/errors/ApiError.ts index 53b21e7..940dbf0 100644 --- a/src/domain/errors/ApiError.ts +++ b/src/domain/errors/ApiError.ts @@ -1,9 +1,9 @@ -import { Payload } from "../../types/Payload"; -import { ServiceError } from "./ServiceError"; +import { Payload } from '../../types/Payload'; +import { ServiceError } from './ServiceError'; export class ApiError extends ServiceError { - constructor(message: string, debug?: Payload) { - super(message, debug); - this.name = "ApiError"; - } + constructor(message: string, debug?: Payload) { + super(message, debug); + this.name = 'ApiError'; + } } diff --git a/src/domain/errors/DatabaseError.ts b/src/domain/errors/DatabaseError.ts index 8f6b191..3f22e8d 100644 --- a/src/domain/errors/DatabaseError.ts +++ b/src/domain/errors/DatabaseError.ts @@ -1,9 +1,9 @@ -import { Payload } from "../../types/Payload"; -import { ServiceError } from "./ServiceError"; +import { Payload } from '../../types/Payload'; +import { ServiceError } from './ServiceError'; export class DatabaseError extends ServiceError { - constructor(message: string, debug?: Payload) { - super(message, debug); - this.name = "DatabaseError"; - } + constructor(message: string, debug?: Payload) { + super(message, debug); + this.name = 'DatabaseError'; + } } diff --git a/src/domain/errors/ServiceError.ts b/src/domain/errors/ServiceError.ts index 068e6b8..8b1d4c9 100644 --- a/src/domain/errors/ServiceError.ts +++ b/src/domain/errors/ServiceError.ts @@ -1,12 +1,12 @@ -import { Payload } from "../../types/Payload"; +import { Payload } from '../../types/Payload'; export class ServiceError extends Error { - public env = process.env; - public debug?: Payload; + public env = process.env; + public debug?: Payload; - constructor(message: string, debug?: Payload) { - super(message); - this.name = "ServiceError"; - this.debug = debug; - } + constructor(message: string, debug?: Payload) { + super(message); + this.name = 'ServiceError'; + this.debug = debug; + } } diff --git a/src/types/ApiResponse.ts b/src/types/ApiResponse.ts index d140ebd..5593bad 100644 --- a/src/types/ApiResponse.ts +++ b/src/types/ApiResponse.ts @@ -1,7 +1,7 @@ -import { Payload } from "./Payload"; +import { Payload } from './Payload'; export interface ApiResponse { - data?: T; - error?: Error | string | number; - success: boolean; + data?: T; + error?: Error | string | number; + success: boolean; } diff --git a/src/types/Payload.ts b/src/types/Payload.ts index 2d3f521..ddf1888 100644 --- a/src/types/Payload.ts +++ b/src/types/Payload.ts @@ -3,5 +3,5 @@ type PayloadArray = (PayloadPrimitives | Payload)[]; type PayloadValid = PayloadPrimitives | PayloadArray | Payload; export interface Payload { - [key: string]: PayloadValid | T; + [key: string]: PayloadValid | T; }