From 0d5bd9638865ae352d0b1d271553741cecc6c703 Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Fri, 25 Sep 2020 16:43:16 -0400 Subject: [PATCH] [Core lro] Update linting scripts and auto linting (#11273) * [Core lro] Update linting scripts and auto linting * applying formatting changes * address Jeff's feedback * remove dist-esm/** * adding dist-esm/src back --- sdk/core/core-lro/package.json | 31 +++++++++---------- sdk/core/core-lro/src/poller.ts | 6 ++-- sdk/core/core-lro/src/shims.d.ts | 4 +-- sdk/core/core-lro/test/testClient.test.ts | 2 +- sdk/core/core-lro/test/utils/testClient.ts | 14 +-------- sdk/core/core-lro/test/utils/testOperation.ts | 3 +- .../core-lro/test/utils/testServiceClient.ts | 4 ++- 7 files changed, 28 insertions(+), 36 deletions(-) diff --git a/sdk/core/core-lro/package.json b/sdk/core/core-lro/package.json index 0c68a1097d7f..eb2f78645346 100644 --- a/sdk/core/core-lro/package.json +++ b/sdk/core/core-lro/package.json @@ -1,10 +1,6 @@ { "name": "@azure/core-lro", - "author": { - "name": "Microsoft Corporation", - "email": "azsdkteam@microsoft.com", - "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", @@ -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": "git@github.com: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": [ @@ -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", @@ -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", diff --git a/sdk/core/core-lro/src/poller.ts b/sdk/core/core-lro/src/poller.ts index b46553bd7dfb..73d62c984462 100644 --- a/sdk/core/core-lro/src/poller.ts +++ b/sdk/core/core-lro/src/poller.ts @@ -255,7 +255,9 @@ export abstract class Poller, 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 */ + }); } /** @@ -371,7 +373,7 @@ export abstract class Poller, TResult const clearPollOncePromise = (): void => { this.pollOncePromise = undefined; }; - this.pollOncePromise.then(clearPollOncePromise, clearPollOncePromise); + this.pollOncePromise.then(clearPollOncePromise, clearPollOncePromise).catch(this.reject); } return this.pollOncePromise; } diff --git a/sdk/core/core-lro/src/shims.d.ts b/sdk/core/core-lro/src/shims.d.ts index c22749fe94f2..3019dc5d04ac 100644 --- a/sdk/core/core-lro/src/shims.d.ts +++ b/sdk/core/core-lro/src/shims.d.ts @@ -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. diff --git a/sdk/core/core-lro/test/testClient.test.ts b/sdk/core/core-lro/test/testClient.test.ts index d451e8b2584c..1fdb6e0482b1 100644 --- a/sdk/core/core-lro/test/testClient.test.ts +++ b/sdk/core/core-lro/test/testClient.test.ts @@ -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); diff --git a/sdk/core/core-lro/test/utils/testClient.ts b/sdk/core/core-lro/test/utils/testClient.ts index 9b5fb9e0c28c..2cd31c57957b 100644 --- a/sdk/core/core-lro/test/utils/testClient.ts +++ b/sdk/core/core-lro/test/utils/testClient.ts @@ -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"; @@ -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 { const poller = new TestPoller( this, diff --git a/sdk/core/core-lro/test/utils/testOperation.ts b/sdk/core/core-lro/test/utils/testOperation.ts index 98ca18e5b2ee..68d11467a586 100644 --- a/sdk/core/core-lro/test/utils/testOperation.ts +++ b/sdk/core/core-lro/test/utils/testOperation.ts @@ -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"; @@ -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 } diff --git a/sdk/core/core-lro/test/utils/testServiceClient.ts b/sdk/core/core-lro/test/utils/testServiceClient.ts index 9adaa833e5a3..6c5311ad0da5 100644 --- a/sdk/core/core-lro/test/utils/testServiceClient.ts +++ b/sdk/core/core-lro/test/utils/testServiceClient.ts @@ -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; @@ -19,7 +21,7 @@ export class TestServiceClient extends ServiceClient { constructor( credentials: TokenCredential | ServiceClientCredentials, - options?: ServiceClientOptions + options?: TestServiceClientOptions ) { super(credentials, options); this.credentials = credentials;