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
34 changes: 30 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
module.exports = {
import stylistic from '@stylistic/eslint-plugin';

const __dirname = import.meta.dirname;

const stylisticConfig = stylistic.configs.customize({
semi: true,
arrowParens: true,
braceStyle: '1tbs',
quoteProps: 'as-needed',
});

export default {
env: {
node: true,
'jest/globals': true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: [
Expand All @@ -12,8 +23,9 @@ module.exports = {
],
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint', 'import', 'prettier', 'jest'],
plugins: ['@typescript-eslint', '@stylistic', 'simple-import-sort', 'import', 'jest'],
ignorePatterns: [
'**/node_modules/**',
'**/dist/**',
'**/vercel/examples/**',
'**/react-native/example/**',
Expand All @@ -22,6 +34,7 @@ module.exports = {
'**/server-ai/examples/chat-judge/**',
'**/server-ai/examples/direct-judge/**',
'**/fromExternal/**',
'**/next-env.d.ts',
],
rules: {
'no-param-reassign': 'error',
Expand All @@ -42,7 +55,20 @@ module.exports = {
'error',
{ ignoreRestSiblings: true, argsIgnorePattern: '^_', varsIgnorePattern: '^__' },
],
'prettier/prettier': ['error'],

...stylisticConfig.rules,
'@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
'@stylistic/operator-linebreak': ['error', 'after'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESLint operator-linebreak rule contradicts all code changes

High Severity

The @stylistic/operator-linebreak rule is set to 'after' (operator at end of line), but every source code change in this PR moves operators to the beginning of the next line ('before' style). The stylistic.configs.customize() default for this rule is 'before', which matches the code changes — but the explicit override on this line reverses it to 'after'. This will cause lint errors across all modified files (AttributeReference.ts, ContextFilter.ts, ClientMessages.ts, EventProcessor.ts, Backoff.ts, etc.) when yarn lint is run.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7e61ebb. Configure here.

Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
'@stylistic/jsx-one-expression-per-line': 'off',
'simple-import-sort/imports': ['error', {
groups: [
['^\\u0000'],
['^node:', '^(?!@launchdarkly)(?!\\.)'],
['^@launchdarkly'],
['^\\.'],
],
}],
'simple-import-sort/exports': 'error',
'class-methods-use-this': 'off',
'import/no-extraneous-dependencies': [
'error',
Expand Down
13 changes: 0 additions & 13 deletions .prettierignore

This file was deleted.

9 changes: 0 additions & 9 deletions .prettierrc

This file was deleted.

11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,20 @@
"//": "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:fix": "npx eslint . --ext .ts --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",
"prettier": "npx prettier --write \"**/*.{js,ts,tsx,json,yaml,yml,md}\" --log-level warn",
"check": "yarn && yarn prettier && yarn lint && tsc && yarn build"
"check": "yarn && yarn lint && tsc && yarn build"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@stylistic/eslint-plugin": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"typedoc": "0.25.0",
"typescript": "5.1.6"
},
Expand Down
11 changes: 4 additions & 7 deletions packages/ai-providers/server-ai-langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
"scripts": {
"build": "tsup-node",
"lint": "npx eslint . --ext .ts",
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
"lint:fix": "yarn run lint --fix",
"check": "yarn prettier && yarn lint && yarn build && yarn test",
"lint:fix": "npx eslint . --ext .ts --fix",
"check": "yarn lint:fix && yarn lint && yarn build && yarn test",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant lint after lint:fix in check scripts

Low Severity

The check scripts across ~18 packages use the pattern yarn lint:fix && yarn lint && ..., where yarn lint is always redundant. Since eslint --fix already exits non-zero when unfixable errors remain, the && chain stops before lint ever runs. If lint:fix succeeds (exit 0), all issues were fixed and lint will trivially pass. This wastes CI time running the linter twice and obscures intent.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 68e8a58. Configure here.

"test": "jest"
},
"files": [
Expand All @@ -47,19 +46,17 @@
"@langchain/core": "^0.3.0",
"@launchdarkly/server-sdk-ai": "^0.17.1",
"@opentelemetry/api": "^1.9.0",
"@stylistic/eslint-plugin": "^4.0.0",
"@traceloop/instrumentation-langchain": "^0.22.0",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "^29.6.1",
"langchain": "^0.3.0",
"prettier": "^3.0.0",
"ts-jest": "^29.1.1",
"tsup": "^8.5.1",
"typescript": "5.1.6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { BaseChatModel } from '@langchain/core/language_models/chat_models';
import { AIMessage, HumanMessage, SystemMessage } from '@langchain/core/messages';
import { initChatModel } from 'langchain/chat_models/universal';

import { AIProvider } from '@launchdarkly/server-sdk-ai';
import type {
ChatResponse,
LDAIConfig,
Expand All @@ -12,6 +11,7 @@ import type {
LDTokenUsage,
StructuredResponse,
} from '@launchdarkly/server-sdk-ai';
import { AIProvider } from '@launchdarkly/server-sdk-ai';

let instrumentPromise: Promise<void> | undefined;

Expand Down Expand Up @@ -61,7 +61,7 @@ export class LangChainProvider extends AIProvider {
} catch {
logger?.debug(
'OpenTelemetry instrumentation not available for LangChain provider. ' +
'Install @traceloop/instrumentation-langchain to enable automatic tracing.',
'Install @traceloop/instrumentation-langchain to enable automatic tracing.',
);
}
})();
Expand Down
11 changes: 4 additions & 7 deletions packages/ai-providers/server-ai-openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
"scripts": {
"build": "tsup-node",
"lint": "npx eslint . --ext .ts",
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
"lint:fix": "yarn run lint --fix",
"check": "yarn prettier && yarn lint && yarn build && yarn test",
"lint:fix": "npx eslint . --ext .ts --fix",
"check": "yarn lint:fix && yarn lint && yarn build && yarn test",
"test": "jest"
},
"files": [
Expand All @@ -46,19 +45,17 @@
"@launchdarkly/js-server-sdk-common": "2.18.5",
"@launchdarkly/server-sdk-ai": "^0.17.1",
"@opentelemetry/api": "^1.9.0",
"@stylistic/eslint-plugin": "^4.0.0",
"@traceloop/instrumentation-openai": "^0.22.0",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "^29.6.1",
"openai": "^5.0.0",
"prettier": "^3.0.0",
"ts-jest": "^29.1.1",
"tsup": "^8.5.1",
"typescript": "5.1.6"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { OpenAI } from 'openai';

import { AIProvider } from '@launchdarkly/server-sdk-ai';
import type {
ChatResponse,
LDAIConfig,
Expand All @@ -10,6 +9,7 @@ import type {
LDTokenUsage,
StructuredResponse,
} from '@launchdarkly/server-sdk-ai';
import { AIProvider } from '@launchdarkly/server-sdk-ai';

let instrumentPromise: Promise<void> | undefined;

Expand Down Expand Up @@ -71,7 +71,7 @@ export class OpenAIProvider extends AIProvider {
} catch {
logger?.debug(
'OpenTelemetry instrumentation not available for OpenAI provider. ' +
'Install @traceloop/instrumentation-openai to enable automatic tracing.',
'Install @traceloop/instrumentation-openai to enable automatic tracing.',
);
}
})();
Expand Down
11 changes: 4 additions & 7 deletions packages/ai-providers/server-ai-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
"scripts": {
"build": "tsup-node",
"lint": "npx eslint . --ext .ts",
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
"lint:fix": "yarn run lint --fix",
"check": "yarn prettier && yarn lint && yarn build && yarn test",
"lint:fix": "npx eslint . --ext .ts --fix",
"check": "yarn lint:fix && yarn lint && yarn build && yarn test",
"test": "jest"
},
"files": [
Expand All @@ -49,18 +48,16 @@
"@ai-sdk/mistral": "^2.0.0",
"@ai-sdk/openai": "^2.0.0",
"@launchdarkly/server-sdk-ai": "^0.17.1",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@stylistic/eslint-plugin": "^4.0.0",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"ai": "^5.0.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "^29.6.1",
"prettier": "^3.0.0",
"ts-jest": "^29.1.1",
"tsup": "^8.5.1",
"typescript": "5.1.6"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { generateObject, generateText, jsonSchema, LanguageModel } from 'ai';

import { AIProvider } from '@launchdarkly/server-sdk-ai';
import type {
ChatResponse,
LDAIConfig,
Expand All @@ -10,6 +9,7 @@ import type {
LDTokenUsage,
StructuredResponse,
} from '@launchdarkly/server-sdk-ai';
import { AIProvider } from '@launchdarkly/server-sdk-ai';

import type {
ModelUsageTokens,
Expand Down
2 changes: 1 addition & 1 deletion packages/ai-providers/server-ai-vercel/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { VercelProvider } from './VercelProvider';
export type {
VercelAIModelParameters,
VercelAISDKConfig,
VercelAISDKMapOptions,
VercelAISDKProvider,
} from './types';
export { VercelProvider } from './VercelProvider';
2 changes: 1 addition & 1 deletion packages/sdk/akamai-base/example/ldClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeProvider, init, LDContext } from '@launchdarkly/akamai-server-base-sdk';

export type { LDContext, EdgeProvider };
export type { EdgeProvider, LDContext };

const flagData = `
{
Expand Down
10 changes: 4 additions & 6 deletions packages/sdk/akamai-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,27 @@
"tsw": "yarn tsc --watch",
"start": "rimraf dist && yarn tsw",
"lint": "eslint . --ext .ts",
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
"test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest --ci --runInBand",
"coverage": "yarn test --coverage",
"check": "yarn prettier && yarn lint && yarn build && yarn test && yarn doc"
"check": "yarn lint:fix && yarn lint && yarn build && yarn test && yarn doc",
"lint:fix": "eslint . --ext .ts --fix"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.1",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@stylistic/eslint-plugin": "^4.0.0",
"@types/crypto-js": "^4.1.1",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "^29.5.0",
"launchdarkly-js-test-helpers": "^2.2.0",
"prettier": "^3.0.0",
"rimraf": "^5.0.0",
"rollup": "^3.23.0",
"rollup-plugin-generate-package-json": "^3.2.0",
Expand Down
10 changes: 4 additions & 6 deletions packages/sdk/akamai-edgekv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,27 @@
"tsw": "yarn tsc --watch",
"start": "rimraf dist && yarn tsw",
"lint": "eslint . --ext .ts",
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
"test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest --ci --runInBand",
"coverage": "yarn test --coverage",
"check": "yarn prettier && yarn lint && yarn build && yarn test && yarn doc"
"check": "yarn lint:fix && yarn lint && yarn build && yarn test && yarn doc",
"lint:fix": "eslint . --ext .ts --fix"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.1",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@stylistic/eslint-plugin": "^4.0.0",
"@types/crypto-js": "^4.1.1",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "^29.5.0",
"launchdarkly-js-test-helpers": "^2.2.0",
"prettier": "^3.0.0",
"rimraf": "^5.0.0",
"rollup": "^3.23.0",
"rollup-plugin-generate-package-json": "^3.2.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/browser/__tests__/MockHasher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ export class MockHasher implements Hasher {
update(_data: string): Hasher {
return this;
}

digest?(_encoding: string): string {
return 'hashed';
}

async asyncDigest?(_encoding: string): Promise<string> {
return 'hashed';
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/browser/__tests__/bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ it('can read old bootstrap data', () => {
expect(logger.info).not.toHaveBeenCalled();
expect(logger.warn).toHaveBeenCalledWith(
'LaunchDarkly client was initialized with bootstrap data that did not' +
' include flag metadata. Events may not be sent correctly.',
' include flag metadata. Events may not be sent correctly.',
);
expect(logger.warn).toHaveBeenCalledTimes(1);
expect(logger.error).not.toHaveBeenCalled();
Expand All @@ -143,7 +143,7 @@ it('can handle invalid bootstrap data', () => {
expect(logger.info).not.toHaveBeenCalled();
expect(logger.warn).toHaveBeenCalledWith(
'LaunchDarkly bootstrap data is not available because the back end' +
' could not read the flags.',
' could not read the flags.',
);
expect(logger.warn).toHaveBeenCalledTimes(1);
expect(logger.error).not.toHaveBeenCalled();
Expand Down
Loading
Loading