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

[storage]Clean up ESLint errors for storage packages. #16969

Merged
merged 5 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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: 1 addition & 1 deletion sdk/storage/storage-blob-changefeed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 \"dist-esm/storage-blob-changefeed/test/*.spec.js\" \"dist-esm/storage-blob-changefeed/test/node/*.spec.js\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix",
"lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o storage-blob-changefeed-lintReport.html || exit 0",
"lint": "eslint package.json api-extractor.json src test --ext .ts",
"pack": "npm pack 2>&1",
"prebuild": "npm run clean",
"test:browser": "echo 'browser not supported yet.'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export class BlobChangeFeedClient {
*/
public static fromConnectionString(
connectionString: string,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
): BlobChangeFeedClient {
const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString, options);
Expand Down Expand Up @@ -139,6 +141,8 @@ export class BlobChangeFeedClient {
constructor(
url: string,
credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
);

Expand All @@ -159,6 +163,8 @@ export class BlobChangeFeedClient {
| AnonymousCredential
| TokenCredential
| Pipeline,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
) {
this.changeFeedFactory = new ChangeFeedFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ChangeFeedFactory {
if (continuationToken) {
cursor = JSON.parse(continuationToken);
ChangeFeedFactory.validateCursor(containerClient, cursor!);
options.start = parseDateFromSegmentPath(cursor?.CurrentSegmentCursor.SegmentPath!);
options.start = parseDateFromSegmentPath(cursor!.CurrentSegmentCursor.SegmentPath!);
options.end = new Date(cursor!.EndTime!);
}
// Round start and end time if we are not using the cursor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class LazyLoadingBlobStream extends Readable {
*
* @param size - Optional. The size of data to be read
*/
public async _read(size?: number) {
public async _read(size?: number): Promise<void> {
const { span, updatedOptions } = createSpan("LazyLoadingBlobStream-read", this.options);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ export async function blobToString(blob: Blob): Promise<string> {
});
}

export function bodyToAvroReadable() {}
export function bodyToAvroReadable(): void {
/* empty */
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SDK_VERSION } from "../src/utils/constants";
import { setSpan, context } from "@azure/core-tracing";

import * as dotenv from "dotenv";
import { Context } from "mocha";
dotenv.config();

const timeoutForLargeFileUploadingTest = 20 * 60 * 1000;
Expand All @@ -20,13 +21,13 @@ describe("BlobChangeFeedClient", async () => {
let recorder: Recorder;
let changeFeedClient: BlobChangeFeedClient;

before(async function() {
before(async function(this: Context) {
if (process.env.CHANGE_FEED_ENABLED !== "1" && !isPlaybackMode()) {
this.skip();
}
});

beforeEach(async function() {
beforeEach(async function(this: Context) {
recorder = record(this, recorderEnvSetup);
changeFeedClient = getBlobChangeFeedClient();
});
Expand Down Expand Up @@ -179,13 +180,13 @@ describe("BlobChangeFeedClient: Change Feed not configured", async () => {
let recorder: Recorder;
let changeFeedClient: BlobChangeFeedClient;

before(async function() {
before(async function(this: Context) {
if (process.env.CHANGE_FEED_ENABLED === "1" && !isPlaybackMode()) {
this.skip();
}
});

beforeEach(async function() {
beforeEach(async function(this: Context) {
recorder = record(this, recorderEnvSetup);
changeFeedClient = getBlobChangeFeedClient();
});
Expand Down
12 changes: 6 additions & 6 deletions sdk/storage/storage-blob-changefeed/test/changefeed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,30 @@ describe("Change Feed", async () => {
});

it("no valid years in change feed container", async () => {
const yearPaths = [{ kind: "prefix", name: "idx/segments/1601/" }];
containerClientStub.listBlobsByHierarchy.withArgs("/").returns(fakeList(yearPaths) as any);
const newYearPaths = [{ kind: "prefix", name: "idx/segments/1601/" }];
containerClientStub.listBlobsByHierarchy.withArgs("/").returns(fakeList(newYearPaths) as any);
const changeFeed = await changeFeedFactory.create(serviceClientStub as any);
assert.ok(!changeFeed.hasNext());
});

it("no years after start time", async () => {
const yearPaths = [
const newYearPaths = [
{ kind: "prefix", name: "idx/segments/1601/" },
{ kind: "prefix", name: "idx/segments/2019/" }
];
containerClientStub.listBlobsByHierarchy.withArgs("/").returns(fakeList(yearPaths) as any);
containerClientStub.listBlobsByHierarchy.withArgs("/").returns(fakeList(newYearPaths) as any);
const changeFeed = await changeFeedFactory.create(serviceClientStub as any, undefined, {
start: new Date(Date.UTC(2020, 0))
});
assert.ok(!changeFeed.hasNext());
});

it("no segments remaining in start year", async () => {
const yearPaths = [
const newYearPaths = [
{ kind: "prefix", name: "idx/segments/1601/" },
{ kind: "prefix", name: "idx/segments/2019/" }
];
containerClientStub.listBlobsByHierarchy.withArgs("/").returns(fakeList(yearPaths) as any);
containerClientStub.listBlobsByHierarchy.withArgs("/").returns(fakeList(newYearPaths) as any);

const segments = [
{ name: "idx/segments/2019/03/02/2000/meta.json" },
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/storage-blob-changefeed/test/segment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ describe("Segment", async () => {

const shardRemainingCount = shardCount - 1;
for (let i = 0; i < shardRemainingCount; i++) {
const event = await segment.getChange();
assert.equal(event, (i + 2) % shardCount);
const changedEvent = await segment.getChange();
assert.equal(changedEvent, (i + 2) % shardCount);
}
const event2 = await segment.getChange();
assert.equal(event2, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ export function padStart(
targetLength: number,
padString: string = " "
): string {
// TS doesn't know this code needs to run downlevel sometimes.
// @ts-expect-error
// @ts-expect-error TS doesn't know this code needs to run downlevel sometimes.
EmmaZhu marked this conversation as resolved.
Show resolved Hide resolved
if (String.prototype.padStart) {
return currentString.padStart(targetLength, padString);
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-file-datalake/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 120000 \"dist-esm/storage-file-datalake/test/*.spec.js\" \"dist-esm/storage-file-datalake/test/node/*.spec.js\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix",
"lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o storage-file-datalake-lintReport.html || exit 0",
"lint": "eslint package.json api-extractor.json src test --ext .ts",
"pack": "npm pack 2>&1",
"prebuild": "npm run clean",
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export class DataLakeFileSystemClient extends StorageClient {
constructor(
url: string,
credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
);

Expand All @@ -104,6 +106,8 @@ export class DataLakeFileSystemClient extends StorageClient {
| AnonymousCredential
| TokenCredential
| Pipeline,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
) {
if (credentialOrPipeline instanceof Pipeline) {
Expand Down Expand Up @@ -139,6 +143,8 @@ export class DataLakeFileSystemClient extends StorageClient {
*
* @param directoryName -
*/
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-subclients */
public getDirectoryClient(directoryName: string): DataLakeDirectoryClient {
return new DataLakeDirectoryClient(
appendToURLPath(this.url, encodeURIComponent(directoryName)),
Expand All @@ -151,6 +157,8 @@ export class DataLakeFileSystemClient extends StorageClient {
*
* @param fileName -
*/
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-subclients */
public getFileClient(fileName: string): DataLakeFileClient {
return new DataLakeFileClient(
appendToURLPath(this.url, encodeURIComponent(fileName)),
Expand Down Expand Up @@ -754,7 +762,7 @@ export class DataLakeFileSystemClient extends StorageClient {
});
}

if (!(response.nextMarker == undefined || response.nextMarker === "")) {
if (!(response.nextMarker === undefined || response.nextMarker === "")) {
response.continuation = response.nextMarker;
}

Expand Down
16 changes: 15 additions & 1 deletion sdk/storage/storage-file-datalake/src/DataLakeServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ export class DataLakeServiceClient extends StorageClient {
* `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`
* @param options - Optional. Options to configure the HTTP pipeline.
*/
public static fromConnectionString(connectionString: string, options?: StoragePipelineOptions) {
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
public static fromConnectionString(
connectionString: string,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
): DataLakeServiceClient {
options = options || {};
const extractedCreds = extractConnectionStringParts(connectionString);
if (extractedCreds.kind === "AccountConnString") {
Expand Down Expand Up @@ -106,6 +113,8 @@ export class DataLakeServiceClient extends StorageClient {
public constructor(
url: string,
credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
);

Expand All @@ -127,6 +136,8 @@ export class DataLakeServiceClient extends StorageClient {
| AnonymousCredential
| TokenCredential
| Pipeline,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
) {
if (credentialOrPipeline instanceof Pipeline) {
Expand All @@ -152,6 +163,8 @@ export class DataLakeServiceClient extends StorageClient {
*
* @param fileSystemName - File system name.
*/
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-subclients */
public getFileSystemClient(fileSystemName: string): DataLakeFileSystemClient {
return new DataLakeFileSystemClient(
appendToURLPath(this.url, encodeURIComponent(fileSystemName)),
Expand Down Expand Up @@ -351,6 +364,7 @@ export class DataLakeServiceClient extends StorageClient {
* @param destinationContainerName - The new name of the File System.
* @param options - Options to configure File System Rename operation.
*/
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
// @ts-ignore Need to hide this interface for now. Make it public and turn on the live tests for it when the service is ready.
private async renameFileSystem(
sourceFileSystemName: string,
Expand Down
20 changes: 18 additions & 2 deletions sdk/storage/storage-file-datalake/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ export class DataLakePathClient extends StorageClient {
public constructor(
url: string,
credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
);

Expand All @@ -240,6 +242,8 @@ export class DataLakePathClient extends StorageClient {
| AnonymousCredential
| TokenCredential
| Pipeline,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
) {
if (credentialOrPipeline instanceof Pipeline) {
Expand Down Expand Up @@ -282,6 +286,8 @@ export class DataLakePathClient extends StorageClient {
* Convert current DataLakePathClient to DataLakeDirectoryClient if current path is a directory.
*
*/
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-subclients */
public toDirectoryClient(): DataLakeDirectoryClient {
return new DataLakeDirectoryClient(this.dfsEndpointUrl, this.pipeline);
}
Expand All @@ -290,6 +296,8 @@ export class DataLakePathClient extends StorageClient {
* Convert current DataLakePathClient to DataLakeFileClient if current path is a file.
*
*/
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-subclients */
public toFileClient(): DataLakeFileClient {
return new DataLakeFileClient(this.dfsEndpointUrl, this.pipeline);
}
Expand Down Expand Up @@ -1018,6 +1026,8 @@ export class DataLakeDirectoryClient extends DataLakePathClient {
*
* @param fileName -
*/
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-subclients */
public getFileClient(fileName: string): DataLakeFileClient {
return new DataLakeFileClient(
appendToURLPath(this.url, encodeURIComponent(fileName)),
Expand Down Expand Up @@ -1090,6 +1100,8 @@ export class DataLakeFileClient extends DataLakePathClient {
public constructor(
url: string,
credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
);

Expand All @@ -1111,6 +1123,8 @@ export class DataLakeFileClient extends DataLakePathClient {
| AnonymousCredential
| TokenCredential
| Pipeline,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options?: StoragePipelineOptions
) {
if (credentialOrPipeline instanceof Pipeline) {
Expand Down Expand Up @@ -1428,17 +1442,19 @@ export class DataLakeFileClient extends DataLakePathClient {
*/
public async uploadFile(
filePath: string,
// Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
/* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
options: FileParallelUploadOptions = {}
): Promise<FileUploadResponse> {
const { span, updatedOptions } = createSpan("DataLakeFileClient-uploadFile", options);
try {
const size = (await fsStat(filePath)).size;
return await this.uploadSeekableInternal(
(offset: number, size: number) => {
(offset: number, contentSize: number) => {
return () =>
fsCreateReadStream(filePath, {
autoClose: true,
end: offset + size - 1,
end: offset + contentSize - 1,
start: offset
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ export abstract class Credential implements RequestPolicyFactory {
* @param _nextPolicy -
* @param _options -
*/
public create(
// tslint:disable-next-line:variable-name
_nextPolicy: RequestPolicy,
// tslint:disable-next-line:variable-name
_options: RequestPolicyOptions
): RequestPolicy {
public create(_nextPolicy: RequestPolicy, _options: RequestPolicyOptions): RequestPolicy {
throw new Error("Method should be implemented in children classes.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export class AnonymousCredentialPolicy extends CredentialPolicy {
* @param nextPolicy -
* @param options -
*/

// The base class has a protected constructor. Adding a public one to enable constructing of this class.
/* eslint-disable-next-line @typescript-eslint/no-useless-constructor*/
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) {
super(nextPolicy, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export class StorageBrowserPolicy extends BaseRequestPolicy {
* @param nextPolicy -
* @param options -
*/

// The base class has a protected constructor. Adding a public one to enable constructing of this class.
/* eslint-disable-next-line @typescript-eslint/no-useless-constructor*/
constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) {
super(nextPolicy, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class StorageRetryPolicy extends BaseRequestPolicy {
}

await this.delay(isPrimaryRetry, attempt, request.abortSignal);
return await this.attemptSendRequest(request, secondaryHas404, ++attempt);
return this.attemptSendRequest(request, secondaryHas404, ++attempt);
}

/**
Expand Down
Loading