Skip to content

Commit

Permalink
[eventhubs-checkpointstore-blob] fixes eslint errors (#14677)
Browse files Browse the repository at this point in the history
Resolves #10777 by addressing the last outstanding item.

With this change, `@azure/eventhubs-checkpointstore-blob` now no longer has eslint errors.
  • Loading branch information
chradek committed Apr 2, 2021
1 parent ad31d2a commit f3520b9
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 39 deletions.
2 changes: 1 addition & 1 deletion sdk/eventhub/eventhubs-checkpointstore-blob/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 --timeout 1200000 --full-trace \"dist-esm/test/*.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 checkpointstore-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 build:test && npm run unit-test:browser && npm run integration-test:browser",
Expand Down
8 changes: 4 additions & 4 deletions sdk/eventhub/eventhubs-checkpointstore-blob/src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const logger = createClientLogger("eventhubs-checkpointstore-blob");
/**
* Logs the error's stack trace to "verbose" if a stack trace is available.
* @param error - Error containing a stack trace.
* @hidden
* @internal
*/
export function logErrorStackTrace(error: any): void {
if (error && error.stack) {
logger.verbose(error.stack);
export function logErrorStackTrace(error: unknown): void {
if (error && typeof error === "object" && "stack" in error) {
logger.verbose((error as any).stack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { logger, logErrorStackTrace } from "../log";
export function throwTypeErrorIfParameterMissing(
methodName: string,
parameterName: string,
parameterValue: any
parameterValue: unknown
): void {
if (parameterValue === undefined || parameterValue === null) {
const error = new TypeError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ describe("Blob Checkpoint Store", function(): void {
]);
fail("Should have thrown an error - this isn't a normal claim collision issue");
} catch (err) {
(err instanceof RestError).should.be.ok;
should.equal(err instanceof RestError, true, "Error is unexpected type.");
// 404 because the container is missing (since we deleted it up above)
(err as RestError).statusCode!.should.equal(404);
}
Expand Down Expand Up @@ -257,14 +257,30 @@ describe("Blob Checkpoint Store", function(): void {
"testConsumerGroup"
);

ownershipList.length.should.equal(1);
ownershipList[0].ownerId.should.equal("Id1");
ownershipList[0].partitionId.should.equal("0");
ownershipList[0].consumerGroup.should.equal("testConsumerGroup");
ownershipList[0].fullyQualifiedNamespace.should.equal("testNamespace.servicebus.windows.net");
ownershipList[0].eventHubName.should.equal("testEventHub");
ownershipList[0].lastModifiedTimeInMs!.should.not.undefined;
ownershipList[0].etag!.should.not.undefined;
should.equal(ownershipList.length, 1, "Unexpected number of ownerships in list.");
should.equal(ownershipList[0].ownerId, "Id1", "The 1st ownership item has the wrong ownerId.");
should.equal(
ownershipList[0].consumerGroup,
"testConsumerGroup",
"The 1st ownership item has the wrong consumerGroup."
);
should.equal(
ownershipList[0].fullyQualifiedNamespace,
"testNamespace.servicebus.windows.net",
"The 1st fullyQualifiedNamespace item has the wrong fullyQualifiedNamespace."
);
should.equal(
ownershipList[0].eventHubName,
"testEventHub",
"The 1st ownership item has the wrong eventHubName."
);
should.equal(
ownershipList[0].partitionId,
"0",
"The 1st ownership item has the wrong partitionId."
);
should.exist(ownershipList[0].lastModifiedTimeInMs, "lastModifiedTimeInMs should exist.");
should.exist(ownershipList[0].etag, "etag should exist.");

debug(
`LastModifiedTime: ${ownershipList[0].lastModifiedTimeInMs!}, ETag: ${ownershipList[0].etag}`
Expand Down Expand Up @@ -299,14 +315,31 @@ describe("Blob Checkpoint Store", function(): void {
"testEventHub",
"testConsumerGroup"
);
ownershipList.length.should.equal(1);
ownershipList[0].ownerId.should.equal("Id1");
ownershipList[0].partitionId.should.equal("0");
ownershipList[0].fullyQualifiedNamespace.should.equal("testNamespace.servicebus.windows.net");
ownershipList[0].consumerGroup.should.equal("testConsumerGroup");
ownershipList[0].eventHubName.should.equal("testEventHub");
ownershipList[0].lastModifiedTimeInMs!.should.not.undefined;
ownershipList[0].etag!.should.not.undefined;

should.equal(ownershipList.length, 1, "Unexpected number of ownerships in list.");
should.equal(ownershipList[0].ownerId, "Id1", "The 1st ownership item has the wrong ownerId.");
should.equal(
ownershipList[0].consumerGroup,
"testConsumerGroup",
"The 1st ownership item has the wrong consumerGroup."
);
should.equal(
ownershipList[0].fullyQualifiedNamespace,
"testNamespace.servicebus.windows.net",
"The 1st fullyQualifiedNamespace item has the wrong fullyQualifiedNamespace."
);
should.equal(
ownershipList[0].eventHubName,
"testEventHub",
"The 1st ownership item has the wrong eventHubName."
);
should.equal(
ownershipList[0].partitionId,
"0",
"The 1st ownership item has the wrong partitionId."
);
should.exist(ownershipList[0].lastModifiedTimeInMs, "lastModifiedTimeInMs should exist.");
should.exist(ownershipList[0].etag, "etag should exist.");
debug(
`LastModifiedTime: ${ownershipList[0].lastModifiedTimeInMs!}, ETag: ${ownershipList[0].etag}`
);
Expand Down Expand Up @@ -345,23 +378,48 @@ describe("Blob Checkpoint Store", function(): void {
"testEventHub",
"testConsumerGroup"
);
ownershipList.length.should.equal(3);

ownershipList[0].partitionId.should.equal("0");
ownershipList[0].ownerId.should.equal("Id1");
ownershipList[0].consumerGroup.should.equal("testConsumerGroup");
ownershipList[0].fullyQualifiedNamespace.should.equal("testNamespace.servicebus.windows.net");
ownershipList[0].eventHubName.should.equal("testEventHub");
ownershipList[0].lastModifiedTimeInMs!.should.not.undefined;
ownershipList[0].etag!.should.not.undefined;
should.equal(ownershipList.length, 3, "Unexpected number of ownerships in list.");

should.equal(ownershipList[0].ownerId, "Id1", "The 1st ownership item has the wrong ownerId.");
should.equal(
ownershipList[0].consumerGroup,
"testConsumerGroup",
"The 1st ownership item has the wrong consumerGroup."
);
should.equal(
ownershipList[0].fullyQualifiedNamespace,
"testNamespace.servicebus.windows.net",
"The 1st fullyQualifiedNamespace item has the wrong fullyQualifiedNamespace."
);
should.equal(
ownershipList[0].eventHubName,
"testEventHub",
"The 1st ownership item has the wrong eventHubName."
);
should.equal(
ownershipList[0].partitionId,
"0",
"The 1st ownership item has the wrong partitionId."
);
should.exist(ownershipList[0].lastModifiedTimeInMs, "lastModifiedTimeInMs should exist.");
should.exist(ownershipList[0].etag, "etag should exist.");

ownershipList[1].partitionId.should.equal("1");
ownershipList[1].lastModifiedTimeInMs!.should.not.undefined;
ownershipList[1].etag!.should.not.undefined;
should.equal(
ownershipList[1].partitionId,
"1",
"The 2nd ownership item has the wrong partitionId."
);
should.exist(ownershipList[1].lastModifiedTimeInMs, "lastModifiedTimeInMs should exist.");
should.exist(ownershipList[1].etag, "etag should exist.");

ownershipList[2].partitionId.should.equal("2");
ownershipList[2].lastModifiedTimeInMs!.should.not.undefined;
ownershipList[2].etag!.should.not.undefined;
should.equal(
ownershipList[2].partitionId,
"2",
"The 3rd ownership item has the wrong partitionId."
);
should.exist(ownershipList[2].lastModifiedTimeInMs, "lastModifiedTimeInMs should exist.");
should.exist(ownershipList[2].etag, "etag should exist.");
});

describe("listCheckpoints", function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import * as dotenv from "dotenv";
dotenv.config();

declare const self: any;

export const isNode =
!!process && !!process.version && !!process.versions && !!process.versions.node;

Expand All @@ -15,8 +17,7 @@ function getEnvVarValue(name: string): string | undefined {
if (isNode) {
return process.env[name];
} else {
// @ts-ignore
return window.__env__[name];
return self.__env__[name];
}
}

Expand Down

0 comments on commit f3520b9

Please sign in to comment.