/* eslint-disable max-lines-per-function -- config file requires many lines */
/**
 * ESLint 9 Flat Config - NestJS Stack
 *
 * Publishable factory function for NestJS ESLint configuration. Extends
 * TypeScript config with adjustments for NestJS patterns like decorators,
 * dependency injection, and class-based architecture.
 *
 * Inheritance chain:
 *   nestjs.ts (this file)
 *   -> typescript.ts
 *       -> base.ts
 * @see https://eslint.org/docs/latest/use/configure/configuration-files-new
 * @module configs/eslint/nestjs
 */
// Import TypeScript config and utilities
import { codeOrganization, defaultIgnores, defaultThresholds, getBaseConfigs, getBaseLanguageOptions, getJsFilesOverride, getScriptsFilesOverride, getSharedFilesOverride, getSharedRules, getTestFilesOverride, getTsFilesOverride, getTsTestFilesOverride, } from "./typescript.js";
// Re-export for downstream configs
export { defaultIgnores, defaultThresholds, getBaseConfigs, getBaseLanguageOptions, getSharedRules, };
/**
 * Creates the NestJS ESLint configuration.
 * @param {object} options - Configuration options
 * @param {string} options.tsconfigRootDir - Root directory for tsconfig.json
 * @param {string[]} [options.ignorePatterns] - Patterns to ignore
 * @param {object} [options.thresholds] - Threshold overrides
 * @returns {import("eslint").Linter.Config[]} ESLint flat config array
 */
export function getNestjsConfig({ tsconfigRootDir, ignorePatterns = defaultIgnores, thresholds = defaultThresholds, }) {
    return [
        // Global ignores
        {
            ignores: ignorePatterns,
        },
        // Base configurations from shared module
        ...getBaseConfigs(),
        // Base configuration for all files
        {
            languageOptions: getBaseLanguageOptions(),
            plugins: {
                "code-organization": codeOrganization,
            },
            rules: {
                // Shared rules from base
                ...getSharedRules(thresholds),
                // Code organization
                "code-organization/enforce-statement-order": "error",
                // Configuration enforcement - prevent direct process.env access
                // All configuration should go through ConfigService
                // @see the host rules in .agents/rules/
                "no-restricted-syntax": [
                    "error",
                    {
                        selector: "MemberExpression[object.name='process'][property.name='env']",
                        message: "Direct process.env access is forbidden. Use ConfigService for type-safe configuration. See the host rules in .agents/rules/.",
                    },
                ],
                // NestJS uses classes extensively for modules, controllers, services, etc.
                "functional/no-classes": "off",
                // NestJS decorators require class methods
                "jsdoc/require-jsdoc": [
                    "error",
                    {
                        require: {
                            FunctionDeclaration: true,
                            MethodDefinition: true,
                            ClassDeclaration: true,
                            ArrowFunctionExpression: false,
                            FunctionExpression: false,
                        },
                        contexts: [
                            "TSInterfaceDeclaration",
                            "TSTypeAliasDeclaration",
                            "VariableDeclaration[declarations.0.init.type='ArrowFunctionExpression']:has([id.name=/^[A-Z]/])",
                        ],
                    },
                ],
            },
        },
        // JavaScript files override
        getJsFilesOverride(),
        // Shared hooks and components
        getSharedFilesOverride(),
        // Test files
        getTestFilesOverride(),
        // TypeScript files - enable type-checked linting
        getTsFilesOverride(["**/*.ts"], tsconfigRootDir),
        // TypeScript test files - disable immutable-data
        getTsTestFilesOverride([
            "**/*.test.ts",
            "**/*.spec.ts",
            "**/*.e2e-spec.ts",
        ]),
        // NestJS module files - relax some rules
        {
            files: ["**/*.module.ts"],
            rules: {
                // Modules often import many things
                "max-lines": "off",
            },
        },
        // NestJS controller/service files
        {
            files: ["**/*.controller.ts", "**/*.service.ts", "**/*.resolver.ts"],
            rules: {
                // These files often have many methods
                "max-lines-per-function": ["error", { max: 100 }],
            },
        },
        // Configuration files - allowed to use process.env directly
        {
            files: ["**/*config.*", "**/configuration.ts", "**/config/*.ts"],
            rules: {
                "no-restricted-syntax": "off",
            },
        },
        // Lambda handlers - allowed to use getStandaloneConfig()
        {
            files: ["**/handlers/**/*.ts", "**/lambda/**/*.ts"],
            rules: {
                "no-restricted-syntax": "off",
            },
        },
        // Standalone maintenance scripts — MUST stay last so it wins over the
        // application-oriented overrides above. These files used to be ignored
        // outright; they are linted now, under a profile that suits a CLI.
        getScriptsFilesOverride(),
    ];
}
/* eslint-enable max-lines-per-function -- config file requires many lines */
//# sourceMappingURL=nestjs.js.map