diff --git a/js/README.md b/js/README.md index aa1925dc4..5a104a833 100644 --- a/js/README.md +++ b/js/README.md @@ -119,3 +119,7 @@ See the [Migrate from v1.x to v2.x guide](https://www.braintrust.dev/docs/refere ### Upgrading from 0.x to 1.x See the [Migrate from v1.x to v2.x guide](https://www.braintrust.dev/docs/reference/sdks/typescript/migrations/v0-to-v1). + +## Compatibility + +The `braintrust` package is compatible with Node.js versions 20.12.0, 22.13.0, for the respective major Node.js release lines and above. diff --git a/js/eslint.config.ts b/js/eslint.config.ts index 1d18e3de6..1705032c7 100644 --- a/js/eslint.config.ts +++ b/js/eslint.config.ts @@ -1,8 +1,12 @@ import tseslint from "@typescript-eslint/eslint-plugin"; import tsparser from "@typescript-eslint/parser"; +import esX from "eslint-plugin-es-x"; +import n from "eslint-plugin-n"; import nodeImport from "eslint-plugin-node-import"; import tsupConfigImport from "./tsup.config"; +const supportedNodeVersionRange = "^20.12.0 || ^21.7.0 || ^22.13.0 || >=23.5.0"; + // Handle both ESM and CJS module formats const tsupConfig = Array.isArray(tsupConfigImport) ? tsupConfigImport @@ -51,11 +55,14 @@ export default [ }, plugins: { "@typescript-eslint": tseslint, + "es-x": esX, + n, "node-import": nodeImport, }, rules: { // Base TypeScript rules ...tseslint.configs.recommended.rules, + ...esX.configs["flat/restrict-to-es2022"].rules, // TODO: Fix violations and re-enable as "error" "@typescript-eslint/no-explicit-any": "warn", "@typescript-eslint/no-unused-vars": [ @@ -130,6 +137,21 @@ export default [ "AsyncLocalStorage.enterWith() is not supported in Cloudflare Workers. Use AsyncLocalStorage.run() to scope context instead.", }, ], + "n/no-unsupported-features/node-builtins": [ + "error", + { + version: supportedNodeVersionRange, + allowExperimental: true, + }, + ], + "n/no-unsupported-features/es-builtins": [ + "error", + { version: supportedNodeVersionRange }, + ], + "n/no-unsupported-features/es-syntax": [ + "error", + { version: supportedNodeVersionRange }, + ], // Require node: protocol for Node.js built-in imports (for Deno compatibility) // This plugin automatically detects ALL Node.js built-ins - no manual list needed! "node-import/prefer-node-protocol": "error", diff --git a/js/package.json b/js/package.json index 573969f9f..917bccb4a 100644 --- a/js/package.json +++ b/js/package.json @@ -192,11 +192,14 @@ "ai": "^6.0.0", "async": "^3.2.5", "cross-env": "^7.0.3", + "eslint-plugin-es-x": "9.7.0", + "eslint-plugin-n": "^18.2.1", "eslint-plugin-node-import": "^1.0.5", "openai": "6.25.0", "rollup": "^4.60.3", "tar": "^7.5.16", "tinybench": "^4.0.1", + "ts-declaration-location": "^1.0.7", "tsup": "^8.5.1", "tsx": "^4.21.0", "typedoc": "^0.25.13", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ce6d6ea1c..3cc7f9609 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -483,6 +483,12 @@ importers: cross-env: specifier: ^7.0.3 version: 7.0.3 + eslint-plugin-es-x: + specifier: 9.7.0 + version: 9.7.0(eslint@9.39.4(jiti@2.6.1)) + eslint-plugin-n: + specifier: ^18.2.1 + version: 18.2.1(eslint@9.39.4(jiti@2.6.1))(ts-declaration-location@1.0.7(typescript@5.4.4))(typescript@5.4.4) eslint-plugin-node-import: specifier: ^1.0.5 version: 1.0.5(eslint@9.39.4(jiti@2.6.1)) @@ -498,6 +504,9 @@ importers: tinybench: specifier: ^4.0.1 version: 4.0.1 + ts-declaration-location: + specifier: ^1.0.7 + version: 1.0.7(typescript@5.4.4) tsup: specifier: ^8.5.1 version: 8.5.1(@swc/core@1.15.8)(jiti@2.6.1)(postcss@8.5.15)(tsx@4.21.0)(typescript@5.4.4)(yaml@2.9.0) @@ -2480,6 +2489,37 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} + eslint-compat-utils@0.5.1: + resolution: {integrity: sha512-3z3vFexKIEnjHE3zCMRo6fn/e44U7T1khUjg+Hp0ZQMCigh28rALD0nPFBcGZuiLC5rLZa2ubQHDRln09JfU2Q==} + engines: {node: '>=12'} + peerDependencies: + eslint: '>=6.0.0' + + eslint-plugin-es-x@7.8.0: + resolution: {integrity: sha512-7Ds8+wAAoV3T+LAKeu39Y5BzXCrGKrcISfgKEqTS4BDN8SFEDQd0S43jiQ8vIa3wUKD07qitZdfzlenSi8/0qQ==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + eslint: '>=8' + + eslint-plugin-es-x@9.7.0: + resolution: {integrity: sha512-BT0pUw0toxtrHulYycGiUTL++qC11opyPYMuGUR7AgmuQ/N1YN1xLupF8rGxlaGqEqkqeedJuacCxxAcYgGkvg==} + engines: {node: ^20.19.0 || >=22.12.0} + peerDependencies: + eslint: '>=9.29.0' + + eslint-plugin-n@18.2.1: + resolution: {integrity: sha512-aO3C9//yq8JIvYOi/T+jPvcZ9hZzpwzbR8esrYpFtgE9vpbyM8kn42AQOtIqYspVmpaSWr8X+nrlQuAJYxXAaw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + peerDependencies: + eslint: '>=8.57.1' + ts-declaration-location: ^1.0.6 + typescript: '>=5.0.0' + peerDependenciesMeta: + ts-declaration-location: + optional: true + typescript: + optional: true + eslint-plugin-node-import@1.0.5: resolution: {integrity: sha512-razzgbr3EcB5+bm8/gqTqzTJ7Bpiu8PIChiAMRfZCNigr9GZBtnVSI+wPw+RGbWYCCIzWAsK/A7ihoAeSz5j7A==} engines: {node: ^14.18.0 || ^16.0.0 || >= 18.0.0} @@ -2494,6 +2534,12 @@ packages: resolution: {integrity: sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + eslint-type-tracer@0.5.2: + resolution: {integrity: sha512-YiJmgk6OD1suPB4UC3M/PB+oxahf145jQQ5gFXFk9F9Y7puWwnqGYC2BtTB+FoHqdOohImeTt0rNk0lhhECNaQ==} + engines: {node: ^18 || >=20} + peerDependencies: + eslint: '>=8' + eslint-visitor-keys@3.4.3: resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2749,6 +2795,10 @@ packages: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} + globals@15.15.0: + resolution: {integrity: sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==} + engines: {node: '>=18'} + globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} engines: {node: '>=10'} @@ -3887,6 +3937,11 @@ packages: peerDependencies: typescript: '>=4.8.4' + ts-declaration-location@1.0.7: + resolution: {integrity: sha512-EDyGAwH1gO0Ausm9gV6T2nUvBgXT5kGoCMJPllOaooZ+4VvJiKBdZE7wK18N1deEowhcUptS+5GXZK8U/fvpwA==} + peerDependencies: + typescript: '>=4.0.0' + ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} @@ -6248,6 +6303,40 @@ snapshots: escape-string-regexp@4.0.0: {} + eslint-compat-utils@0.5.1(eslint@9.39.4(jiti@2.6.1)): + dependencies: + eslint: 9.39.4(jiti@2.6.1) + semver: 7.8.0 + + eslint-plugin-es-x@7.8.0(eslint@9.39.4(jiti@2.6.1)): + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.6.1)) + '@eslint-community/regexpp': 4.12.2 + eslint: 9.39.4(jiti@2.6.1) + eslint-compat-utils: 0.5.1(eslint@9.39.4(jiti@2.6.1)) + + eslint-plugin-es-x@9.7.0(eslint@9.39.4(jiti@2.6.1)): + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.6.1)) + '@eslint-community/regexpp': 4.12.2 + eslint: 9.39.4(jiti@2.6.1) + eslint-type-tracer: 0.5.2(eslint@9.39.4(jiti@2.6.1)) + + eslint-plugin-n@18.2.1(eslint@9.39.4(jiti@2.6.1))(ts-declaration-location@1.0.7(typescript@5.4.4))(typescript@5.4.4): + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.6.1)) + enhanced-resolve: 5.21.2 + eslint: 9.39.4(jiti@2.6.1) + eslint-plugin-es-x: 7.8.0(eslint@9.39.4(jiti@2.6.1)) + get-tsconfig: 4.13.0 + globals: 15.15.0 + globrex: 0.1.2 + ignore: 5.3.2 + semver: 7.8.0 + optionalDependencies: + ts-declaration-location: 1.0.7(typescript@5.4.4) + typescript: 5.4.4 + eslint-plugin-node-import@1.0.5(eslint@9.39.4(jiti@2.6.1)): dependencies: eslint: 9.39.4(jiti@2.6.1) @@ -6262,6 +6351,11 @@ snapshots: esrecurse: 4.3.0 estraverse: 5.3.0 + eslint-type-tracer@0.5.2(eslint@9.39.4(jiti@2.6.1)): + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.4(jiti@2.6.1)) + eslint: 9.39.4(jiti@2.6.1) + eslint-visitor-keys@3.4.3: {} eslint-visitor-keys@4.2.1: {} @@ -6569,6 +6663,8 @@ snapshots: globals@14.0.0: {} + globals@15.15.0: {} + globby@11.1.0: dependencies: array-union: 2.1.0 @@ -7711,6 +7807,11 @@ snapshots: dependencies: typescript: 5.4.4 + ts-declaration-location@1.0.7(typescript@5.4.4): + dependencies: + picomatch: 4.0.4 + typescript: 5.4.4 + ts-interface-checker@0.1.13: {} tsconfck@3.1.1(typescript@5.4.4):