From a57e52b90922fe31a17b08db2a89d4078d8f378b Mon Sep 17 00:00:00 2001 From: Araozu Date: Fri, 5 May 2023 19:26:22 -0500 Subject: [PATCH] Eslint setup --- .eslintrc.js | 25 ------------ .eslintrc.yml | 83 ++++++++++++++++++++++++++++++++++++++ src/app.controller.spec.ts | 34 ++++++++-------- src/app.controller.ts | 12 +++--- src/app.module.ts | 12 +++--- src/app.service.ts | 9 +++-- src/main.ts | 8 ++-- 7 files changed, 121 insertions(+), 62 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 .eslintrc.yml diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 259de13..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - project: 'tsconfig.json', - tsconfigRootDir: __dirname, - sourceType: 'module', - }, - plugins: ['@typescript-eslint/eslint-plugin'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - root: true, - env: { - node: true, - jest: true, - }, - ignorePatterns: ['.eslintrc.js'], - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - }, -}; diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 0000000..8b2aa1e --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,83 @@ +env: + node: true + jest: true +extends: + - 'eslint:recommended' + - 'plugin:@typescript-eslint/recommended' +parser: '@typescript-eslint/parser' +parserOptions: + project: 'tsconfig.json' + sourceType: module +root: true +plugins: + - '@typescript-eslint' +rules: + "@typescript-eslint/ban-ts-comment": off + "@typescript-eslint/no-empty-function": off + indent: + - error + - 4 + - SwitchCase: 1 + linebreak-style: + - error + - unix + quotes: + - error + - double + semi: + - error + - always + no-multi-spaces: error + prefer-const: error + no-const-assign: error + no-var: error + array-callback-return: error + prefer-template: error + template-curly-spacing: error + no-useless-escape: error + wrap-iife: error + no-loop-func: error + default-param-last: error + space-before-function-paren: + - error + - never + space-before-blocks: error + no-param-reassign: error + function-paren-newline: error + comma-dangle: + - error + - always-multiline + arrow-spacing: error + arrow-parens: error + arrow-body-style: error + no-confusing-arrow: error + implicit-arrow-linebreak: error + no-duplicate-imports: error + object-curly-newline: error + dot-notation: error + one-var: + - error + - never + no-multi-assign: error + no-plusplus: error + operator-linebreak: error + eqeqeq: error + no-case-declarations: error + no-nested-ternary: error + no-unneeded-ternary: error + no-mixed-operators: error + nonblock-statement-body-position: error + brace-style: error + keyword-spacing: error + space-infix-ops: error + eol-last: error + newline-per-chained-call: error + no-whitespace-before-property: error + space-in-parens: error + array-bracket-spacing: error + key-spacing: error + no-trailing-spaces: error + comma-style: error + radix: error + no-new-wrappers: error + diff --git a/src/app.controller.spec.ts b/src/app.controller.spec.ts index d22f389..1f2a031 100644 --- a/src/app.controller.spec.ts +++ b/src/app.controller.spec.ts @@ -1,22 +1,22 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; +import { Test, TestingModule } from "@nestjs/testing"; +import { AppController } from "./app.controller"; +import { AppService } from "./app.service"; -describe('AppController', () => { - let appController: AppController; +describe("AppController", () => { + let appController: AppController; - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); + beforeEach(async() => { + const app: TestingModule = await Test.createTestingModule({ + controllers: [AppController], + providers: [AppService], + }).compile(); - appController = app.get(AppController); - }); - - describe('root', () => { - it('should return "Hello World!"', () => { - expect(appController.getHello()).toBe('Hello World!'); + appController = app.get(AppController); + }); + + describe("root", () => { + it("should return \"Hello World!\"", () => { + expect(appController.getHello()).toBe("Hello World!"); + }); }); - }); }); diff --git a/src/app.controller.ts b/src/app.controller.ts index cce879e..da4d636 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -1,12 +1,12 @@ -import { Controller, Get } from '@nestjs/common'; -import { AppService } from './app.service'; +import { Controller, Get } from "@nestjs/common"; +import { AppService } from "./app.service"; @Controller() export class AppController { - constructor(private readonly appService: AppService) {} + constructor(private readonly appService: AppService) {} @Get() - getHello(): string { - return this.appService.getHello(); - } + getHello(): string { + return this.appService.getHello(); + } } diff --git a/src/app.module.ts b/src/app.module.ts index 8662803..c008238 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,10 +1,10 @@ -import { Module } from '@nestjs/common'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; +import { Module } from "@nestjs/common"; +import { AppController } from "./app.controller"; +import { AppService } from "./app.service"; @Module({ - imports: [], - controllers: [AppController], - providers: [AppService], + imports: [], + controllers: [AppController], + providers: [AppService], }) export class AppModule {} diff --git a/src/app.service.ts b/src/app.service.ts index 927d7cc..918eb75 100644 --- a/src/app.service.ts +++ b/src/app.service.ts @@ -1,8 +1,9 @@ -import { Injectable } from '@nestjs/common'; +import { Injectable } from "@nestjs/common"; @Injectable() export class AppService { - getHello(): string { - return 'Hello World!'; - } + getHello(): string { + return "Hello World!"; + } } + diff --git a/src/main.ts b/src/main.ts index 13cad38..0a78d77 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,8 @@ -import { NestFactory } from '@nestjs/core'; -import { AppModule } from './app.module'; +import { NestFactory } from "@nestjs/core"; +import { AppModule } from "./app.module"; async function bootstrap() { - const app = await NestFactory.create(AppModule); - await app.listen(3000); + const app = await NestFactory.create(AppModule); + await app.listen(3000); } bootstrap();