Skip to content

Commit

Permalink
[Core lro] Update linting scripts and auto linting (#11273)
Browse files Browse the repository at this point in the history
* [Core lro] Update linting scripts and auto linting

* applying formatting changes

* address Jeff's feedback

* remove dist-esm/**

* adding dist-esm/src back
  • Loading branch information
deyaaeldeen authored Sep 25, 2020
1 parent 2eb4260 commit 0d5bd96
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 36 deletions.
31 changes: 15 additions & 16 deletions sdk/core/core-lro/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"name": "@azure/core-lro",
"author": {
"name": "Microsoft Corporation",
"email": "[email protected]",
"url": "https://github.com/Azure/azure-sdk-for-js"
},
"author": "Microsoft Corporation",
"sdk-type": "client",
"version": "1.0.3",
"description": "LRO Polling strtegy for the Azure SDK in TypeScript",
Expand All @@ -24,30 +20,32 @@
"node",
"microsoft",
"lro",
"polling"
"polling",
"azure",
"cloud"
],
"main": "./dist/index.js",
"module": "dist-esm/src/index.js",
"types": "./types/core-lro.d.ts",
"files": [
"types/core-lro.d.ts",
"dist-esm/src",
"dist/",
"dist-esm/",
"README.md",
"LICENSE"
],
"engines": {
"node": ">=8.0.0"
},
"browser": {
"os": false,
"process": false
},
"license": "MIT",
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-lro",
"repository": {
"type": "git",
"url": "[email protected]:Azure/azure-sdk-for-js.git"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-lro/README.md",
"repository": "github:Azure/azure-sdk-for-js",
"bugs": {
"url": "http://github.com/Azure/azure-sdk-for-js/issues"
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"nyc": {
"extension": [
Expand Down Expand Up @@ -80,9 +78,9 @@
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint -c ../../.eslintrc.old.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint -c ../../.eslintrc.old.json src test --ext .ts -f html -o core-lro-lintReport.html || exit 0",
"lint:terminal": "eslint -c ../../.eslintrc.old.json src test --ext .ts",
"lint:fix": "eslint -c ../../../.eslintrc.json package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint -c ../../../.eslintrc.json package.json api-extractor.json src test --ext .ts",
"lint:terminal": "eslint -c ../../../.eslintrc.json package.json api-extractor.json src test --ext .ts",
"test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
"test": "npm run build:test && npm run unit-test",
Expand All @@ -100,6 +98,7 @@
"tslib": "^2.0.0"
},
"devDependencies": {
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@opentelemetry/api": "^0.10.2",
"@microsoft/api-extractor": "7.7.11",
"@rollup/plugin-commonjs": "11.0.2",
Expand Down
6 changes: 4 additions & 2 deletions sdk/core/core-lro/src/poller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ export abstract class Poller<TState extends PollOperationState<TResult>, TResult
// This prevents the UnhandledPromiseRejectionWarning in node.js from being thrown.
// The above warning would get thrown if `poller.poll` is called, it returns an error,
// and pullUntilDone did not have a .catch or await try/catch on it's return value.
this.promise.catch(() => {});
this.promise.catch(() => {
/* intentionally blank */
});
}

/**
Expand Down Expand Up @@ -371,7 +373,7 @@ export abstract class Poller<TState extends PollOperationState<TResult>, TResult
const clearPollOncePromise = (): void => {
this.pollOncePromise = undefined;
};
this.pollOncePromise.then(clearPollOncePromise, clearPollOncePromise);
this.pollOncePromise.then(clearPollOncePromise, clearPollOncePromise).catch(this.reject);
}
return this.pollOncePromise;
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-lro/src/shims.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

// d.ts shims provide types for things we use internally but are not part
// of this package's surface area.
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-lro/test/testClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("Long Running Operations - custom client", function() {
const result = await poller.pollUntilDone();

// Checking the serialized version of the operation
let serializedOperation: { state: TestOperationState } = JSON.parse(poller.toString());
const serializedOperation: { state: TestOperationState } = JSON.parse(poller.toString());
assert.ok(serializedOperation.state.isStarted);

assert.ok(poller.initialResponse!.parsedBody.started);
Expand Down
14 changes: 1 addition & 13 deletions sdk/core/core-lro/test/utils/testClient.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import {
ServiceClientCredentials,
ServiceClientOptions,
TokenCredential,
RequestOptionsBase
} from "@azure/core-http";
import { RequestOptionsBase } from "@azure/core-http";
import { TestServiceClient } from "./testServiceClient";
import { TestPoller } from "./testPoller";
import { TestNonCancellablePoller } from "./testNonCancellablePoller";
Expand All @@ -20,13 +15,6 @@ interface StartLROOptions {
}

export class TestClient extends TestServiceClient {
constructor(
credentials: TokenCredential | ServiceClientCredentials,
options?: ServiceClientOptions
) {
super(credentials, options);
}

public async startLRO(options: StartLROOptions = {}): Promise<TestPoller> {
const poller = new TestPoller(
this,
Expand Down
3 changes: 2 additions & 1 deletion sdk/core/core-lro/test/utils/testOperation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/* eslint-disable no-invalid-this */

import { HttpOperationResponse, RequestOptionsBase } from "@azure/core-http";
import { AbortSignalLike } from "@azure/abort-controller";
Expand Down Expand Up @@ -77,7 +78,7 @@ async function cancel(

if (abortSignal && abortSignal.aborted) {
// Simulating a try catch of an HTTP request that's given an aborted abortSignal.
return await this.update({
return this.update({
abortSignal
}); // This will throw
}
Expand Down
4 changes: 3 additions & 1 deletion sdk/core/core-lro/test/utils/testServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
RequestOptionsBase
} from "@azure/core-http";

interface TestServiceClientOptions extends ServiceClientOptions {}

export class TestServiceClient extends ServiceClient {
private responses: HttpOperationResponse[] = [];
private initialResponse?: HttpOperationResponse;
Expand All @@ -19,7 +21,7 @@ export class TestServiceClient extends ServiceClient {

constructor(
credentials: TokenCredential | ServiceClientCredentials,
options?: ServiceClientOptions
options?: TestServiceClientOptions
) {
super(credentials, options);
this.credentials = credentials;
Expand Down

0 comments on commit 0d5bd96

Please sign in to comment.