diff --git a/eslint.config.mjs b/eslint.config.mjs index e877cc6..0d6263f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -5,177 +5,184 @@ import pluginJs from "@eslint/js"; import typescriptEslint from "typescript-eslint"; import tsParser from "@typescript-eslint/parser"; import cspellPlugin from "@cspell/eslint-plugin"; +import importOrderPlugin from "eslint-plugin-import"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -export default typescriptEslint.config( - { - files: ["**/*.{js,mjs,cjs,ts}"], - languageOptions: { - globals: { - ...globals.node, - }, - parser: tsParser, - ecmaVersion: 2020, - parserOptions: { - project: "tsconfig.json", - tsconfigRootDir: __dirname, - sourceType: "module", - }, - }, - settings: { - node: { - allow: ["process", "Buffer"], - }, - }, - ignores: [ - "dist", - "node_modules", - "eslint.config.js", - "vitest.config.ts", - "commitlint.config.ts", - ], - plugins: { - "@cspell": cspellPlugin, - }, - extends: [pluginJs.configs.recommended, ...typescriptEslint.configs.recommended], - rules: { - "no-duplicate-imports": "error", - "@typescript-eslint/triple-slash-reference": "off", - "@typescript-eslint/interface-name-prefix": "off", - "@typescript-eslint/no-explicit-any": "error", - "@typescript-eslint/no-inferrable-types": "off", - "@typescript-eslint/ban-types": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/adjacent-overload-signatures": "error", - "@typescript-eslint/await-thenable": "error", - "@typescript-eslint/ban-ts-comment": "error", - "@typescript-eslint/ban-tslint-comment": "error", - "@typescript-eslint/class-literal-property-style": "error", - "@typescript-eslint/consistent-generic-constructors": "error", - "@typescript-eslint/consistent-indexed-object-style": "error", - "@typescript-eslint/consistent-type-assertions": [ - "error", - { - assertionStyle: "as", - }, - ], - "@typescript-eslint/consistent-type-definitions": ["error", "interface"], - "@typescript-eslint/consistent-type-exports": "error", - "@typescript-eslint/consistent-type-imports": [ - "error", - { - prefer: "type-imports", - }, - ], - "@typescript-eslint/explicit-function-return-type": "error", - "@typescript-eslint/explicit-member-accessibility": "error", - "@typescript-eslint/explicit-module-boundary-types": "error", - "@typescript-eslint/method-signature-style": "error", - "@typescript-eslint/no-confusing-non-null-assertion": "error", - "@typescript-eslint/no-duplicate-enum-values": "error", - "@typescript-eslint/no-duplicate-type-constituents": "error", - "@typescript-eslint/no-extra-non-null-assertion": "error", - "@typescript-eslint/no-extraneous-class": "off", - "@typescript-eslint/no-for-in-array": "error", - "@typescript-eslint/no-import-type-side-effects": "error", - "@typescript-eslint/no-require-imports": "error", - "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", - "@typescript-eslint/no-unnecessary-condition": "off", - "@typescript-eslint/no-unnecessary-type-assertion": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/prefer-reduce-type-parameter": "error", - "@typescript-eslint/prefer-string-starts-ends-with": "error", - "@typescript-eslint/restrict-template-expressions": "off", - "@typescript-eslint/prefer-readonly": "error", - "no-return-await": "off", - "@typescript-eslint/return-await": "error", - "@typescript-eslint/no-misused-promises": "off", - "@typescript-eslint/no-unbound-method": ["off", { "ignore-static": true }], - "@typescript-eslint/unbound-method": ["off"], - "@typescript-eslint/no-floating-promises": "off", - eqeqeq: ["error", "always"], - "no-console": "error", - "@typescript-eslint/unified-signatures": "off", - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": [ - "warn", - { - argsIgnorePattern: "^_", - varsIgnorePattern: "^_", - caughtErrorsIgnorePattern: "^_", - }, - ], - "@typescript-eslint/naming-convention": [ - "error", - { - selector: "default", - format: ["camelCase"], - }, - { - selector: "variable", - format: ["camelCase", "UPPER_CASE", "PascalCase"], - leadingUnderscore: "allow", - }, - { - selector: "parameter", - format: ["camelCase"], - leadingUnderscore: "allow", - }, - { - selector: "memberLike", - modifiers: ["private"], - format: ["camelCase", "UPPER_CASE", "snake_case"], - leadingUnderscore: "allow", - }, - { - selector: "memberLike", - modifiers: ["public"], - format: ["camelCase", "UPPER_CASE", "snake_case"], - }, - { - selector: "typeLike", - format: ["PascalCase"], - }, - { - selector: "enumMember", - format: ["UPPER_CASE"], - }, - { - selector: "objectLiteralMethod", - format: ["camelCase", "PascalCase"], - }, - { - selector: "objectLiteralProperty", - format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"], - leadingUnderscore: "allow", - }, - { - selector: "typeProperty", - format: ["camelCase", "UPPER_CASE", "snake_case"], - leadingUnderscore: "allow", - }, - ], +export default typescriptEslint.config({ + files: ["**/*.{js,mjs,cjs,ts}"], + languageOptions: { + globals: { + ...globals.node, + }, + parser: tsParser, + ecmaVersion: 2020, + parserOptions: { + project: "tsconfig.json", + tsconfigRootDir: __dirname, + sourceType: "module", + }, + }, + settings: { + node: { + allow: ["process", "Buffer"], + }, + }, + ignores: [ + "dist/", + "node_modules", + "vitest.config.ts", + "commitlint.config.ts", + "*.mjs", + "**/.husky/*", + ], + plugins: { + import: importOrderPlugin, + "@cspell": cspellPlugin, + }, + extends: [pluginJs.configs.recommended, ...typescriptEslint.configs.recommended], + rules: { + "no-duplicate-imports": "error", + "import/order": [ + "error", + { + groups: [["builtin", "external", "internal", "parent", "sibling"], ["type"]], + }, + ], + "@typescript-eslint/triple-slash-reference": "off", + "@typescript-eslint/interface-name-prefix": "off", + "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/ban-types": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/adjacent-overload-signatures": "error", + "@typescript-eslint/await-thenable": "error", + "@typescript-eslint/ban-ts-comment": "error", + "@typescript-eslint/ban-tslint-comment": "error", + "@typescript-eslint/class-literal-property-style": "error", + "@typescript-eslint/consistent-generic-constructors": "error", + "@typescript-eslint/consistent-indexed-object-style": "error", + "@typescript-eslint/consistent-type-assertions": [ + "error", + { + assertionStyle: "as", + }, + ], + "@typescript-eslint/consistent-type-definitions": ["error", "interface"], + "@typescript-eslint/consistent-type-exports": "error", + "@typescript-eslint/consistent-type-imports": [ + "error", + { + prefer: "type-imports", + }, + ], + "@typescript-eslint/explicit-function-return-type": "error", + "@typescript-eslint/explicit-member-accessibility": "error", + "@typescript-eslint/explicit-module-boundary-types": "error", + "@typescript-eslint/method-signature-style": "error", + "@typescript-eslint/no-confusing-non-null-assertion": "error", + "@typescript-eslint/no-duplicate-enum-values": "error", + "@typescript-eslint/no-duplicate-type-constituents": "error", + "@typescript-eslint/no-extra-non-null-assertion": "error", + "@typescript-eslint/no-extraneous-class": "off", + "@typescript-eslint/no-for-in-array": "error", + "@typescript-eslint/no-import-type-side-effects": "error", + "@typescript-eslint/no-require-imports": "error", + "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", + "@typescript-eslint/no-unnecessary-condition": "off", + "@typescript-eslint/no-unnecessary-type-assertion": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/prefer-reduce-type-parameter": "error", + "@typescript-eslint/prefer-string-starts-ends-with": "error", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/prefer-readonly": "error", + "no-return-await": "off", + "@typescript-eslint/return-await": "error", + "@typescript-eslint/no-misused-promises": "off", + "@typescript-eslint/no-unbound-method": ["off", { "ignore-static": true }], + "@typescript-eslint/unbound-method": ["off"], + "@typescript-eslint/no-floating-promises": "off", + eqeqeq: ["error", "always"], + "no-console": "error", + "@typescript-eslint/unified-signatures": "off", + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "warn", + { + argsIgnorePattern: "^_", + varsIgnorePattern: "^_", + caughtErrorsIgnorePattern: "^_", + }, + ], + "@typescript-eslint/naming-convention": [ + "error", + { + selector: "default", + format: ["camelCase"], + }, + { + selector: "variable", + format: ["camelCase", "UPPER_CASE", "PascalCase"], + leadingUnderscore: "allow", + }, + { + selector: "parameter", + format: ["camelCase"], + leadingUnderscore: "allow", + }, + { + selector: "memberLike", + modifiers: ["private"], + format: ["camelCase", "UPPER_CASE", "snake_case"], + leadingUnderscore: "allow", + }, + { + selector: "memberLike", + modifiers: ["public"], + format: ["camelCase", "UPPER_CASE", "snake_case"], + }, + { + selector: "typeLike", + format: ["PascalCase"], + }, + { + selector: "enumMember", + format: ["UPPER_CASE"], + }, + { + selector: "objectLiteralMethod", + format: ["camelCase", "PascalCase"], + }, + { + selector: "objectLiteralProperty", + format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"], + leadingUnderscore: "allow", + }, + { + selector: "typeProperty", + format: ["camelCase", "UPPER_CASE", "snake_case"], + leadingUnderscore: "allow", + }, + ], - "@cspell/spellchecker": [ - "warn", - { - autoFix: true, - numSuggestions: 5, - generateSuggestions: true, - checkComments: true, - checkIdentifiers: true, - checkStrings: true, - checkStringTemplates: true, - cspell: { - import: ["./cspell.json"], - }, - cspellOptionsRoot: import.meta.url, - }, - ], + "@cspell/spellchecker": [ + "warn", + { + autoFix: true, + numSuggestions: 5, + generateSuggestions: true, + checkComments: true, + checkIdentifiers: true, + checkStrings: true, + checkStringTemplates: true, + cspell: { + import: ["./cspell.json"], }, - }, -); \ No newline at end of file + cspellOptionsRoot: import.meta.url, + }, + ], + }, +}); diff --git a/package.json b/package.json index 956f5a0..d901d97 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,10 @@ "@swc/core": "^1.7.26", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", + "eslint-plugin-import": "2.31.0", "globals": "^15.11.0", + "http-status": "2.0.0", + "http-status-codes": "2.3.0", "nest-winston": "^1.9.7", "npm-run-all": "4.1.5", "reflect-metadata": "^0.2.0", diff --git a/src/health/controllers/health.controller.ts b/src/health/controllers/health.controller.ts index abe0ddc..6297939 100644 --- a/src/health/controllers/health.controller.ts +++ b/src/health/controllers/health.controller.ts @@ -1,7 +1,7 @@ import { Controller, Get, Inject } from "@nestjs/common"; -import { HEALTH_ENDPOINT, HEALTH_SERVICE } from "../constants"; import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; -import { IHealthMessage } from "../interfaces/health-message.interface"; +import { HEALTH_ENDPOINT, HEALTH_SERVICE } from "../constants"; +import type { IHealthMessage } from "../interfaces/health-message.interface"; @ApiTags("Health") @Controller(HEALTH_ENDPOINT) diff --git a/tsconfig.build.json b/tsconfig.build.json index 64f86c6..84e4a53 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] + "exclude": ["node_modules", "test", "dist", "*.mjs", "**/*spec.ts"] } diff --git a/tsconfig.json b/tsconfig.json index 474e694..26a50aa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,5 +25,5 @@ "@modules/*": ["src/modules/*"], } }, - "exclude": ["node_modules", "dist"] + "exclude": ["node_modules", "dist", "*.mjs"] }