import nx from '@nx/eslint-plugin';

export default [
  ...nx.configs['flat/base'],
  ...nx.configs['flat/typescript'],
  ...nx.configs['flat/javascript'],
  {
    "ignores": [
      "**/dist",
      "**/out-tsc",
      "**/vitest.config.*.timestamp*",
      // Generated gRPC TypeScript stubs — hand-rules do not apply to
      // codegen output. Lint the wrapper modules in `ai-client/`, not
      // the ts-proto-emitted files under `gen/`.
      "apps/portal-bff/src/grpc/gen/**"
    ]
  },
  {
    files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
    rules: {
      '@nx/enforce-module-boundaries': [
        'error',
        {
          enforceBuildableLibDependency: true,
          allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?[jt]s$'],
          // Module boundaries per ADR-0003.
          //
          // Scope tags partition the workspace into front (portal-shell) /
          // back (portal-bff) / shared (consumable by both). Type tags
          // partition into apps / feature libs / shared libs.
          //
          // Both axes apply: a lib must satisfy both scope and type rules
          // to be importable.
          depConstraints: [
            {
              sourceTag: 'scope:portal-shell',
              onlyDependOnLibsWithTags: ['scope:portal-shell', 'scope:shared'],
            },
            {
              sourceTag: 'scope:portal-bff',
              onlyDependOnLibsWithTags: ['scope:portal-bff', 'scope:shared'],
            },
            {
              sourceTag: 'scope:shared',
              onlyDependOnLibsWithTags: ['scope:shared'],
            },
            {
              sourceTag: 'type:app',
              onlyDependOnLibsWithTags: ['type:feature', 'type:shared'],
            },
            {
              sourceTag: 'type:feature',
              onlyDependOnLibsWithTags: ['type:feature', 'type:shared'],
            },
            {
              sourceTag: 'type:shared',
              onlyDependOnLibsWithTags: ['type:shared'],
            },
          ],
        },
      ],
    },
  },
  {
    files: [
      '**/*.ts',
      '**/*.tsx',
      '**/*.cts',
      '**/*.mts',
      '**/*.js',
      '**/*.jsx',
      '**/*.cjs',
      '**/*.mjs',
    ],
    // Override or add rules here
    rules: {},
  },
];
