UNPKG

@addon24/eslint-config

Version:

ESLint configuration rules for WorldOfTextcraft projects - Centralized configuration for all project types

795 lines (773 loc) 37.8 kB
/** * Backend ESLint Configuration * * Ursprüngliche Backend-Konfiguration - 1:1 übernommen * Enthält alle Backend-spezifischen Regeln und benutzerdefinierten Regeln */ import stylisticPlugin from "@stylistic/eslint-plugin"; import typescriptEslint from "@typescript-eslint/eslint-plugin"; import typescriptParser from "@typescript-eslint/parser"; import deprecatePlugin from "eslint-plugin-deprecate"; import importPlugin from "eslint-plugin-import"; import jestPlugin from "eslint-plugin-jest"; import perfectionist from "eslint-plugin-perfectionist"; import sonarjsPlugin from "eslint-plugin-sonarjs"; import globals from "globals"; import path from "path"; // Importiere alle ursprünglichen Regeldateien import adminControllerSecurityRules from '../rules/admin-controller-security.js'; import analyzeRelationUsageRule from '../rules/analyze-relation-usage.js'; import authGuardRequiredRule from '../rules/auth-guard-required.js'; import bestPracticesRules from '../rules/best-practices.js'; import controllerArchitectureRules from '../rules/controller-architecture.js'; import controllerNamingConventionsRule from '../rules/controller-naming-conventions.js'; import controllerReadonlyRestrictionRules from '../rules/controller-readonly-restriction.js'; import controllerSwaggerCompleteRule from '../rules/controller-swagger-complete.js'; import controllerSwaggerDocsRule from '../rules/controller-swagger-docs.js'; import controllerSwaggerEnglishRule from '../rules/controller-swagger-english.js'; import coordinateNamingRule from '../rules/coordinate-naming.js'; import deadCodeDetectionRules from '../rules/dead-code-detection-backend.js'; import deprecatedRules from '../rules/deprecate.js'; import dtoAnnotationPropertyConsistencyRule from '../rules/dto-annotation-property-consistency.js'; import dtoEntityMappingCompletenessRule from '../rules/dto-entity-mapping-completeness.js'; import dtoEntitySwaggerSeparationRule from '../rules/dto-entity-swagger-separation.js'; import dtoEntityTypeConsistencyRule from '../rules/dto-entity-type-consistency.js'; import dtoEntityTypeMatchingRule from '../rules/dto-entity-type-matching.js'; import dtoVisibilityModifiersRule from '../rules/dto-visibility-modifiers.js'; import enforceApiVersioning from '../rules/enforce-api-versioning.js'; import enforceAppModuleRegistration from '../rules/enforce-app-module-registration.js'; import enforceBaseControllerRule from '../rules/enforce-basecontroller.js'; import enforceBodyRequestDtoRule from '../rules/enforce-body-request-dto.js'; import enforceControllerResponseDtoRule from '../rules/enforce-controller-response-dto.js'; import enforceCustomErrorClassesRule from '../rules/enforce-custom-error-classes.js'; import enforceDtoConstructorRule from '../rules/enforce-dto-constructor.js'; import enforceDtoCreateParameterTypesRule from '../rules/enforce-dto-create-parameter-types.js'; import enforceDtoCreatePatternRule from '../rules/enforce-dto-create-pattern.js'; import enforceDtoEntityCreationRule from '../rules/enforce-dto-entity-creation.js'; import enforceDtoFromEntity from '../rules/enforce-dto-from-entity.js'; import enforceDtoNamingConventions from '../rules/enforce-dto-naming-conventions.js'; import enforceDtoNamingRule from '../rules/enforce-dto-naming.js'; import enforceDtoUsageRule from '../rules/enforce-dto-usage.js'; import enforceEagerTranslationLoadingRule from '../rules/enforce-eager-translation-loading.js'; import enforceEntityCreationPatternRule from '../rules/enforce-entity-creation-pattern.js'; import enforceEntityDtoConvertMethodRule from '../rules/enforce-entity-dto-convert-method.js'; import enforceEntityDtoExtendsBaseRule from '../rules/enforce-entity-dto-extends-base.js'; import enforceEntityDtoFromEntity from '../rules/enforce-entity-dto-fromentity.js'; import enforceEntityDtoNoRequestDto from '../rules/enforce-entity-dto-no-request-dto.js'; import enforceEntityDtoToEntityRule from '../rules/enforce-entity-dto-toentity.js'; import enforceEntityFactoryPatternRule from '../rules/enforce-entity-factory-pattern.js'; import enforceEnumForPlayableEntitiesRule from '../rules/enforce-enum-for-playable-entities.js'; import enforceErrorHandling from '../rules/enforce-error-handling.js'; import enforceExplicitDtoTypesRule from '../rules/enforce-explicit-dto-types.js'; import enforceInjectDecoratorRule from '../rules/enforce-inject-decorator.js'; import enforceLazyTypeLoadingRule from '../rules/enforce-lazy-type-loading.js'; import enforceModuleExistenceRule from '../rules/enforce-module-existence.js'; import enforceNonEntityDtoCreate from '../rules/enforce-nonentity-dto-create.js'; import enforcePlayableEntityNamingRule from '../rules/enforce-playable-entity-naming.js'; import enforceRepositoryTokenHandlingRule from '../rules/enforce-repository-token-handling.js'; import enforceRequestDtoNoEntityDtoRule from '../rules/enforce-request-dto-no-entity-dto.js'; import enforceResultPattern from '../rules/enforce-result-pattern.js'; import enforceTypeormNamingConventionsRule from '../rules/enforce-typeorm-naming-conventions.js'; import entityRequiredPropertiesRule from '../rules/entity-required-properties.js'; import enumDatabaseValidationRule from '../rules/enum-database-validation.js'; import errorRules from '../rules/errors.js'; import es6Rules from '../rules/es6.js'; import noCommentsPlugin from '../rules/eslint-plugin-no-comments.js'; import filenameClassNameMatchRule from '../rules/filename-class-name-match.js'; import forbidFromEntityOutsideEntityFolderRule from '../rules/forbid-fromentity-outside-entity-folder.js'; import importRules from '../rules/imports.js'; import jestRules from '../rules/jest.js'; import maxClassesPerFileRule from '../rules/max-classes-per-file.js'; import noBlankLinesBetweenDecoratorsAndPropertiesRule from '../rules/no-blank-lines-between-decorators-and-properties.js'; import noDtoConstructorsRule from '../rules/no-dto-constructors.js'; import noDtoDefaultValuesRule from '../rules/no-dto-default-values.js'; import noDtoDuplicates from '../rules/no-dto-duplicates.js'; import noDtoInEntityRule from '../rules/no-dto-in-entity.js'; import noEntityImportsInControllersRules from '../rules/no-entity-imports-in-controllers.js'; import noEntityInSwaggerDocsRule from '../rules/no-entity-in-swagger-docs.js'; import noEntityTypeCasting from '../rules/no-entity-type-casting.js'; import noImportMetaEnvRule from '../rules/no-import-meta-env.js'; import noRelativeImportsRule from '../rules/no-relative-imports.js'; import noTsyringeRule from '../rules/no-tsyringe.js'; import noTypeAssertion from '../rules/no-type-assertion.js'; import noUndefinedEntityPropertiesRule from '../rules/no-undefined-entity-properties.js'; import nodeRules from '../rules/node.js'; import pinoLoggerFormatRule from '../rules/pino-logger-format.js'; import preferDtoClassesRule from '../rules/prefer-dto-classes.js'; import { enforceDtoCreateMethod, enforceDtoFromEntityMethod } from '../rules/prefer-dto-create-method.js'; import requireDtoResponseRule from '../rules/require-dto-response.js'; import requireValidRelationsRule from '../rules/require-valid-relations.js'; import typeormColumnTypeValidationRule from '../rules/typeorm-column-type-validation.js'; import serviceArchitectureRule from '../rules/service-architecture.js'; import strictRules from '../rules/strict.js'; import styleRules from '../rules/style.js'; import typescriptRules from '../rules/typescript.js'; import variableRules from '../rules/variables.js'; import websocketArchitectureRules from '../rules/websocket-architecture.js'; // Absolute Pfade zu den TypeScript-Konfigurationsdateien const tsconfigRootDir = process.cwd(); // Das aktuelle Arbeitsverzeichnis const tsconfig = path.resolve(tsconfigRootDir, "tsconfig.json"); const tsconfigEslint = path.resolve(tsconfigRootDir, "tsconfig.eslint.json"); // Registriere die benutzerdefinierten Regeln als Plugin const customRulesPlugin = { rules: { "require-valid-relations": requireValidRelationsRule, "require-dto-response": requireDtoResponseRule, "enforce-controller-response-dto": enforceControllerResponseDtoRule, "enforce-basecontroller": enforceBaseControllerRule.rules["enforce-basecontroller"], "enforce-body-request-dto": enforceBodyRequestDtoRule.rules["enforce-body-request-dto"], "enforce-dto-usage": enforceDtoUsageRule.rules["enforce-dto-usage"], "enforce-dto-constructor": enforceDtoConstructorRule.rules["enforce-dto-constructor"], "controller-swagger-docs": controllerSwaggerDocsRule, "controller-swagger-complete": controllerSwaggerCompleteRule, "controller-swagger-english": controllerSwaggerEnglishRule, "controller-naming-conventions": controllerNamingConventionsRule, "admin-controller-security": adminControllerSecurityRules.rules["admin-controller-security"], "auth-guard-required": authGuardRequiredRule, "no-entity-type-casting": noEntityTypeCasting, "no-tsyringe": noTsyringeRule.rules["no-tsyringe"], "pino-logger-format": pinoLoggerFormatRule, "no-dto-duplicates": noDtoDuplicates, "dto-entity-swagger-separation": dtoEntitySwaggerSeparationRule, "dto-entity-type-consistency": dtoEntityTypeConsistencyRule.rules["dto-entity-type-consistency"], "dto-entity-type-matching": dtoEntityTypeMatchingRule, "dto-visibility-modifiers": dtoVisibilityModifiersRule, "no-dto-constructors": noDtoConstructorsRule, "no-dto-in-entity": noDtoInEntityRule, "no-entity-imports-in-controllers": noEntityImportsInControllersRules.rules["no-entity-imports-in-controllers"], "no-entity-in-swagger-docs": noEntityInSwaggerDocsRule, "prefer-dto-classes": preferDtoClassesRule.rules["prefer-dto-classes"], "enforce-dto-from-entity-method": enforceDtoFromEntityMethod, "enforce-dto-create-method": enforceDtoCreateMethod, "no-relative-imports": noRelativeImportsRule, "coordinate-naming": coordinateNamingRule, "analyze-relation-usage": analyzeRelationUsageRule, "no-import-meta-env": noImportMetaEnvRule, "no-type-assertion": noTypeAssertion.rules["no-type-assertion"], "max-classes-per-file": maxClassesPerFileRule, "no-blank-lines-between-decorators-and-properties": noBlankLinesBetweenDecoratorsAndPropertiesRule, "entity-required-properties": entityRequiredPropertiesRule.rules["entity-required-properties"], "typeorm-column-type-validation": typeormColumnTypeValidationRule.rules["typeorm-column-type-validation"], "enforce-typeorm-naming-conventions": enforceTypeormNamingConventionsRule.rules["enforce-typeorm-naming-conventions"], "enforce-repository-token-handling": enforceRepositoryTokenHandlingRule, "enforce-inject-decorator": enforceInjectDecoratorRule, "enforce-result-pattern": enforceResultPattern, "enforce-api-versioning": enforceApiVersioning.rules["enforce-api-versioning"], "enforce-app-module-registration": enforceAppModuleRegistration, "enforce-error-handling": enforceErrorHandling.rules["enforce-error-handling"], "enforce-service-dto": serviceArchitectureRule.rules["enforce-service-dto"], "enforce-dto-from-entity": enforceDtoFromEntity.rules["enforce-dto-from-entity"], "enforce-entity-dto-fromentity": enforceEntityDtoFromEntity, "enforce-entity-dto-no-request-dto": enforceEntityDtoNoRequestDto, "enforce-nonentity-dto-create": enforceNonEntityDtoCreate.rules["enforce-nonentity-dto-create"], "enforce-request-dto-no-entity-dto": enforceRequestDtoNoEntityDtoRule, "enforce-entity-factory-pattern": enforceEntityFactoryPatternRule, "enforce-dto-entity-creation": enforceDtoEntityCreationRule, "enforce-entity-creation-pattern": enforceEntityCreationPatternRule.rules["enforce-entity-creation-pattern"], "enforce-dto-create-pattern": enforceDtoCreatePatternRule.rules["enforce-dto-create-pattern"], "enforce-lazy-type-loading": enforceLazyTypeLoadingRule, "enforce-dto-create-parameter-types": enforceDtoCreateParameterTypesRule, "enforce-entity-dto-toentity": enforceEntityDtoToEntityRule.rules["enforce-entity-dto-toentity"], "enforce-entity-dto-extends-base": enforceEntityDtoExtendsBaseRule, "enforce-entity-dto-convert-method": enforceEntityDtoConvertMethodRule, "enforce-custom-error-classes": enforceCustomErrorClassesRule, "enforce-dto-naming-conventions": enforceDtoNamingConventions, "enforce-dto-naming": enforceDtoNamingRule.rules["enforce-dto-naming"], "no-undefined-entity-properties": noUndefinedEntityPropertiesRule.rules["no-undefined-entity-properties"], "dto-annotation-property-consistency": dtoAnnotationPropertyConsistencyRule.rules["dto-annotation-property-consistency"], "enforce-explicit-dto-types": enforceExplicitDtoTypesRule, "no-dto-default-values": noDtoDefaultValuesRule.rules["no-dto-default-values"], "filename-class-name-match": filenameClassNameMatchRule, "enum-database-validation": enumDatabaseValidationRule, "enforce-module-existence": enforceModuleExistenceRule.rules["enforce-module-existence"], "enforce-eager-translation-loading": enforceEagerTranslationLoadingRule, "enforce-playable-entity-naming": enforcePlayableEntityNamingRule, "enforce-enum-for-playable-entities": enforceEnumForPlayableEntitiesRule, "no-comments": noCommentsPlugin.rules["no-comments"], ...controllerArchitectureRules.rules, ...controllerReadonlyRestrictionRules.rules, ...dtoEntityMappingCompletenessRule.rules, ...dtoEntityTypeMatchingRule.rules, ...forbidFromEntityOutsideEntityFolderRule.rules, "prefer-dto-create-method": enforceDtoCreateMethod, ...websocketArchitectureRules.rules, }, }; // Erstelle TypeScript-Parser mit detaillierten Options const tsParserWithOptions = { parser: typescriptParser, parserOptions: { project: [tsconfig, tsconfigEslint], tsconfigRootDir: tsconfigRootDir, createDefaultProgram: true, ecmaFeatures: { jsx: false, }, }, }; const config = [ { ignores: [ "node_modules/**", "dist/**", "coverage/**", "logs/**", "scripts/**", "**/__tests__/**", "src/migration/**", "**/migration/**", "**/*.migration.ts", "**/Migration*.ts" ], }, // Spezielle Konfiguration für Test-Fixtures - aktiviere neue Regeln { files: ["**/test-fixtures/**/*.ts"], languageOptions: { ecmaVersion: "latest", sourceType: "module", globals: globals.node, ...tsParserWithOptions, }, plugins: { "@typescript-eslint": typescriptEslint, "@stylistic": stylisticPlugin, import: importPlugin, deprecate: deprecatePlugin, jest: jestPlugin, "custom-rules": customRulesPlugin, "no-comments": noCommentsPlugin, perfectionist, sonarjs: sonarjsPlugin, }, rules: { // Nur die neuen Regeln aktivieren für Test-Fixtures "custom-rules/enforce-module-existence": "error", // Alle anderen Regeln deaktivieren "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-explicit-any": "off", "no-restricted-syntax": "off", "no-restricted-globals": "off", }, }, // Spezielle Konfiguration für Express Middleware - deaktiviere unsafe-* Regeln { files: [ "**/middleware/cors-debug.ts", "**/middleware/detailed-error-logger.ts", "**/middleware/request-logger.ts", "**/middleware/response-logger.ts", "**/middleware/route-tracking.ts" ], languageOptions: { ecmaVersion: "latest", sourceType: "module", globals: globals.node, ...tsParserWithOptions, }, plugins: { "@typescript-eslint": typescriptEslint, "@stylistic": stylisticPlugin, import: importPlugin, deprecate: deprecatePlugin, jest: jestPlugin, "custom-rules": customRulesPlugin, "no-comments": noCommentsPlugin, perfectionist, sonarjs: sonarjsPlugin, }, rules: { // Deaktiviere unsafe-* Regeln für Express Middleware "@typescript-eslint/no-unsafe-assignment": "off", "@typescript-eslint/no-unsafe-call": "off", "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/no-unsafe-argument": "off", "@typescript-eslint/no-unsafe-return": "off", // Alle anderen Regeln beibehalten ...bestPracticesRules.rules, ...deprecatedRules.rules, ...errorRules.rules, ...es6Rules.rules, ...importRules.rules, "import/order": "off", ...jestRules.rules, ...nodeRules.rules, ...strictRules.rules, ...styleRules.rules, ...typescriptRules.rules, ...variableRules.rules, ...deadCodeDetectionRules.rules, }, }, // Spezielle Konfiguration für Socket.IO - deaktiviere unsafe-* Regeln { files: [ "**/socket/SocketGateway.ts", "**/socket/handlers/AuraEventHandler.ts", "**/socket/handlers/ChatEventHandler.ts", "**/socket/handlers/CharacterEventHandler.ts" ], languageOptions: { ecmaVersion: "latest", sourceType: "module", globals: globals.node, ...tsParserWithOptions, }, plugins: { "@typescript-eslint": typescriptEslint, "@stylistic": stylisticPlugin, import: importPlugin, deprecate: deprecatePlugin, jest: jestPlugin, "custom-rules": customRulesPlugin, "no-comments": noCommentsPlugin, perfectionist, sonarjs: sonarjsPlugin, }, rules: { // Deaktiviere unsafe-* Regeln für Socket.IO "@typescript-eslint/no-unsafe-assignment": "off", "@typescript-eslint/no-unsafe-call": "off", "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/no-unsafe-argument": "off", "@typescript-eslint/no-unsafe-return": "off", // Alle anderen Regeln beibehalten ...bestPracticesRules.rules, ...deprecatedRules.rules, ...errorRules.rules, ...es6Rules.rules, ...importRules.rules, "import/order": "off", ...jestRules.rules, ...nodeRules.rules, ...strictRules.rules, ...styleRules.rules, ...typescriptRules.rules, ...variableRules.rules, ...deadCodeDetectionRules.rules, }, }, // Spezielle Konfiguration für Authentication/Utilities - deaktiviere unsafe-* Regeln { files: [ "**/utilities/authentication.ts", "**/utilities/CorsVerificationHelper.ts", "**/utilities/CorsLoggerMiddleware.ts" ], languageOptions: { ecmaVersion: "latest", sourceType: "module", globals: globals.node, ...tsParserWithOptions, }, plugins: { "@typescript-eslint": typescriptEslint, "@stylistic": stylisticPlugin, import: importPlugin, deprecate: deprecatePlugin, jest: jestPlugin, "custom-rules": customRulesPlugin, "no-comments": noCommentsPlugin, perfectionist, sonarjs: sonarjsPlugin, }, rules: { // Deaktiviere unsafe-* Regeln für Authentication/Utilities "@typescript-eslint/no-unsafe-assignment": "off", "@typescript-eslint/no-unsafe-call": "off", "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/no-unsafe-argument": "off", "@typescript-eslint/no-unsafe-return": "off", // Alle anderen Regeln beibehalten ...bestPracticesRules.rules, ...deprecatedRules.rules, ...errorRules.rules, ...es6Rules.rules, ...importRules.rules, "import/order": "off", ...jestRules.rules, ...nodeRules.rules, ...strictRules.rules, ...styleRules.rules, ...typescriptRules.rules, ...variableRules.rules, ...deadCodeDetectionRules.rules, }, }, { files: ["**/*.ts"], languageOptions: { ecmaVersion: "latest", sourceType: "module", globals: globals.node, ...tsParserWithOptions, }, plugins: { "@typescript-eslint": typescriptEslint, "@stylistic": stylisticPlugin, import: importPlugin, deprecate: deprecatePlugin, jest: jestPlugin, "custom-rules": customRulesPlugin, "no-comments": noCommentsPlugin, perfectionist, sonarjs: sonarjsPlugin, }, rules: { ...bestPracticesRules.rules, ...deprecatedRules.rules, ...errorRules.rules, ...es6Rules.rules, ...importRules.rules, // Deaktiviere import/order um Konflikte mit perfectionist/sort-imports zu vermeiden "import/order": "off", ...jestRules.rules, ...nodeRules.rules, ...strictRules.rules, ...styleRules.rules, ...typescriptRules.rules, ...variableRules.rules, ...deadCodeDetectionRules.rules, // Verwende die benutzerdefinierten Regeln direkt "custom-rules/require-valid-relations": "error", "custom-rules/enforce-basecontroller": "error", "custom-rules/enforce-body-request-dto": "error", "custom-rules/enforce-dto-usage": "error", "custom-rules/controller-swagger-docs": "error", "custom-rules/controller-swagger-complete": "error", "custom-rules/controller-swagger-english": "error", "custom-rules/controller-naming-conventions": "error", "custom-rules/dto-entity-swagger-separation": "error", "custom-rules/controller-architecture": "error", "custom-rules/require-proper-response-handling": "error", "custom-rules/no-write-methods-in-public-controllers": [ "error", { exceptions: [ "CharacterController.ts", "AuthController.ts", ] } ], "custom-rules/no-entity-type-casting": "error", "custom-rules/no-tsyringe": "error", "custom-rules/no-dto-duplicates": "error", "custom-rules/no-undefined-entity-properties": "error", "custom-rules/dto-annotation-property-consistency": "error", "custom-rules/admin-controller-security": "error", "custom-rules/no-entity-imports-in-controllers": "error", "custom-rules/enforce-controller-response-dto": "error", "custom-rules/no-entity-in-swagger-docs": "error", "custom-rules/prefer-dto-classes": "warn", "custom-rules/enforce-dto-from-entity-method": "error", "custom-rules/enforce-dto-create-method": "error", "max-depth": ["error", 4], "max-nested-callbacks": ["error", 3], "max-params": ["error", { "max": 10 }], // Maximal 10 Parameter erlaubt "custom-rules/no-comments": "error", "custom-rules/coordinate-naming": [ "error", { min: 2, exceptions: ["_", "constructor"] } ], "custom-rules/analyze-relation-usage": "error", "custom-rules/no-import-meta-env": "error", "custom-rules/dto-entity-mapping-completeness": "error", "custom-rules/dto-entity-type-matching": "error", "custom-rules/dto-entity-type-consistency": "error", "custom-rules/forbid-fromentity-outside-entity-folder": "error", "custom-rules/dto-visibility-modifiers": "error", "import/no-relative-parent-imports": "error", "import/no-relative-packages": "error", "custom-rules/no-relative-imports": "error", "custom-rules/enforce-explicit-dto-types": "error", "custom-rules/no-dto-constructors": "error", "custom-rules/max-classes-per-file": "error", // Regel zum Verbieten aller Kommentare "no-comments/no-comments": "error", // Entity-Validierung "custom-rules/entity-required-properties": "error", "custom-rules/typeorm-column-type-validation": "error", "custom-rules/enforce-typeorm-naming-conventions": "error", // Neue Härtungsregeln "custom-rules/enforce-repository-token-handling": "error", "custom-rules/enforce-inject-decorator": "error", "custom-rules/enforce-result-pattern": "error", "custom-rules/enforce-api-versioning": "error", "custom-rules/enforce-error-handling": "error", "custom-rules/pino-logger-format": "error", "custom-rules/enforce-service-dto": "error", "custom-rules/enforce-dto-from-entity": "error", // Alte Regel deaktiviert "custom-rules/enforce-entity-dto-no-request-dto": "error", "custom-rules/enforce-nonentity-dto-create": "error", // Neue spezialisierte Regel für Non-Entity-DTOs "custom-rules/enforce-request-dto-no-entity-dto": "error", // Request-DTOs dürfen keine EntityDto-Properties haben "custom-rules/enforce-entity-factory-pattern": "error", // Entities nur in DTO fromEntity-Methoden initialisieren "custom-rules/enforce-dto-entity-creation": "error", // Verbotet entityManager.create() und erzwingt DTO-basierte Entity-Erstellung "custom-rules/enforce-entity-creation-pattern": "error", // Entities über DTOs erstellen und mit .toEntity() konvertieren "custom-rules/enforce-dto-create-pattern": "error", // DTO create-Methoden müssen striktes Pattern verwenden "custom-rules/enforce-dto-create-parameter-types": "error", // DTO create-Methoden Parameter müssen 1:1 mit DTO-Properties übereinstimmen "custom-rules/enforce-entity-dto-toentity": "error", // Entity DTOs müssen toEntity-Methode haben "custom-rules/enforce-custom-error-classes": "error", // Custom Error-Klassen statt generischem Error "custom-rules/enforce-dto-naming-conventions": "error", // DTO-Namenskonventionen "custom-rules/enforce-dto-constructor": "error", "custom-rules/filename-class-name-match": "error", "custom-rules/enforce-lazy-type-loading": "error", // Lazy type loading für zirkuläre Imports "custom-rules/enum-database-validation": "error", "custom-rules/no-type-assertion": "error", "custom-rules/no-dto-default-values": "error", "custom-rules/enforce-eager-translation-loading": "error", // Eager loading für translation relations "custom-rules/enforce-playable-entity-naming": "error", // Erzwingt playableRace/playableClass/playableFaction "custom-rules/enforce-enum-for-playable-entities": "error", // Erzwingt Enum-Typen für playable entities // Neue Regeln für TypeScript-Fehler-Abfangung "custom-rules/enforce-module-existence": "error", // Perfectionist-Regeln für Code-Organisation - verwende Perfectionist statt import/order "perfectionist/sort-array-includes": "error", "perfectionist/sort-classes": "error", "perfectionist/sort-enums": "error", "perfectionist/sort-exports": "error", "perfectionist/sort-imports": "error", // Perfectionist für Import-Sortierung "perfectionist/sort-interfaces": "error", "perfectionist/sort-intersection-types": "error", "perfectionist/sort-jsx-props": "error", "perfectionist/sort-maps": "error", "perfectionist/sort-named-exports": "error", "perfectionist/sort-named-imports": "error", // Perfectionist für Named Imports "perfectionist/sort-object-types": "error", "perfectionist/sort-objects": "error", "perfectionist/sort-sets": "error", "perfectionist/sort-switch-case": "error", "perfectionist/sort-union-types": "error", "perfectionist/sort-variable-declarations": "error", // SonarJS-Regeln für Code-Qualität und Sicherheit "sonarjs/no-identical-expressions": "error", "sonarjs/no-identical-functions": "error", "sonarjs/no-redundant-boolean": "error", "sonarjs/no-redundant-jump": "error", "sonarjs/no-unused-collection": "error", "sonarjs/no-use-of-empty-return-value": "error", "sonarjs/prefer-immediate-return": "error", "sonarjs/prefer-object-literal": "error", "sonarjs/prefer-single-boolean-return": "error", "sonarjs/prefer-while": "error", // Deaktiviere semicolon-Regeln für bulletproof code (verhindert Konflikte in TypeScript-Interfaces) "no-extra-semi": "off", "semi": "off", // Konfiguriere Export-Sortierung mit mehrzeiligem Format // Verbietet direkte Verwendung von import.meta.env und process.env "no-restricted-syntax": [ "error", { "selector": "MemberExpression[object.type='MemberExpression'][object.object.type='MetaProperty'][object.object.meta.name='import'][object.object.property.name='meta'][object.property.name='env']", "message": "Direkte Verwendung von import.meta.env ist nicht erlaubt. Verwende stattdessen ConfigProvider.getXxx()." }, { "selector": "MemberExpression[object.type='MemberExpression'][object.object.name='process'][object.property.name='env']", "message": "Direkte Verwendung von process.env ist nicht erlaubt. Verwende stattdessen ConfigProvider.getXxx()." }, { "selector": "MemberExpression[object.name='process'][property.name='env']", "message": "Direkte Verwendung von process.env ist nicht erlaubt. Verwende stattdessen ConfigProvider.getXxx()." }, { "selector": "TSTypeReference[typeName.name='Record']", "message": "Usage of Record<string, unknown> is not allowed. Define a specific interface or type instead." }, { "selector": "TSInterfaceBody > TSIndexSignature[typeAnnotation.typeAnnotation.type='TSUnknownKeyword']", "message": "Index signatures with 'unknown' type ([key: string]: unknown) are not allowed. Define specific properties instead." } ], // Verbietet direkte Verwendung von fetch "no-restricted-globals": [ "error", { "name": "fetch", "message": "Direkte Verwendung von fetch ist nicht erlaubt. Verwende stattdessen den ApiClient aus @addon24/api-client: import { ApiClient } from '@addon24/api-client'; const client = new ApiClient(); client.get/post/patch/delete(url, options)." } ], }, }, // Spezielle Konfiguration für Controller { files: ["**/controller/**/*.ts"], rules: { // Maximal 10 Parameter erlaubt "@typescript-eslint/max-params": ["error", { "max": 10 }], // Aktiviere die Regel für BaseController-Nutzung "custom-rules/enforce-basecontroller": "error", // Indent-Fehler in bestehenden Controllern ignorieren (bestehender 4-Space-Stil) "@stylistic/indent": "off", // Stilregeln vereinfachen für bestehende Controller "object-curly-newline": "off", "newline-before-return": "off", // DTO-Zwang in Controllern deaktivieren, Responses werden separat typisiert "custom-rules/enforce-dto-usage": "error", // Temporär Naming-Konventionen für Controller deaktivieren "custom-rules/controller-naming-conventions": "off", // ensure absolute imports are above relative imports and that unassigned imports are ignored // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md // TODO: enforce a stricter convention in module import order? "import/order": "off", // Deaktiviert wegen Circular Fixes Konflikten } }, // Spezifische Ausnahme für AdminAuraController hinsichtlich Englisch-Erkennung { files: ["**/controller/Admin/AdminAuraController.ts"], rules: { "custom-rules/controller-swagger-english": "off", }, }, // Spezielle Konfiguration für Entity-Dateien { files: ["**/entity/**/*.ts", "**/*Entity.ts"], rules: { // Aktiviere die Regel gegen DTO-Verwendung in Entities "custom-rules/no-dto-in-entity": "error", // Deaktiviere DTO-Usage für Entity-Dateien (TypeORM Decorators verwenden anonyme Objekte) "custom-rules/enforce-dto-usage": "off", // Deaktiviere Perfectionist für Entities (Entity-Property-Reihenfolge ist frei wählbar) "perfectionist/sort-objects": "off", "perfectionist/sort-classes": "off", }, }, // Spezielle Konfiguration für Entity-DTOs - Circular Dependency Prevention { files: ["**/dto/Entity/**/*.ts", "**/*EntityDto.ts"], rules: { // Aktiviere die neuen Circular Dependency Prevention Regeln "custom-rules/enforce-entity-dto-extends-base": "error", "custom-rules/enforce-entity-dto-convert-method": "error", // Deaktiviere DTO-Usage für Entity-DTOs (@ApiProperty Decorators verwenden anonyme Objekte) "custom-rules/enforce-dto-usage": "off", // Deaktiviere Perfectionist für Entity-DTOs (Property-Reihenfolge ist frei wählbar) "perfectionist/sort-objects": "off", "perfectionist/sort-classes": "off", }, }, // Spezielle Konfiguration für DTO-Dateien { files: ["**/dto/**/*.ts"], rules: { // Deaktiviere DTO-Usage für DTO-Dateien (@ApiProperty Decorators verwenden anonyme Objekte) "custom-rules/enforce-dto-usage": "off", }, }, // Ausnahme für ConfigProvider - darf import.meta.env und process.env verwenden { files: ["**/config/ConfigProvider.ts"], rules: { "no-restricted-syntax": "off", }, }, // Ausnahme für Build-Tools - dürfen any-types und komplexere Logik verwenden { files: ["**/config/swagger-adapter.ts"], rules: { "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-unsafe-return": "off", "@typescript-eslint/no-unsafe-call": "off", "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/no-unsafe-assignment": "error", "no-cond-assign": "off", "prefer-regex-literals": "off", "prefer-destructuring": "off", "@typescript-eslint/naming-convention": "off", "@typescript-eslint/no-unused-vars": "off", "import/no-extraneous-dependencies": "off", "custom-rules/enforce-dto-usage": "error", "no-restricted-syntax": "off", }, }, // Ausnahme für HTTP-Client-Services - dürfen fetch verwenden { files: ["**/utilities/Api/**/*.ts"], rules: { "no-restricted-globals": "off", }, }, // Ausnahme für Test-Dateien - dürfen fetch und process.env für Mocking verwenden { files: ["**/*.test.ts", "**/*.spec.ts", "**/__tests__/**/*.ts", "**/test-fixtures/**/*.ts"], rules: { "no-restricted-globals": "off", "no-restricted-syntax": "off", "@typescript-eslint/naming-convention": "off", "@typescript-eslint/no-unsafe-assignment": "error", "@typescript-eslint/no-unsafe-member-access": "off", "import/no-extraneous-dependencies": "off", }, }, { files: ["**/__tests__/**/*", "**/migration/**/*"], rules: { ...Object.fromEntries( Object.keys({ ...bestPracticesRules.rules, ...deprecatedRules.rules, ...errorRules.rules, ...es6Rules.rules, ...importRules.rules, ...jestRules.rules, ...nodeRules.rules, ...strictRules.rules, ...styleRules.rules, ...typescriptRules.rules, ...variableRules.rules, ...deadCodeDetectionRules.rules, }).map(rule => [rule, "off"]) ), // Deaktiviere auch alle custom-rules "custom-rules/require-valid-relations": "off", "custom-rules/enforce-basecontroller": "error", "custom-rules/controller-swagger-docs": "off", "custom-rules/controller-swagger-complete": "off", "custom-rules/controller-swagger-english": "off", "custom-rules/controller-naming-conventions": "off", "custom-rules/dto-entity-swagger-separation": "off", "custom-rules/controller-architecture": "off", "custom-rules/require-proper-response-handling": "off", "custom-rules/no-write-methods-in-public-controllers": "off", "custom-rules/no-tsyringe": "off", "custom-rules/admin-controller-security": "off", "custom-rules/no-entity-imports-in-controllers": "off", "custom-rules/no-entity-in-swagger-docs": "off", "custom-rules/prefer-dto-classes": "off", "custom-rules/enforce-dto-from-entity-method": "error", "custom-rules/enforce-dto-create-method": "error", "custom-rules/coordinate-naming": "off", "custom-rules/auth-guard-required": "off", "custom-rules/analyze-relation-usage": "off", "custom-rules/no-import-meta-env": "off", "custom-rules/dto-entity-mapping-completeness": "error", "custom-rules/dto-visibility-modifiers": "error", "custom-rules/no-dto-constructors": "off", "custom-rules/max-classes-per-file": "off", "no-comments/no-comments": "error", "custom-rules/entity-required-properties": "off", "custom-rules/typeorm-column-type-validation": "off", "custom-rules/enforce-typeorm-naming-conventions": "off", "custom-rules/enforce-repository-token-handling": "off", "custom-rules/enforce-result-pattern": "off", "custom-rules/enforce-api-versioning": "off", "custom-rules/enforce-error-handling": "off", "custom-rules/enforce-service-dto": "off", "custom-rules/enforce-dto-from-entity": "off", "custom-rules/enforce-entity-dto-fromentity": ["error", { "allowCreateMethod": true }], "custom-rules/enforce-entity-dto-no-request-dto": "error", "custom-rules/enforce-entity-dto-toentity": "error", "custom-rules/enforce-entity-dto-extends-base": "error", "custom-rules/enforce-entity-dto-convert-method": "error", "custom-rules/enforce-nonentity-dto-create": "off", "custom-rules/enforce-dto-naming-conventions": "error", "custom-rules/enforce-dto-constructor": "off", "custom-rules/filename-class-name-match": "error", "custom-rules/enum-database-validation": "off", "custom-rules/enforce-dto-usage": "error", "no-restricted-syntax": "off", "no-restricted-globals": "off", }, }, ]; export default config;