Skip to content

Commit f87a58e

Browse files
committed
refactor: update eslint to v9
1 parent e5e5ee4 commit f87a58e

123 files changed

Lines changed: 334 additions & 511 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

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

.eslintrc.js

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

eslint.config.mjs

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
import { dirname } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
4+
import tseslint from 'typescript-eslint';
5+
import eslint from '@eslint/js';
6+
import globals from 'globals';
7+
import importPlugin from 'eslint-plugin-import-x';
8+
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
9+
import jest from 'eslint-plugin-jest';
10+
11+
const __dirname = dirname(fileURLToPath(import.meta.url));
12+
13+
export default tseslint.config(
14+
// Global ignores (replaces .eslintignore + ignorePatterns)
15+
{
16+
ignores: [
17+
'**/.yarn/**',
18+
'**/dist/**',
19+
'**/.next/**',
20+
'**/.vite/**',
21+
// NOTE: we are ignoring these examples because they were being ignored
22+
// before, we will need to isolate specific rules for examples and
23+
// remove these in the future.
24+
'**/vercel/examples/**',
25+
'**/react-native/example/**',
26+
'**/react-native/example-fdv2/**',
27+
'**/react/contract-tests/**',
28+
'**/react/examples/**',
29+
'**/jest/example/**',
30+
'**/electron/example/**',
31+
'**/svelte/.svelte-kit/**',
32+
'**/svelte/example/**',
33+
'**/fastly/example/build/**',
34+
'**/server-ai/examples/chat-judge/**',
35+
'**/server-ai/examples/direct-judge/**',
36+
'**/fromExternal/**',
37+
],
38+
},
39+
40+
// Base config for all TypeScript files
41+
{
42+
files: ['**/*.ts', '**/*.tsx'],
43+
extends: [
44+
eslint.configs.recommended,
45+
importPlugin.flatConfigs.recommended,
46+
tseslint.configs.recommended
47+
],
48+
plugins: {
49+
// Alias as 'import' so existing eslint-disable comments with import/ prefix keep working
50+
import: importPlugin,
51+
jest,
52+
},
53+
languageOptions: {
54+
parserOptions: {
55+
project: './tsconfig.eslint.json',
56+
tsconfigRootDir: __dirname,
57+
},
58+
globals: {
59+
...globals.node,
60+
BigInt: 'readonly',
61+
},
62+
},
63+
settings: {
64+
'import-x/resolver-next': [
65+
createTypeScriptImportResolver({
66+
project: 'tsconfig.eslint.json',
67+
}),
68+
],
69+
},
70+
rules: {
71+
'@typescript-eslint/no-explicit-any': 'off',
72+
'@typescript-eslint/no-unused-vars': [
73+
'error',
74+
{
75+
ignoreRestSiblings: true,
76+
argsIgnorePattern: '^_',
77+
varsIgnorePattern: '^__',
78+
caughtErrors: 'none',
79+
},
80+
],
81+
// naming conventions
82+
'@typescript-eslint/naming-convention': [
83+
'error',
84+
{
85+
selector: ['method'],
86+
format: ['camelCase'],
87+
leadingUnderscore: 'forbid',
88+
},
89+
{
90+
selector: ['method'],
91+
format: ['camelCase'],
92+
modifiers: ['private'],
93+
leadingUnderscore: 'require',
94+
},
95+
{
96+
selector: ['classProperty', 'parameterProperty'],
97+
format: ['camelCase'],
98+
leadingUnderscore: 'forbid',
99+
},
100+
{
101+
selector: ['classProperty', 'parameterProperty'],
102+
modifiers: ['static'],
103+
format: ['PascalCase'],
104+
leadingUnderscore: 'forbid',
105+
},
106+
{
107+
selector: ['classProperty', 'parameterProperty'],
108+
modifiers: ['private'],
109+
format: ['camelCase'],
110+
leadingUnderscore: 'require',
111+
},
112+
],
113+
'@typescript-eslint/no-empty-object-type': [
114+
'error',
115+
{ allowInterfaces: 'with-single-extends' },
116+
],
117+
'no-restricted-syntax': [
118+
'error',
119+
{ selector: 'ForInStatement', message: 'Use Object.{keys,values,entries} instead.' },
120+
{ selector: 'LabeledStatement', message: 'Labels are a form of GOTO.' },
121+
{ selector: 'WithStatement', message: '`with` is disallowed in strict mode.' },
122+
],
123+
'import/no-extraneous-dependencies': [
124+
'error',
125+
{
126+
devDependencies: [
127+
// NOTE: we should uncomment this in the future as config files typically
128+
// only read from devdependencies
129+
'**/jest*.ts',
130+
// '**/*.config.ts',
131+
'**/*.d.ts',
132+
'**/*{.,_}test.{ts,tsx}',
133+
// '**/*{.,_}spec.{ts,tsx}',
134+
],
135+
},
136+
],
137+
// enable url-scheme imports
138+
'import-x/no-unresolved': ['error', { ignore: ['^[a-z]+:'] }],
139+
'no-underscore-dangle': ['error', { allowAfterThis: true }],
140+
'no-await-in-loop': 'error',
141+
'no-new': 'error',
142+
'no-console': 'error',
143+
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
144+
145+
// NOTE: this will allow object fields to be reassigned.
146+
'no-param-reassign': [ 'error' ],
147+
148+
// TODO: we may want to re-enable this in the future.
149+
'@typescript-eslint/ban-ts-comment': 'off',
150+
151+
// extension rules (https://typescript-eslint.io/rules#extension-rules)
152+
"no-use-before-define": "off",
153+
"@typescript-eslint/no-use-before-define": "error",
154+
155+
// Keeping this as a reference, but I don't think we really need to enforce this rule.
156+
// "class-methods-use-this": "off",
157+
// "@typescript-eslint/class-methods-use-this": "error"
158+
},
159+
},
160+
161+
// Test files: add jest globals and jest rules; relax test-specific rules
162+
{
163+
files: [
164+
'**/*.test.ts',
165+
'**/*.test.tsx',
166+
'**/__tests__/**/*.ts',
167+
'**/__tests__/**/*.tsx'
168+
],
169+
languageOptions: {
170+
globals: {
171+
...globals.jest,
172+
},
173+
},
174+
rules: {
175+
'jest/no-disabled-tests': 'warn',
176+
'jest/no-focused-tests': 'error',
177+
'jest/no-identical-title': 'error',
178+
'jest/valid-expect': 'error',
179+
// 'no-console': 'off',
180+
'@typescript-eslint/no-require-imports': 'off',
181+
'import-x/no-unresolved': 'off',
182+
},
183+
},
184+
185+
// Examples, contract-tests, and tooling packages: allow console
186+
{
187+
files: [
188+
'**/example/**',
189+
'**/examples/**',
190+
'**/example-*/**',
191+
'**/contract-tests/**',
192+
'packages/tooling/**',
193+
],
194+
rules: {
195+
// TODO re-enable later
196+
// 'no-console': 'off',
197+
// TODO: a lot of our examples fail this one, will need to check
198+
'import-x/no-unresolved': 'off',
199+
},
200+
},
201+
202+
// Override: contract-test-utils needs 'always' extensions (with ts exception)
203+
{
204+
files: ['packages/tooling/contract-test-utils/**/*.ts'],
205+
rules: {
206+
'import/extensions': ['error', 'always', { ts: 'never' }],
207+
},
208+
},
209+
);

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,23 @@
6565
"build": "yarn workspaces foreach -vp --topological-dev run build",
6666
"//": "When using build:doc you need to specify the workspace. 'yarn run build:doc -- packages/shared/common' for example.",
6767
"build:doc": "npx typedoc --options $1/typedoc.json",
68-
"lint": "npx eslint . --ext .ts",
69-
"lint:fix": "yarn run lint -- --fix",
68+
"lint": "npx eslint .",
69+
"lint:fix": "npx eslint . --fix",
7070
"test": "echo Please run tests for individual packages.",
7171
"coverage": "npm run test -- --coverage",
7272
"contract-test-harness": "curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/master/downloader/run.sh \\ | VERSION=v2 PARAMS=\"-url http://localhost:8000 -debug -stop-service-at-end $TEST_HARNESS_PARAMS\" sh",
7373
"check": "yarn && yarn lint && tsc && yarn build"
7474
},
7575
"devDependencies": {
76-
"@typescript-eslint/eslint-plugin": "^6.20.0",
77-
"@typescript-eslint/parser": "^6.20.0",
78-
"eslint": "^8.56.0",
79-
"eslint-plugin-import": "^2.27.5",
80-
"eslint-plugin-jest": "^27.6.3",
76+
"@eslint/js": "^9.0.0",
77+
"eslint": "^9.0.0",
78+
"eslint-import-resolver-typescript": "^4.0.0",
79+
"eslint-plugin-import-x": "^4.0.0",
80+
"eslint-plugin-jest": "^28.0.0",
81+
"globals": "^16.0.0",
8182
"typedoc": "0.25.0",
82-
"typescript": "5.1.6"
83+
"typescript": "5.1.6",
84+
"typescript-eslint": "^8.0.0"
8385
},
8486
"packageManager": "yarn@3.4.1",
8587
"//": "Pin jsonc-parser because v3.3.0 breaks rollup-plugin-esbuild",

packages/ai-providers/server-ai-langchain/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"scripts": {
2727
"build": "tsup-node",
28-
"lint": "npx eslint . --ext .ts",
28+
"lint": "npx eslint .",
2929
"lint:fix": "yarn run lint --fix",
3030
"check": "yarn lint && yarn build && yarn test",
3131
"test": "jest"
@@ -47,11 +47,6 @@
4747
"@opentelemetry/api": "^1.9.0",
4848
"@traceloop/instrumentation-langchain": "^0.26.0",
4949
"@types/jest": "^29.5.3",
50-
"@typescript-eslint/eslint-plugin": "^6.20.0",
51-
"@typescript-eslint/parser": "^6.20.0",
52-
"eslint": "^8.45.0",
53-
"eslint-plugin-import": "^2.27.5",
54-
"eslint-plugin-jest": "^27.6.3",
5550
"jest": "^29.6.1",
5651
"langchain": "^1.3.4",
5752
"ts-jest": "^29.1.1",

packages/ai-providers/server-ai-openai/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"scripts": {
2727
"build": "tsup-node",
28-
"lint": "npx eslint . --ext .ts",
28+
"lint": "npx eslint .",
2929
"lint:fix": "yarn run lint --fix",
3030
"check": "yarn lint && yarn build && yarn test",
3131
"test": "jest"
@@ -47,11 +47,6 @@
4747
"@opentelemetry/api": "^1.9.0",
4848
"@traceloop/instrumentation-openai": "^0.22.0",
4949
"@types/jest": "^29.5.3",
50-
"@typescript-eslint/eslint-plugin": "^6.20.0",
51-
"@typescript-eslint/parser": "^6.20.0",
52-
"eslint": "^8.45.0",
53-
"eslint-plugin-import": "^2.27.5",
54-
"eslint-plugin-jest": "^27.6.3",
5550
"jest": "^29.6.1",
5651
"openai": "^5.0.0",
5752
"ts-jest": "^29.1.1",

0 commit comments

Comments
 (0)