Skip to content

Commit 5b6d4f2

Browse files
authored
refactor: fix lint issues (#1316)
This PR is the result of running `yarn lint:fix` with the configurations in https://github.com/launchdarkly/js-core/tree/skz/sdk-2234/remove-prettier <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/launchdarkly/js-core/pull/1316" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open in Devin Review"> </picture> </a> <!-- devin-review-badge-end --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Mostly mechanical lint/prettier autofixes (import/export ordering, ternary formatting, string literal normalization), but it also changes a few public entrypoints/exports ordering and adds `variationDetail` to `sdk-client`’s `LDClientImpl`, which could affect consumers relying on exact module shape or missing APIs. > > **Overview** > Applies repo-wide `yarn lint:fix` output: normalizes import ordering (including `type`-only imports), reformats conditional/ternary expressions, and replaces many template literals with plain string literals. > > Also adjusts several package entrypoints to reorder/re-export symbols consistently (e.g. `index.ts` files across browser/electron/react-native/server/edge/ai providers), and updates a few runtime import positions (notably Shopify Oxygen timer polyfill). > > Adds `variationDetail()` to `packages/shared/sdk-client`’s `LDClientImpl`, enabling detail-returning evaluations alongside existing `variation()`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 84065c1. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 68e8a58 commit 5b6d4f2

164 files changed

Lines changed: 642 additions & 644 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.

packages/ai-providers/server-ai-langchain/src/LangChainProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { BaseChatModel } from '@langchain/core/language_models/chat_models';
22
import { AIMessage, HumanMessage, SystemMessage } from '@langchain/core/messages';
33
import { initChatModel } from 'langchain/chat_models/universal';
44

5-
import { AIProvider } from '@launchdarkly/server-sdk-ai';
65
import type {
76
ChatResponse,
87
LDAIConfig,
@@ -12,6 +11,7 @@ import type {
1211
LDTokenUsage,
1312
StructuredResponse,
1413
} from '@launchdarkly/server-sdk-ai';
14+
import { AIProvider } from '@launchdarkly/server-sdk-ai';
1515

1616
let instrumentPromise: Promise<void> | undefined;
1717

@@ -61,7 +61,7 @@ export class LangChainProvider extends AIProvider {
6161
} catch {
6262
logger?.debug(
6363
'OpenTelemetry instrumentation not available for LangChain provider. ' +
64-
'Install @traceloop/instrumentation-langchain to enable automatic tracing.',
64+
'Install @traceloop/instrumentation-langchain to enable automatic tracing.',
6565
);
6666
}
6767
})();

packages/ai-providers/server-ai-openai/src/OpenAIProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { OpenAI } from 'openai';
22

3-
import { AIProvider } from '@launchdarkly/server-sdk-ai';
43
import type {
54
ChatResponse,
65
LDAIConfig,
@@ -10,6 +9,7 @@ import type {
109
LDTokenUsage,
1110
StructuredResponse,
1211
} from '@launchdarkly/server-sdk-ai';
12+
import { AIProvider } from '@launchdarkly/server-sdk-ai';
1313

1414
let instrumentPromise: Promise<void> | undefined;
1515

@@ -71,7 +71,7 @@ export class OpenAIProvider extends AIProvider {
7171
} catch {
7272
logger?.debug(
7373
'OpenTelemetry instrumentation not available for OpenAI provider. ' +
74-
'Install @traceloop/instrumentation-openai to enable automatic tracing.',
74+
'Install @traceloop/instrumentation-openai to enable automatic tracing.',
7575
);
7676
}
7777
})();

packages/ai-providers/server-ai-vercel/src/VercelProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { generateObject, generateText, jsonSchema, LanguageModel } from 'ai';
22

3-
import { AIProvider } from '@launchdarkly/server-sdk-ai';
43
import type {
54
ChatResponse,
65
LDAIConfig,
@@ -10,6 +9,7 @@ import type {
109
LDTokenUsage,
1110
StructuredResponse,
1211
} from '@launchdarkly/server-sdk-ai';
12+
import { AIProvider } from '@launchdarkly/server-sdk-ai';
1313

1414
import type {
1515
ModelUsageTokens,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export { VercelProvider } from './VercelProvider';
21
export type {
32
VercelAIModelParameters,
43
VercelAISDKConfig,
54
VercelAISDKMapOptions,
65
VercelAISDKProvider,
76
} from './types';
7+
export { VercelProvider } from './VercelProvider';

packages/sdk/akamai-base/example/ldClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EdgeProvider, init, LDContext } from '@launchdarkly/akamai-server-base-sdk';
22

3-
export type { LDContext, EdgeProvider };
3+
export type { EdgeProvider, LDContext };
44

55
const flagData = `
66
{

packages/sdk/browser/__tests__/MockHasher.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ export class MockHasher implements Hasher {
44
update(_data: string): Hasher {
55
return this;
66
}
7+
78
digest?(_encoding: string): string {
89
return 'hashed';
910
}
11+
1012
async asyncDigest?(_encoding: string): Promise<string> {
1113
return 'hashed';
1214
}

packages/sdk/browser/__tests__/bootstrap.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ it('can read old bootstrap data', () => {
121121
expect(logger.info).not.toHaveBeenCalled();
122122
expect(logger.warn).toHaveBeenCalledWith(
123123
'LaunchDarkly client was initialized with bootstrap data that did not' +
124-
' include flag metadata. Events may not be sent correctly.',
124+
' include flag metadata. Events may not be sent correctly.',
125125
);
126126
expect(logger.warn).toHaveBeenCalledTimes(1);
127127
expect(logger.error).not.toHaveBeenCalled();
@@ -143,7 +143,7 @@ it('can handle invalid bootstrap data', () => {
143143
expect(logger.info).not.toHaveBeenCalled();
144144
expect(logger.warn).toHaveBeenCalledWith(
145145
'LaunchDarkly bootstrap data is not available because the back end' +
146-
' could not read the flags.',
146+
' could not read the flags.',
147147
);
148148
expect(logger.warn).toHaveBeenCalledTimes(1);
149149
expect(logger.error).not.toHaveBeenCalled();

packages/sdk/browser/contract-tests/entity/src/ClientEntity.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
SynchronizerEntry,
99
} from '@launchdarkly/js-client-sdk';
1010
import {
11+
ClientSideTestHook as TestHook,
1112
CommandParams,
1213
CommandType,
1314
CreateInstanceParams,
@@ -16,7 +17,6 @@ import {
1617
SDKConfigDataSynchronizer,
1718
SDKConfigModeDefinition,
1819
SDKConfigParams,
19-
ClientSideTestHook as TestHook,
2020
ValueType,
2121
} from '@launchdarkly/js-contract-test-utils/client';
2222

@@ -123,9 +123,9 @@ function makeSdkConfig(options: SDKConfigParams, tag: string) {
123123

124124
if (options.dataSystem.connectionModeConfig) {
125125
const connMode = options.dataSystem.connectionModeConfig;
126-
dataSystem.automaticModeSwitching = connMode.initialConnectionMode
127-
? { type: 'manual', initialConnectionMode: connMode.initialConnectionMode }
128-
: false;
126+
dataSystem.automaticModeSwitching = connMode.initialConnectionMode ?
127+
{ type: 'manual', initialConnectionMode: connMode.initialConnectionMode } :
128+
false;
129129

130130
if (connMode.customConnectionModes) {
131131
const connectionModes: Record<string, any> = {};
@@ -323,9 +323,9 @@ export async function newSdkClientEntity(options: CreateInstanceParams) {
323323

324324
const timeout =
325325
options.configuration.startWaitTimeMs !== null &&
326-
options.configuration.startWaitTimeMs !== undefined
327-
? options.configuration.startWaitTimeMs
328-
: 5000;
326+
options.configuration.startWaitTimeMs !== undefined ?
327+
options.configuration.startWaitTimeMs :
328+
5000;
329329
const sdkConfig = makeSdkConfig(options.configuration, options.tag);
330330
const initialContext =
331331
options.configuration.clientSide?.initialUser ||

packages/sdk/browser/contract-tests/entity/src/TestHarnessWebSocket.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class TestHarnessWebSocket {
1212
constructor(private readonly _url: string) {}
1313

1414
connect() {
15-
this._logger.info(`Connecting to web socket.`);
15+
this._logger.info('Connecting to web socket.');
1616
this._ws = new WebSocket(this._url, ['v1']);
1717
this._ws.onopen = () => {
1818
this._logger.info('Connected to websocket.');
@@ -24,7 +24,7 @@ export default class TestHarnessWebSocket {
2424
}, 1000);
2525
};
2626
this._ws.onerror = (err) => {
27-
this._logger.info(`error:`, err);
27+
this._logger.info('error:', err);
2828
};
2929

3030
this._ws.onmessage = async (msg) => {

packages/sdk/browser/contract-tests/entity/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// eslint-disable-next-line prettier/prettier
21
import './style.css';
2+
33
import TestHarnessWebSocket from './TestHarnessWebSocket';
44

55
async function runContractTests() {

0 commit comments

Comments
 (0)