import tseslint from 'typescript-eslint'

// shared flat config for the server-side workspaces (core, api); mobile
// runs expo's own config. type-aware so promise misuse is caught — the
// offline/idempotency machinery leans on precise promise handling
export default tseslint.config(
  {
    files: ['**/*.ts'],
    extends: [...tseslint.configs.recommendedTypeChecked],
    languageOptions: {
      parserOptions: {
        projectService: true,
      },
    },
    rules: {
      // tsc (noUnusedLocals) already owns unused checks
      '@typescript-eslint/no-unused-vars': 'off',
      // drizzle rows and json bodies make structural `any` reads explicit
      // at the boundary instead; allow the escape hatch to stay visible
      '@typescript-eslint/no-explicit-any': 'error',
      // fire-and-forget side effects are deliberate and marked with void
      '@typescript-eslint/no-floating-promises': [
        'error',
        {ignoreVoid: true},
      ],
    },
  },
  {
    // tests read responses through the any-typed request fixture and
    // assert shapes at runtime; the unsafe-* family only fights that
    files: ['**/*.test.ts', '**/test-fixtures.ts'],
    rules: {
      '@typescript-eslint/no-non-null-assertion': 'off',
      '@typescript-eslint/no-unsafe-assignment': 'off',
      '@typescript-eslint/no-unsafe-argument': 'off',
      '@typescript-eslint/no-unsafe-call': 'off',
      '@typescript-eslint/no-unsafe-member-access': 'off',
      '@typescript-eslint/no-unsafe-return': 'off',
    },
  },
  {ignores: ['dist/*', 'node_modules/*', 'drizzle/*']},
)
