Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix eslint errors for search packages #11868

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 4 additions & 1 deletion sdk/search/search-documents/review/search-documents.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ export type GetIndexOptions = OperationOptions;
// @public
export type GetIndexStatisticsOptions = OperationOptions;

// @public
export type getSearchClientOptions = SearchIndexClientOptions;

// @public
export type GetServiceStatisticsOptions = OperationOptions;

Expand Down Expand Up @@ -1108,7 +1111,7 @@ export class SearchIndexClient {
readonly endpoint: string;
getIndex(indexName: string, options?: GetIndexOptions): Promise<SearchIndex>;
getIndexStatistics(indexName: string, options?: GetIndexStatisticsOptions): Promise<SearchIndexStatistics>;
getSearchClient<T>(indexName: string, options?: SearchClientOptions): SearchClient<T>;
getSearchClient<T>(indexName: string, options?: getSearchClientOptions): SearchClient<T>;
getServiceStatistics(options?: GetServiceStatisticsOptions): Promise<SearchServiceStatistics>;
getSynonymMap(synonymMapName: string, options?: GetSynonymMapsOptions): Promise<SynonymMap>;
listIndexes(options?: ListIndexesOptions): IndexIterator;
Expand Down
1 change: 1 addition & 0 deletions sdk/search/search-documents/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
CountDocumentsOptions,
DeleteDocumentsOptions,
GetDocumentOptions,
getSearchClientOptions,
IndexDocumentsAction,
ListSearchResultsPageSettings,
IndexDocumentsOptions,
Expand Down
5 changes: 5 additions & 0 deletions sdk/search/search-documents/src/indexModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ScoringStatistics
} from "./generated/data/models";
import { PagedAsyncIterableIterator } from "@azure/core-paging";
import { SearchIndexClientOptions } from "./searchIndexClient";

/**
* Options for performing the count operation on the index.
Expand Down Expand Up @@ -60,6 +61,10 @@ export type SearchIndexingBufferedSenderDeleteDocumentsOptions = OperationOption
*/
export type SearchIndexingBufferedSenderFlushDocumentsOptions = OperationOptions;

/**
* Alias of Search Index Client Options parameter to satisfy linting constraints
*/
export type getSearchClientOptions = SearchIndexClientOptions;
/**
* Options for retrieving a single document.
*/
Expand Down
5 changes: 3 additions & 2 deletions sdk/search/search-documents/src/searchIndexClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ import {
SearchIndexStatistics,
SearchServiceStatistics
} from "./serviceModels";
import { getSearchClientOptions } from "./indexModels";
import * as utils from "./serviceUtils";
import { createSpan } from "./tracing";
import { odataMetadataPolicy } from "./odataMetadataPolicy";
import { SearchClient, SearchClientOptions } from "./searchClient";
import { SearchClient } from "./searchClient";

/**
* Client options used to configure Cognitive Search API requests.
Expand Down Expand Up @@ -611,7 +612,7 @@ export class SearchIndexClient {
* @param indexName Name of the index
* @param options SearchClient Options
*/
public getSearchClient<T>(indexName: string, options?: SearchClientOptions): SearchClient<T> {
public getSearchClient<T>(indexName: string, options?: getSearchClientOptions): SearchClient<T> {
return new SearchClient<T>(this.endpoint, indexName, this.credential, options || this.options);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import {
IndexDocumentsAction,
SearchIndexingBufferedSenderUploadDocumentsOptions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { SearchClient } from "./searchClient";
import { IndexDocumentsBatch } from "./indexDocumentsBatch";
import {
Expand Down Expand Up @@ -78,7 +81,8 @@ class SearchIndexingBufferedSenderImpl<T> implements SearchIndexingBufferedSende
this.batchObject = new IndexDocumentsBatch<T>();
if (this.autoFlush) {
const interval = setInterval(() => this.flush(), this.flushWindowInMs);
interval?.unref();
const unblock = interval?.unref;
unblock();
this.cleanupTimer = () => {
clearInterval(interval);
};
Expand Down Expand Up @@ -244,7 +248,9 @@ class SearchIndexingBufferedSenderImpl<T> implements SearchIndexingBufferedSende
if (this.batchObject.actions.length > 0) {
await this.internalFlush(true);
}
this.cleanupTimer && this.cleanupTimer();
if (this.cleanupTimer) {
this.cleanupTimer();
}
}

/**
Expand Down
6 changes: 4 additions & 2 deletions sdk/search/search-documents/src/serviceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export function convertSimilarityToPublic(
return similarity;
}

if (similarity.odatatype == "#Microsoft.Azure.Search.ClassicSimilarity") {
if (similarity.odatatype === "#Microsoft.Azure.Search.ClassicSimilarity") {
return similarity as ClassicSimilarity;
} else {
return similarity as BM25Similarity;
Expand Down Expand Up @@ -370,7 +370,9 @@ export function generatedIndexToPublicIndex(generatedIndex: GeneratedSearchIndex
};
}

export function generatedSearchResultToPublicSearchResult<T>(results: GeneratedSearchResult[]) {
export function generatedSearchResultToPublicSearchResult<T>(
results: GeneratedSearchResult[]
): SearchResult<T>[] {
const returnValues: SearchResult<T>[] = results.map<SearchResult<T>>((result) => {
const { _score, _highlights, ...restProps } = result;
const doc: { [key: string]: any } = {
Expand Down
2 changes: 1 addition & 1 deletion sdk/search/search-documents/test/node/searchClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("SearchClient", function() {

it("autocomplete returns zero results for invalid query", async function() {
const autoCompleteResult: AutocompleteResult = await searchClient.autocomplete("garbxyz", "sg");
assert.isTrue(autoCompleteResult.results.length == 0);
assert.isTrue(autoCompleteResult.results.length === 0);
});

it("search returns the correct search result", async function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ describe("SearchIndexClient", function() {
];
assert.include(synonyms, synonymMap.synonyms[0]);
assert.include(synonyms, synonymMap.synonyms[1]);
} catch (ex) {
throw ex;
} finally {
await indexClient.deleteSynonymMap(synonymMap);
}
Expand Down Expand Up @@ -207,8 +205,6 @@ describe("SearchIndexClient", function() {
index = await indexClient.getIndex(indexName);
assert.equal(index.name, indexName);
assert.equal(index.fields.length, 5);
} catch (ex) {
throw ex;
} finally {
await indexClient.deleteIndex(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ describe("SearchIndexerClient", function() {
assert.equal(indexer.dataSourceName, "my-data-source-1");
assert.equal(indexer.targetIndexName, TEST_INDEX_NAME);
assert.isFalse(indexer.isDisabled);
} catch (ex) {
throw ex;
} finally {
await indexerClient.deleteIndexer(indexer);
}
Expand Down Expand Up @@ -178,8 +176,6 @@ describe("SearchIndexerClient", function() {
assert.equal(dataSourceConnection.name, "my-data-source-3");
assert.equal(dataSourceConnection.type, "cosmosdb");
assert.equal(dataSourceConnection.container.name, "hotels");
} catch (ex) {
throw ex;
} finally {
await indexerClient.deleteDataSourceConnection(dataSourceConnection);
}
Expand Down Expand Up @@ -267,8 +263,6 @@ describe("SearchIndexerClient", function() {
assert.equal(skillSet.skills.length, 1);
assert.equal(skillSet.skills[0].inputs.length, 2);
assert.equal(skillSet.skills[0].outputs.length, 3);
} catch (ex) {
throw ex;
} finally {
await indexerClient.deleteSkillset(skillSet);
}
Expand Down