/ libs / typescript / .eslintrc.json
.eslintrc.json
  1  {
  2    "extends": [
  3      "eslint:recommended",
  4      "plugin:@typescript-eslint/recommended",
  5      "plugin:@typescript-eslint/recommended-requiring-type-checking"
  6    ],
  7    "parser": "@typescript-eslint/parser",
  8    "parserOptions": {
  9      "ecmaVersion": 2022,
 10      "sourceType": "module",
 11      "project": "./tsconfig.json"
 12    },
 13    "plugins": ["@typescript-eslint"],
 14    "ignorePatterns": [
 15      "dist/",
 16      "build/",
 17      "bundle/",
 18      "node_modules/",
 19      "*.d.ts",
 20      "jest.config.js",
 21      "jest.config.cjs"
 22    ],
 23    "rules": {
 24      // TypeScript-specific rules
 25      "@typescript-eslint/no-unused-vars": [
 26        "error",
 27        {
 28          "argsIgnorePattern": "^_",
 29          "varsIgnorePattern": "^_"
 30        }
 31      ],
 32      "@typescript-eslint/no-non-null-assertion": "warn",
 33      "@typescript-eslint/prefer-optional-chain": "error",
 34      "@typescript-eslint/no-unnecessary-type-assertion": "error",
 35      "@typescript-eslint/no-loss-of-precision": "error",
 36      // We cannot type everything like user inputs, outputs, json, etc.
 37      "@typescript-eslint/no-explicit-any": "off",
 38      "@typescript-eslint/no-unsafe-assignment": "off",
 39      // Namespaces are useful for organizing API specifications
 40      "@typescript-eslint/no-namespace": "off",
 41      "@typescript-eslint/ban-types": "off",
 42  
 43      // General JavaScript/TypeScript rules
 44      "no-console": ["warn", { "allow": ["debug", "warn", "error"] }],
 45      "no-debugger": "error",
 46      "no-alert": "error",
 47      "prefer-const": "error",
 48      "no-var": "error",
 49      "eqeqeq": ["error", "always", { "null": "never" }],
 50      "curly": ["error", "all"],
 51      "no-trailing-spaces": "error",
 52      "no-multiple-empty-lines": ["error", { "max": 2 }],
 53  
 54      // Import/Export rules
 55      "no-duplicate-imports": "error",
 56  
 57      // Promise/Async rules
 58      "no-async-promise-executor": "error",
 59      "require-await": "error"
 60    },
 61    "overrides": [
 62      {
 63        "files": ["*.test.ts", "*.spec.ts", "examples/**/*.ts", "jest.*.ts"],
 64        "rules": {
 65          "no-console": "off",
 66          "@typescript-eslint/explicit-function-return-type": "off",
 67          "@typescript-eslint/no-unsafe-member-access": "off",
 68          "@typescript-eslint/no-unsafe-argument": "off",
 69          "@typescript-eslint/no-non-null-assertion": "off"
 70        }
 71      },
 72      {
 73        "files": ["scripts/**/*.ts"],
 74        "rules": {
 75          "no-console": "off"
 76        }
 77      },
 78      {
 79        "files": ["integrations/vercel/tests/*.test.ts"],
 80        "rules": {
 81          // AI SDK does not expose the type of createOpenAI return value
 82          "@typescript-eslint/no-unsafe-call": "off"
 83        }
 84      },
 85      {
 86        "files": ["integrations/opencode/tests/*.test.ts"],
 87        "rules": {
 88          // OpenCode plugin types are mocked and not fully typed
 89          "@typescript-eslint/no-unsafe-call": "off",
 90          "@typescript-eslint/unbound-method": "off"
 91        }
 92      },
 93      {
 94        "files": ["integrations/claude-code/tests/*.test.ts"],
 95        "rules": {
 96          // Claude Code transcript types are mocked and not fully typed
 97          "@typescript-eslint/no-unsafe-call": "off",
 98          "@typescript-eslint/unbound-method": "off"
 99        }
100      }
101    ]
102  }