Skip to content

Commit 1141664

Browse files
stainless-botRobertCraigie
authored andcommitted
chore(internal): migrate to eslint v9
1 parent 3b6caa7 commit 1141664

File tree

10 files changed

+313
-476
lines changed

10 files changed

+313
-476
lines changed

.eslintrc.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// @ts-check
2+
import tseslint from 'typescript-eslint';
3+
import unusedImports from 'eslint-plugin-unused-imports';
4+
import prettier from 'eslint-plugin-prettier';
5+
6+
export default tseslint.config(
7+
{
8+
languageOptions: {
9+
parser: tseslint.parser,
10+
parserOptions: { sourceType: 'module' },
11+
},
12+
files: ['**/*.ts', '**/*.mts', '**/*.cts', '**/*.js', '**/*.mjs', '**/*.cjs'],
13+
ignores: ['dist/**'],
14+
plugins: {
15+
'@typescript-eslint': tseslint.plugin,
16+
'unused-imports': unusedImports,
17+
prettier,
18+
},
19+
rules: {
20+
'no-unused-vars': 'off',
21+
'prettier/prettier': 'error',
22+
'unused-imports/no-unused-imports': 'error',
23+
'no-restricted-imports': [
24+
'error',
25+
{
26+
patterns: [
27+
{
28+
regex: '^@anthropic-ai/sdk(/.*)?',
29+
message: 'Use a relative import, not a package import.',
30+
},
31+
],
32+
},
33+
],
34+
},
35+
},
36+
{
37+
files: ['tests/**', 'examples/**', 'packages/**'],
38+
rules: {
39+
'no-restricted-imports': 'off',
40+
},
41+
},
42+
);

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030
"@swc/jest": "^0.2.29",
3131
"@types/jest": "^29.4.0",
3232
"@types/node": "^20.17.6",
33-
"@typescript-eslint/eslint-plugin": "^6.7.0",
34-
"@typescript-eslint/parser": "^6.0.0",
35-
"eslint": "^8.49.0",
36-
"eslint-plugin-prettier": "^5.0.1",
37-
"eslint-plugin-unused-imports": "^3.0.0",
33+
"typescript-eslint": "^8.24.0",
34+
"@typescript-eslint/eslint-plugin": "^8.24.0",
35+
"@typescript-eslint/parser": "^8.24.0",
36+
"eslint": "^9.20.1",
37+
"eslint-plugin-prettier": "^5.2.3",
38+
"eslint-plugin-unused-imports": "^4.1.4",
3839
"iconv-lite": "^0.6.3",
3940
"jest": "^29.4.0",
4041
"prettier": "^3.0.0",

packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ for (const dep in pkgJson.dependencies) {
88
}
99
}
1010

11-
fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2))
11+
fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2));

packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ for (const dep in pkgJson.dependencies) {
88
}
99
}
1010

11-
fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2))
11+
fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2));

scripts/format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -e
55
cd "$(dirname "$0")/.."
66

77
echo "==> Running eslint --fix"
8-
ESLINT_USE_FLAT_CONFIG="false" ./node_modules/.bin/eslint --fix --ext ts,js .
8+
./node_modules/.bin/eslint --fix .

scripts/lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
cd "$(dirname "$0")/.."
66

77
echo "==> Running eslint"
8-
ESLINT_USE_FLAT_CONFIG="false" ./node_modules/.bin/eslint --ext ts,js . --ignore-pattern="packages/"
8+
./node_modules/.bin/eslint .
99

1010
echo "==> Building"
1111
./scripts/build # also checks types

src/client.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -399,24 +399,6 @@ export class BaseAnthropic {
399399
return url.toString();
400400
}
401401

402-
private calculateContentLength(body: unknown): string | null {
403-
if (typeof body === 'string') {
404-
if (typeof (globalThis as any).Buffer !== 'undefined') {
405-
return (globalThis as any).Buffer.byteLength(body, 'utf8').toString();
406-
}
407-
408-
if (typeof (globalThis as any).TextEncoder !== 'undefined') {
409-
const encoder = new (globalThis as any).TextEncoder();
410-
const encoded = encoder.encode(body);
411-
return encoded.length.toString();
412-
}
413-
} else if (ArrayBuffer.isView(body)) {
414-
return body.byteLength.toString();
415-
}
416-
417-
return null;
418-
}
419-
420402
/**
421403
* Used as a callback for mutating the given `FinalRequestOptions` object.
422404
*/

src/pagination.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
4646
}
4747

4848
async *iterPages(): AsyncGenerator<this> {
49-
// eslint-disable-next-line @typescript-eslint/no-this-alias
5049
let page: this = this;
5150
yield page;
5251
while (page.hasNextPage()) {

0 commit comments

Comments
 (0)