Skip to content

Commit 2f2710c

Browse files
committed
fix lint
1 parent 9ef5640 commit 2f2710c

File tree

7 files changed

+35
-35
lines changed

7 files changed

+35
-35
lines changed

src/AzureAppConfigurationImpl.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
6161

6262
constructor(
6363
clientManager: ConfigurationClientManager,
64-
options: AzureAppConfigurationOptions | undefined,
64+
options: AzureAppConfigurationOptions | undefined,
6565
) {
6666
this.#options = options;
6767
this.#clientManager = clientManager;
@@ -322,12 +322,12 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
322322
}
323323
}
324324
}
325-
selector.pageEtags = pageEtags;
325+
selector.pageEtags = pageEtags;
326326
}
327327

328328
this.#featureFlagSelectors = selectors;
329329
return featureFlagsMap;
330-
}
330+
};
331331

332332
let featureFlagsMap = new Map<string, any>();
333333
featureFlagsMap = await this.#executeWithFailoverPolicy(funcToExecute);
@@ -504,10 +504,8 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
504504
}
505505
return needRefresh;
506506
};
507-
508-
let needRefresh: boolean;
509-
needRefresh = await this.#executeWithFailoverPolicy(funcToExecute);
510507

508+
const needRefresh: boolean = await this.#executeWithFailoverPolicy(funcToExecute);
511509
if (needRefresh) {
512510
try {
513511
await this.#loadFeatureFlags();
@@ -636,5 +634,5 @@ function getValidFeatureFlagSelectors(selectors?: SettingSelector[]): SettingSel
636634
}
637635

638636
function isFailoverableError(error: any): boolean {
639-
return (error instanceof RestError) && (error.statusCode === 408 || error.statusCode === 429 || (error.statusCode !== undefined && error.statusCode >= 500));
637+
return isRestError(error) && (error.statusCode === 408 || error.statusCode === 429 || (error.statusCode !== undefined && error.statusCode >= 500));
640638
}

src/AzureAppConfigurationOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const MaxRetryDelayInMs = 60000;
1313
export interface AzureAppConfigurationOptions {
1414
/**
1515
* Specifies whether enable replica discovery or not.
16-
*
16+
*
1717
* @remarks
1818
* If not specified, the default value is true.
1919
*/

src/ConfigurationClientManager.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT license.
33

44
import { AppConfigurationClient, AppConfigurationClientOptions } from "@azure/app-configuration";
5-
import { ConfigurationClientWrapper } from "./ConfigurationClientWrapper"
5+
import { ConfigurationClientWrapper } from "./ConfigurationClientWrapper";
66
import { TokenCredential } from "@azure/identity";
77
import { AzureAppConfigurationOptions, MaxRetries, MaxRetryDelayInMs } from "./AzureAppConfigurationOptions";
88
import { isFailoverableEnv } from "./requestTracing/utils";
@@ -14,18 +14,18 @@ const TCP = "_tcp";
1414
const EndpointSection = "Endpoint";
1515
const IdSection = "Id";
1616
const SecretSection = "Secret";
17-
const AzConfigDomainLabel = ".azconfig."
18-
const AppConfigDomainLabel = ".appconfig."
17+
const AzConfigDomainLabel = ".azconfig.";
18+
const AppConfigDomainLabel = ".appconfig.";
1919
const FallbackClientRefreshExpireInterval = 60 * 60 * 1000; // 1 hour in milliseconds
2020
const MinimalClientRefreshInterval = 30 * 1000; // 30 seconds in milliseconds
2121
const SrvQueryTimeout = 5000; // 5 seconds
2222

2323
interface IConfigurationClientManager {
24-
getClients(): ConfigurationClientWrapper[];
24+
getClients(): Promise<ConfigurationClientWrapper[]>;
2525
refreshClients(): Promise<void>;
2626
}
2727

28-
export class ConfigurationClientManager {
28+
export class ConfigurationClientManager implements IConfigurationClientManager {
2929
isFailoverable: boolean;
3030
#endpoint: string;
3131
#secret : string;
@@ -55,7 +55,7 @@ export class ConfigurationClientManager {
5555
this.#id = parseConnectionString(connectionString, IdSection);
5656
// TODO: need to check if it's CDN or not
5757
this.#endpoint = parseConnectionString(connectionString, EndpointSection);
58-
58+
5959
} else if (connectionStringOrEndpoint instanceof URL) {
6060
const credential = credentialOrOptions as TokenCredential;
6161
options = appConfigOptions as AzureAppConfigurationOptions;
@@ -69,7 +69,7 @@ export class ConfigurationClientManager {
6969

7070
this.#staticClients = [new ConfigurationClientWrapper(this.#endpoint, staticClient)];
7171
this.#validDomain = getValidDomain(this.#endpoint);
72-
this.isFailoverable = (options?.replicaDiscoveryEnabled ?? true) && isFailoverableEnv();
72+
this.isFailoverable = (options?.replicaDiscoveryEnabled ?? true) && isFailoverableEnv();
7373
}
7474

7575
async getClients() {
@@ -93,7 +93,7 @@ export class ConfigurationClientManager {
9393
.filter(client => client.backoffEndTime <= currentTime));
9494
}
9595

96-
return availableClients
96+
return availableClients;
9797
}
9898

9999
async refreshClients() {
@@ -155,7 +155,7 @@ export class ConfigurationClientManager {
155155

156156
#isFallbackClientDiscoveryDue(dateTime) {
157157
return dateTime >= this.#lastFallbackClientRefreshAttempt + MinimalClientRefreshInterval
158-
&& (!this.#dynamicClients
158+
&& (!this.#dynamicClients
159159
|| this.#dynamicClients.every(client => dateTime < client.backoffEndTime)
160160
|| dateTime >= this.#lastFallbackClientRefreshTime + FallbackClientRefreshExpireInterval);
161161
}
@@ -171,7 +171,7 @@ async function querySrvTargetHost(host) {
171171
let dns;
172172

173173
if (isFailoverableEnv()) {
174-
dns = require('dns/promises');
174+
dns = require("dns/promises");
175175
} else {
176176
return results;
177177
}
@@ -184,16 +184,18 @@ async function querySrvTargetHost(host) {
184184
}
185185

186186
// Add the first origin record to results
187-
const originHost = originRecords[0].name
187+
const originHost = originRecords[0].name;
188188
results.push(originHost);
189-
189+
190190
// Look up SRV records for alternate hosts
191191
let index = 0;
192-
while (true) {
192+
let moreAltRecordsExist = true;
193+
while (moreAltRecordsExist) {
193194
const currentAlt = `${ALT}${index}`;
194195
try {
195196
const altRecords = await dns.resolveSrv(`${currentAlt}.${TCP}.${originHost}`);
196197
if (altRecords.length === 0) {
198+
moreAltRecordsExist = false;
197199
break; // No more alternate records, exit loop
198200
}
199201

@@ -205,7 +207,7 @@ async function querySrvTargetHost(host) {
205207
});
206208
index++;
207209
} catch (err) {
208-
if (err.code === 'ENOTFOUND') {
210+
if (err.code === "ENOTFOUND") {
209211
break; // No more alternate records, exit loop
210212
} else {
211213
throw new Error(`Failed to lookup alternate SRV records: ${err.message}`);
@@ -221,7 +223,7 @@ async function querySrvTargetHost(host) {
221223

222224
/**
223225
* Parses the connection string to extract the value associated with a specific token.
224-
*
226+
*
225227
* @param {string} connectionString - The connection string containing tokens.
226228
* @param {string} token - The token whose value needs to be extracted.
227229
* @returns {string} The value associated with the token, or an empty string if not found.
@@ -241,7 +243,7 @@ function parseConnectionString(connectionString, token) {
241243

242244
// Move startIndex to the beginning of the token value
243245
const valueStartIndex = startIndex + searchToken.length;
244-
const endIndex = connectionString.indexOf(';', valueStartIndex);
246+
const endIndex = connectionString.indexOf(";", valueStartIndex);
245247
const valueEndIndex = endIndex === -1 ? connectionString.length : endIndex;
246248

247249
// Extract and return the token value
@@ -251,15 +253,15 @@ function parseConnectionString(connectionString, token) {
251253
/**
252254
* Builds a connection string from the given endpoint, secret, and id.
253255
* Returns an empty string if either secret or id is empty.
254-
*
256+
*
255257
* @param {string} endpoint - The endpoint to include in the connection string.
256258
* @param {string} secret - The secret to include in the connection string.
257259
* @param {string} id - The ID to include in the connection string.
258260
* @returns {string} - The formatted connection string or an empty string if invalid input.
259261
*/
260262
function buildConnectionString(endpoint, secret, id) {
261263
if (!secret || !id) {
262-
return '';
264+
return "";
263265
}
264266

265267
return `${EndpointSection}=${endpoint};${IdSection}=${id};${SecretSection}=${secret}`;
@@ -276,7 +278,7 @@ function getValidDomain(endpoint) {
276278
const url = new URL(endpoint);
277279
const trustedDomainLabels = [AzConfigDomainLabel, AppConfigDomainLabel];
278280
const host = url.hostname.toLowerCase();
279-
281+
280282
for (const label of trustedDomainLabels) {
281283
const index = host.lastIndexOf(label);
282284
if (index !== -1) {
@@ -292,7 +294,7 @@ function getValidDomain(endpoint) {
292294

293295
/**
294296
* Checks if the given host ends with the valid domain.
295-
*
297+
*
296298
* @param {string} host - The host to be validated.
297299
* @param {string} validDomain - The valid domain to check against.
298300
* @returns {boolean} - True if the host ends with the valid domain, false otherwise.
@@ -317,7 +319,7 @@ export function getClientOptions(options?: AzureAppConfigurationOptions): AppCon
317319
const defaultRetryOptions = {
318320
maxRetries: MaxRetries,
319321
maxRetryDelayInMs: MaxRetryDelayInMs,
320-
}
322+
};
321323
const retryOptions = Object.assign({}, defaultRetryOptions, options?.clientOptions?.retryOptions);
322324

323325
return Object.assign({}, options?.clientOptions, {

src/ConfigurationClientWrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ export function calculateBackoffDuration(failedAttempts: number) {
4646
const jitter = JITTER_RATIO * (Math.random() * 2 - 1);
4747

4848
return calculatedBackoffDuration * (1 + jitter);
49-
}
49+
}

src/load.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { TokenCredential } from "@azure/identity";
55
import { AzureAppConfiguration } from "./AzureAppConfiguration";
66
import { AzureAppConfigurationImpl } from "./AzureAppConfigurationImpl";
7-
import { AzureAppConfigurationOptions, MaxRetries, MaxRetryDelayInMs } from "./AzureAppConfigurationOptions";
7+
import { AzureAppConfigurationOptions } from "./AzureAppConfigurationOptions";
88
import { ConfigurationClientManager } from "./ConfigurationClientManager";
99

1010
const MIN_DELAY_FOR_UNHANDLED_ERROR: number = 5000; // 5 seconds

test/keyvault.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ describe("key vault reference", function () {
119119
expect(settings.get("TestKey")).eq("SecretValue");
120120
expect(settings.get("TestKey2")).eq("SecretValue2");
121121
});
122-
})
122+
});

test/utils/testHelper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function mockAppConfigurationClientListConfigurationSettings(...pages: Configura
9999
function mockConfigurationManagerGetClients(isFailoverable: boolean, clientOptions?: AppConfigurationClientOptions) {
100100
// Stub the getClients method on the class prototype
101101
sinon.stub(ConfigurationClientManager.prototype, "getClients").callsFake(async () => {
102-
let clients: ConfigurationClientWrapper[] = [];
102+
const clients: ConfigurationClientWrapper[] = [];
103103
const fakeEndpoint = createMockedEndpoint("fake");
104104
const fakeStaticClientWrapper = new ConfigurationClientWrapper(fakeEndpoint, new AppConfigurationClient(createMockedConnectionString(fakeEndpoint), clientOptions));
105105
clients.push(fakeStaticClientWrapper);
@@ -108,7 +108,7 @@ function mockConfigurationManagerGetClients(isFailoverable: boolean, clientOptio
108108
return clients;
109109
}
110110

111-
const fakeReplicaEndpoint = createMockedEndpoint(`fake-replica`);
111+
const fakeReplicaEndpoint = createMockedEndpoint("fake-replica");
112112
const fakeDynamicClientWrapper = new ConfigurationClientWrapper(fakeReplicaEndpoint, new AppConfigurationClient(createMockedConnectionString(fakeReplicaEndpoint), clientOptions));
113113
clients.push(fakeDynamicClientWrapper);
114114

@@ -233,4 +233,4 @@ export {
233233
createMockedFeatureFlag,
234234

235235
sleepInMs
236-
}
236+
};

0 commit comments

Comments
 (0)