From 54648bd61752062e223ff5ab55815750f7ee191b Mon Sep 17 00:00:00 2001 From: Inga Date: Sun, 12 Jan 2025 19:29:07 +0000 Subject: [PATCH] strict tsc and linting configs --- service/.eslintrc.js | 11 ++++------- service/package-lock.json | 8 ++++++++ service/package.json | 1 + service/src/app.module.ts | 1 + service/src/main.ts | 4 ++-- service/test/app.e2e-spec.ts | 7 ++++--- service/tsconfig.json | 8 ++------ 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/service/.eslintrc.js b/service/.eslintrc.js index 259de13..93d0495 100644 --- a/service/.eslintrc.js +++ b/service/.eslintrc.js @@ -7,7 +7,9 @@ module.exports = { }, plugins: ['@typescript-eslint/eslint-plugin'], extends: [ - 'plugin:@typescript-eslint/recommended', + 'eslint:recommended', + 'plugin:@typescript-eslint/strict-type-checked', + 'plugin:@typescript-eslint/stylistic-type-checked', 'plugin:prettier/recommended', ], root: true, @@ -16,10 +18,5 @@ module.exports = { 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', - }, + rules: {}, }; diff --git a/service/package-lock.json b/service/package-lock.json index 360ea0f..3b6f8c5 100644 --- a/service/package-lock.json +++ b/service/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.5", "@types/express": "^5.0.0", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", @@ -1896,6 +1897,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@tsconfig/strictest": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@tsconfig/strictest/-/strictest-2.0.5.tgz", + "integrity": "sha512-ec4tjL2Rr0pkZ5hww65c+EEPYwxOi4Ryv+0MtjeaSQRJyq322Q27eOQiFbuNgw2hpL4hB1/W/HBGk3VKS43osg==", + "dev": true, + "license": "MIT" + }, "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/service/package.json b/service/package.json index 4816bcc..765104a 100644 --- a/service/package.json +++ b/service/package.json @@ -30,6 +30,7 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", + "@tsconfig/strictest": "^2.0.5", "@types/express": "^5.0.0", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", diff --git a/service/src/app.module.ts b/service/src/app.module.ts index 8662803..e0d67c3 100644 --- a/service/src/app.module.ts +++ b/service/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/service/src/main.ts b/service/src/main.ts index f76bc8d..3534114 100644 --- a/service/src/main.ts +++ b/service/src/main.ts @@ -3,6 +3,6 @@ import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); - await app.listen(process.env.PORT ?? 3000); + await app.listen(process.env['PORT'] ?? 3000); } -bootstrap(); +void bootstrap(); diff --git a/service/test/app.e2e-spec.ts b/service/test/app.e2e-spec.ts index 50cda62..3eba382 100644 --- a/service/test/app.e2e-spec.ts +++ b/service/test/app.e2e-spec.ts @@ -1,17 +1,18 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; +import request from 'supertest'; +import type { App } from 'supertest/types'; import { AppModule } from './../src/app.module'; describe('AppController (e2e)', () => { - let app: INestApplication; + let app: INestApplication; beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule], }).compile(); - app = moduleFixture.createNestApplication(); + app = moduleFixture.createNestApplication>(); await app.init(); }); diff --git a/service/tsconfig.json b/service/tsconfig.json index a1c778d..10aaf38 100644 --- a/service/tsconfig.json +++ b/service/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "@tsconfig/strictest", "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 } }