Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

105 changes: 0 additions & 105 deletions .eslintrc.js

This file was deleted.

209 changes: 209 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

import tseslint from 'typescript-eslint';
import eslint from '@eslint/js';
import globals from 'globals';
import importPlugin from 'eslint-plugin-import-x';
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
import jest from 'eslint-plugin-jest';

const __dirname = dirname(fileURLToPath(import.meta.url));

export default tseslint.config(
// Global ignores (replaces .eslintignore + ignorePatterns)
{
ignores: [
'**/.yarn/**',
'**/dist/**',
'**/.next/**',
'**/.vite/**',
// NOTE: we are ignoring these examples because they were being ignored
// before, we will need to isolate specific rules for examples and
// remove these in the future.
'**/vercel/examples/**',
'**/react-native/example/**',
'**/react-native/example-fdv2/**',
'**/react/contract-tests/**',
'**/react/examples/**',
'**/jest/example/**',
'**/electron/example/**',
'**/svelte/.svelte-kit/**',
'**/svelte/example/**',
'**/fastly/example/build/**',
'**/server-ai/examples/chat-judge/**',
'**/server-ai/examples/direct-judge/**',
'**/fromExternal/**',
],
},

// Base config for all TypeScript files
{
files: ['**/*.ts', '**/*.tsx'],
extends: [
eslint.configs.recommended,
importPlugin.flatConfigs.recommended,
tseslint.configs.recommended
],
plugins: {
// Alias as 'import' so existing eslint-disable comments with import/ prefix keep working
import: importPlugin,
jest,
},
languageOptions: {
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
globals: {
...globals.node,
BigInt: 'readonly',
},
},
settings: {
'import-x/resolver-next': [
createTypeScriptImportResolver({
project: 'tsconfig.eslint.json',
}),
],
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
varsIgnorePattern: '^__',
caughtErrors: 'none',
},
],
// naming conventions
'@typescript-eslint/naming-convention': [
'error',
{
selector: ['method'],
format: ['camelCase'],
leadingUnderscore: 'forbid',
},
{
selector: ['method'],
format: ['camelCase'],
modifiers: ['private'],
leadingUnderscore: 'require',
},
{
selector: ['classProperty', 'parameterProperty'],
format: ['camelCase'],
leadingUnderscore: 'forbid',
},
{
selector: ['classProperty', 'parameterProperty'],
modifiers: ['static'],
format: ['PascalCase'],
leadingUnderscore: 'forbid',
},
{
selector: ['classProperty', 'parameterProperty'],
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'require',
},
],
'@typescript-eslint/no-empty-object-type': [
'error',
{ allowInterfaces: 'with-single-extends' },
],
'no-restricted-syntax': [
'error',
{ selector: 'ForInStatement', message: 'Use Object.{keys,values,entries} instead.' },
{ selector: 'LabeledStatement', message: 'Labels are a form of GOTO.' },
{ selector: 'WithStatement', message: '`with` is disallowed in strict mode.' },
],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
// NOTE: we should uncomment this in the future as config files typically
// only read from devdependencies
'**/jest*.ts',
// '**/*.config.ts',
'**/*.d.ts',
'**/*{.,_}test.{ts,tsx}',
// '**/*{.,_}spec.{ts,tsx}',
],
},
],
// enable url-scheme imports
'import-x/no-unresolved': ['error', { ignore: ['^[a-z]+:'] }],
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'no-await-in-loop': 'error',
'no-new': 'error',
'no-console': 'error',
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],

// NOTE: this will allow object fields to be reassigned.
'no-param-reassign': [ 'error' ],

// TODO: we may want to re-enable this in the future.
'@typescript-eslint/ban-ts-comment': 'off',

// extension rules (https://typescript-eslint.io/rules#extension-rules)
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",

// Keeping this as a reference, but I don't think we really need to enforce this rule.
// "class-methods-use-this": "off",
// "@typescript-eslint/class-methods-use-this": "error"
},
},

// Test files: add jest globals and jest rules; relax test-specific rules
{
files: [
'**/*.test.ts',
'**/*.test.tsx',
'**/__tests__/**/*.ts',
'**/__tests__/**/*.tsx'
],
languageOptions: {
globals: {
...globals.jest,
},
},
rules: {
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/valid-expect': 'error',
// 'no-console': 'off',
'@typescript-eslint/no-require-imports': 'off',
'import-x/no-unresolved': 'off',
},
},

// Examples, contract-tests, and tooling packages: allow console
{
files: [
'**/example/**',
'**/examples/**',
'**/example-*/**',
'**/contract-tests/**',
'packages/tooling/**',
],
rules: {
// TODO re-enable later
// 'no-console': 'off',
// TODO: a lot of our examples fail this one, will need to check
'import-x/no-unresolved': 'off',
},
},

// Override: contract-test-utils needs 'always' extensions (with ts exception)
{
files: ['packages/tooling/contract-test-utils/**/*.ts'],
rules: {
'import/extensions': ['error', 'always', { ts: 'never' }],
},
},
);
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,23 @@
"build": "yarn workspaces foreach -vp --topological-dev run build",
"//": "When using build:doc you need to specify the workspace. 'yarn run build:doc -- packages/shared/common' for example.",
"build:doc": "npx typedoc --options $1/typedoc.json",
"lint": "npx eslint . --ext .ts",
"lint:fix": "yarn run lint -- --fix",
"lint": "npx eslint .",
"lint:fix": "npx eslint . --fix",
"test": "echo Please run tests for individual packages.",
"coverage": "npm run test -- --coverage",
"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",
"check": "yarn && yarn lint && tsc && yarn build"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"@eslint/js": "^9.0.0",
"eslint": "^9.0.0",
"eslint-import-resolver-typescript": "^4.0.0",
"eslint-plugin-import-x": "^4.0.0",
"eslint-plugin-jest": "^28.0.0",
"globals": "^16.0.0",
"typedoc": "0.25.0",
"typescript": "5.1.6"
"typescript": "5.1.6",
"typescript-eslint": "^8.0.0"
},
"packageManager": "yarn@3.4.1",
"//": "Pin jsonc-parser because v3.3.0 breaks rollup-plugin-esbuild",
Expand Down
16 changes: 9 additions & 7 deletions packages/ai-providers/server-ai-langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"scripts": {
"build": "tsup-node",
"lint": "npx eslint . --ext .ts",
"lint": "npx eslint .",
"lint:fix": "yarn run lint --fix",
"check": "yarn lint && yarn build && yarn test",
"test": "jest"
Expand All @@ -42,21 +42,23 @@
"author": "LaunchDarkly",
"license": "Apache-2.0",
"devDependencies": {
"@eslint/js": "^9.0.0",
"@langchain/core": "^1.1.41",
"@launchdarkly/server-sdk-ai": "^0.18.0",
"@opentelemetry/api": "^1.9.0",
"@traceloop/instrumentation-langchain": "^0.26.0",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.45.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint": "^9.0.0",
"eslint-import-resolver-typescript": "^4.0.0",
"eslint-plugin-import-x": "^4.0.0",
"eslint-plugin-jest": "^28.0.0",
"globals": "^16.0.0",
"jest": "^29.6.1",
"langchain": "^1.3.4",
"ts-jest": "^29.1.1",
"tsup": "^8.5.1",
"typescript": "5.1.6"
"typescript": "5.1.6",
"typescript-eslint": "^8.0.0"
},
"peerDependencies": {
"@langchain/core": "^1.0.0",
Expand Down
Loading
Loading