From 909720a11d353a4120e48ac6a933985b5608e6e8 Mon Sep 17 00:00:00 2001 From: Inga <52715130+inga-lovinde@users.noreply.github.com> Date: Sat, 9 Dec 2023 01:26:14 +0000 Subject: [PATCH] use stricter tsconfig and eslint config --- .eslintrc.js | 6 +++--- package-lock.json | 7 +++++++ package.json | 3 ++- src/app.module.ts | 1 + src/main.ts | 2 +- test/app.e2e-spec.ts | 2 +- tsconfig.json | 8 ++------ 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 259de13..c417de3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,7 +7,8 @@ module.exports = { }, plugins: ['@typescript-eslint/eslint-plugin'], extends: [ - 'plugin:@typescript-eslint/recommended', + 'eslint:recommended', + 'plugin:@typescript-eslint/strict-type-checked', 'plugin:prettier/recommended', ], root: true, @@ -19,7 +20,6 @@ module.exports = { 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', + '@typescript-eslint/explicit-module-boundary-types': 'off' }, }; diff --git a/package-lock.json b/package-lock.json index edb6c14..f3bbed1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", + "@tsconfig/strictest": "^2.0.2", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", @@ -1851,6 +1852,12 @@ "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", "dev": true }, + "node_modules/@tsconfig/strictest": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.2.tgz", + "integrity": "sha512-jt4jIsWKvUvuY6adJnQJlb/UR7DdjC8CjHI/OaSQruj2yX9/K6+KOvDt/vD6udqos/FUk5Op66CvYT7TBLYO5Q==", + "dev": true + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", diff --git a/package.json b/package.json index cbd0258..4498fb2 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\"", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", @@ -30,6 +30,7 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", + "@tsconfig/strictest": "^2.0.2", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", diff --git a/src/app.module.ts b/src/app.module.ts index 8662803..e0d67c3 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -7,4 +7,5 @@ import { AppService } from './app.service'; controllers: [AppController], providers: [AppService], }) +// eslint-disable-next-line @typescript-eslint/no-extraneous-class export class AppModule {} diff --git a/src/main.ts b/src/main.ts index 13cad38..23f3240 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,4 +5,4 @@ async function bootstrap() { const app = await NestFactory.create(AppModule); await app.listen(3000); } -bootstrap(); +void bootstrap(); diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts index 50cda62..9ceebc4 100644 --- a/test/app.e2e-spec.ts +++ b/test/app.e2e-spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; +import request from 'supertest'; import { AppModule } from './../src/app.module'; describe('AppController (e2e)', () => { diff --git a/tsconfig.json b/tsconfig.json index a1c778d..044f304 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "@tsconfig/strictest/tsconfig.json", "compilerOptions": { "module": "commonjs", "declaration": true, @@ -11,11 +12,6 @@ "outDir": "./dist", "baseUrl": "./", "incremental": true, - "skipLibCheck": true, - "strictNullChecks": true, - "noImplicitAny": true, - "strictBindCallApply": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true + "skipLibCheck": true } }