From bb137b0aa4cabf2ac978a4493c814455d00dfda9 Mon Sep 17 00:00:00 2001 From: Ramya Rao Date: Fri, 27 Aug 2021 08:11:42 -0700 Subject: [PATCH] Fix common linter errors for web-pubsub (#17299) * Fix @azure/azure-sdk/ts-package-json-keywords failure * Fix tsdoc/syntax errors for @param tag * Fix tsdoc/syntax error for usage of @ for non tag * Run lint:fix * Update lintreport name --- sdk/web-pubsub/web-pubsub/package.json | 4 +- sdk/web-pubsub/web-pubsub/src/groupClient.ts | 56 +++++----- sdk/web-pubsub/web-pubsub/src/hubClient.ts | 104 +++++++++--------- sdk/web-pubsub/web-pubsub/src/logger.ts | 2 +- .../web-pubsub/src/parseConnectionString.ts | 5 +- sdk/web-pubsub/web-pubsub/src/utils.ts | 3 + sdk/web-pubsub/web-pubsub/test/conn.spec.ts | 4 +- 7 files changed, 92 insertions(+), 86 deletions(-) diff --git a/sdk/web-pubsub/web-pubsub/package.json b/sdk/web-pubsub/web-pubsub/package.json index 340e45d1afb6..ea20fa4b0851 100644 --- a/sdk/web-pubsub/web-pubsub/package.json +++ b/sdk/web-pubsub/web-pubsub/package.json @@ -22,7 +22,7 @@ "integration-test:node": "echo skipped", "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 --fix-type [problem,suggestion]", - "lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o signalr-lintReport.html || exit 0", + "lint": "eslint package.json api-extractor.json src test --ext .ts -f html -o webpubsub-lintReport.html || exit 0", "pack": "npm pack 2>&1", "test:browser": "echo \"Browser is not supported.\" && exit 0", "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node", @@ -57,7 +57,7 @@ }, "repository": "github:Azure/azure-sdk-for-js", "keywords": [ - "Azure", + "azure", "cloud" ], "author": "Microsoft Corporation", diff --git a/sdk/web-pubsub/web-pubsub/src/groupClient.ts b/sdk/web-pubsub/web-pubsub/src/groupClient.ts index 8ccaf395090c..5d6bd4ae121e 100644 --- a/sdk/web-pubsub/web-pubsub/src/groupClient.ts +++ b/sdk/web-pubsub/web-pubsub/src/groupClient.ts @@ -84,54 +84,54 @@ export interface WebPubSubGroup { /** * Add a specific connection to this group * - * @param connectionId The connection id to add to this group - * @param options Additional options + * @param connectionId - The connection id to add to this group + * @param options - Additional options */ addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise; /** * Remove a specific connection from this group * - * @param connectionId The connection id to remove from this group - * @param options Additional options + * @param connectionId - The connection id to remove from this group + * @param options - Additional options */ removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise; /** * Add a user to this group * - * @param username The user name to add - * @param options Additional options + * @param username - The user name to add + * @param options - Additional options */ addUser(username: string, options?: GroupAddUserOptions): Promise; /** * Remove a user from this group * - * @param username The user name to remove - * @param options Additional options + * @param username - The user name to remove + * @param options - Additional options */ removeUser(username: string, options?: GroupRemoveUserOptions): Promise; /** * Send a text message to every connection in this group * - * @param message The message to send - * @param options Additional options + * @param message - The message to send + * @param options - Additional options */ sendToAll(message: string, options: GroupSendTextToAllOptions): Promise; /** * Send a json message to every connection in this group * - * @param message The message to send - * @param options Additional options + * @param message - The message to send + * @param options - Additional options */ sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise; /** * Send a binary message to every connection in this group * - * @param message The binary message to send - * @param options Additional options + * @param message - The binary message to send + * @param options - Additional options */ sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise; } @@ -174,8 +174,8 @@ export class WebPubSubGroupImpl implements WebPubSubGroup { /** * Add a specific connection to this group * - * @param connectionId The connection id to add to this group - * @param options Additional options + * @param connectionId - The connection id to add to this group + * @param options - Additional options */ public async addConnection( connectionId: string, @@ -214,8 +214,8 @@ export class WebPubSubGroupImpl implements WebPubSubGroup { /** * Remove a specific connection from this group * - * @param connectionId The connection id to remove from this group - * @param options Additional options + * @param connectionId - The connection id to remove from this group + * @param options - Additional options */ public async removeConnection( connectionId: string, @@ -241,8 +241,8 @@ export class WebPubSubGroupImpl implements WebPubSubGroup { /** * Add a user to this group * - * @param username The user name to add - * @param options Additional options + * @param username - The user name to add + * @param options - Additional options */ public async addUser(username: string, options: GroupAddUserOptions = {}): Promise { const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-addUser", options); @@ -262,8 +262,8 @@ export class WebPubSubGroupImpl implements WebPubSubGroup { /** * Remove a user from this group * - * @param username The user name to remove - * @param options Additional options + * @param username - The user name to remove + * @param options - Additional options */ public async removeUser(username: string, options: GroupRemoveUserOptions = {}): Promise { const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-removeUser", options); @@ -283,22 +283,22 @@ export class WebPubSubGroupImpl implements WebPubSubGroup { /** * Send a text message to every connection in this group * - * @param message The message to send - * @param options Additional options + * @param message - The message to send + * @param options - Additional options */ public async sendToAll(message: string, options: GroupSendTextToAllOptions): Promise; /** * Send a json message to every connection in this group * - * @param message The message to send - * @param options Additional options + * @param message - The message to send + * @param options - Additional options */ public async sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise; /** * Send a binary message to every connection in this group * - * @param message The binary message to send - * @param options Additional options + * @param message - The binary message to send + * @param options - Additional options */ public async sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise; diff --git a/sdk/web-pubsub/web-pubsub/src/hubClient.ts b/sdk/web-pubsub/web-pubsub/src/hubClient.ts index 77f8d537dd44..631be1752a51 100644 --- a/sdk/web-pubsub/web-pubsub/src/hubClient.ts +++ b/sdk/web-pubsub/web-pubsub/src/hubClient.ts @@ -207,9 +207,9 @@ export class WebPubSubServiceClient { * const client = new WebPubSubServiceClient(connectionString, 'chat'); * ``` * - * @param connectionString The connection string - * @param hubName The name of the hub to connect to. If omitted, '_default' is used. - * @param options Options to configure the http pipeline + * @param connectionString - The connection string + * @param hubName - The name of the hub to connect to. If omitted, '_default' is used. + * @param options - Options to configure the http pipeline */ constructor(connectionString: string, hubName: string, options?: HubAdminClientOptions); @@ -224,10 +224,10 @@ export class WebPubSubServiceClient { * const client = new WebPubSubServiceClient(endpoint, cred, 'chat'); * ``` * - * @param endpoint The endpoint to connect to - * @param credential An AzureKeyCredential holding your service key - * @param hubName The name of the hub to connect to. - * @param options Options to configure the http pipeline + * @param endpoint - The endpoint to connect to + * @param credential - An AzureKeyCredential holding your service key + * @param hubName - The name of the hub to connect to. + * @param options - Options to configure the http pipeline */ constructor( endpoint: string, @@ -270,7 +270,7 @@ export class WebPubSubServiceClient { /** * Auth the client connection with userId and custom claims if any - * @param options The options that the client has + * @param options - The options that the client has */ public async getAuthenticationToken( options?: GetAuthenticationTokenOptions @@ -301,7 +301,7 @@ export class WebPubSubServiceClient { /** * Get a client for a group - * @param groupName The name of the group to connect to. + * @param groupName - The name of the group to connect to. */ public group(groupName: string): WebPubSubGroup { return new WebPubSubGroupImpl(this.client, this.hubName, groupName); @@ -310,22 +310,22 @@ export class WebPubSubServiceClient { /** * Broadcast a text message to all connections on this hub. * - * @param message The text message to send - * @param options Additional options + * @param message - The text message to send + * @param options - Additional options */ public async sendToAll(message: string, options: HubSendTextToAllOptions): Promise; /** * Broadcast a JSON message to all connections on this hub. * - * @param message The JSON message to send - * @param options Additional options + * @param message - The JSON message to send + * @param options - Additional options */ public async sendToAll(message: JSONTypes, options?: HubSendToAllOptions): Promise; /** * Broadcast a binary message to all connections on this hub. * - * @param message The message to send - * @param options Additional options + * @param message - The message to send + * @param options - Additional options */ public async sendToAll(message: RequestBodyType, options?: HubSendToAllOptions): Promise; @@ -356,9 +356,9 @@ export class WebPubSubServiceClient { /** * Send a text message to a specific user * - * @param username User name to send to - * @param message The text message to send - * @param options Additional options + * @param username - User name to send to + * @param message - The text message to send + * @param options - Additional options */ public async sendToUser( username: string, @@ -369,9 +369,9 @@ export class WebPubSubServiceClient { /** * Send a JSON message to a specific user * - * @param username User name to send to - * @param message The josn message to send - * @param options Additional options + * @param username - User name to send to + * @param message - The josn message to send + * @param options - Additional options */ public async sendToUser( username: string, @@ -382,9 +382,9 @@ export class WebPubSubServiceClient { /** * Send a binary message to a specific user * - * @param username The user name to send to - * @param message The binary message to send - * @param options Additional options + * @param username - The user name to send to + * @param message - The binary message to send + * @param options - Additional options */ public async sendToUser( username: string, @@ -415,9 +415,9 @@ export class WebPubSubServiceClient { /** * Send a text message to a specific connection * - * @param connectionId Connection id to send to - * @param message The text message - * @param options Additional options + * @param connectionId - Connection id to send to + * @param message - The text message + * @param options - Additional options */ public async sendToConnection( connectionId: string, @@ -428,9 +428,9 @@ export class WebPubSubServiceClient { /** * Send a binary message to a specific connection * - * @param connectionId Connection id to send to - * @param message The JSON message - * @param options Additional options + * @param connectionId - Connection id to send to + * @param message - The JSON message + * @param options - Additional options */ public async sendToConnection( connectionId: string, @@ -441,9 +441,9 @@ export class WebPubSubServiceClient { /** * Send a binary message to a specific connection * - * @param connectionId Connection id to send to - * @param message The binary message - * @param options Additional options + * @param connectionId - Connection id to send to + * @param message - The binary message + * @param options - Additional options */ public async sendToConnection( connectionId: string, @@ -477,8 +477,8 @@ export class WebPubSubServiceClient { /** * Check if a specific connection is connected to this hub * - * @param connectionId Connection id to check - * @param options Additional options + * @param connectionId - Connection id to check + * @param options - Additional options */ public async hasConnection( connectionId: string, @@ -523,8 +523,8 @@ export class WebPubSubServiceClient { /** * Close a specific connection to this hub * - * @param connectionId Connection id to close - * @param options Additional options + * @param connectionId - Connection id to close + * @param options - Additional options */ public async closeConnection( connectionId: string, @@ -548,8 +548,8 @@ export class WebPubSubServiceClient { /** * Remove a specific user from all groups they are joined to - * @param userId The user id to remove from all groups - * @param options Additional options + * @param userId - The user id to remove from all groups + * @param options - Additional options */ public async removeUserFromAllGroups( userId: string, @@ -570,8 +570,8 @@ export class WebPubSubServiceClient { /** * Check if a particular group exists (i.e. has active connections). * - * @param groupName The group name to check for - * @param options Additional options + * @param groupName - The group name to check for + * @param options - Additional options */ public async hasGroup(groupName: string, options: HubHasGroupOptions = {}): Promise { const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasGroup", options); @@ -608,8 +608,8 @@ export class WebPubSubServiceClient { /** * Check if a particular user is connected to this hub. * - * @param username The user name to check for - * @param options Additional options + * @param username - The user name to check for + * @param options - Additional options */ public async hasUser(username: string, options: HubHasUserOptions = {}): Promise { const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasUser", options); @@ -647,9 +647,9 @@ export class WebPubSubServiceClient { /** * Grant permissions to a connection * - * @param connectionId The connection id to grant permissions to - * @param Permission The permission to grant - * @param options Additional options + * @param connectionId - The connection id to grant permissions to + * @param Permission - The permission to grant + * @param options - Additional options */ public async grantPermission( connectionId: string, @@ -676,9 +676,9 @@ export class WebPubSubServiceClient { /** * Revoke permissions from a connection * - * @param connectionId The connection id to revoke permissions from - * @param Permission The permission to revoke - * @param options Additional options + * @param connectionId - The connection id to revoke permissions from + * @param Permission - The permission to revoke + * @param options - Additional options */ public async revokePermission( connectionId: string, @@ -705,9 +705,9 @@ export class WebPubSubServiceClient { /** * Check if the connection has the specified permission * - * @param connectionId The connection id to check permission - * @param Permission The permission to check - * @param options Additional options + * @param connectionId - The connection id to check permission + * @param Permission - The permission to check + * @param options - Additional options */ public async hasPermission( connectionId: string, diff --git a/sdk/web-pubsub/web-pubsub/src/logger.ts b/sdk/web-pubsub/web-pubsub/src/logger.ts index 820266b24308..f8e83fd44e8a 100644 --- a/sdk/web-pubsub/web-pubsub/src/logger.ts +++ b/sdk/web-pubsub/web-pubsub/src/logger.ts @@ -4,6 +4,6 @@ import { createClientLogger } from "@azure/logger"; /** - * The @azure/logger configuration for this package. + * The `@azure/logger` configuration for this package. */ export const logger = createClientLogger("web-pubsub"); diff --git a/sdk/web-pubsub/web-pubsub/src/parseConnectionString.ts b/sdk/web-pubsub/web-pubsub/src/parseConnectionString.ts index b415a590ca9b..5fce712e9ab8 100644 --- a/sdk/web-pubsub/web-pubsub/src/parseConnectionString.ts +++ b/sdk/web-pubsub/web-pubsub/src/parseConnectionString.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { AzureKeyCredential } from "@azure/core-auth"; import { URL } from "./util/url"; @@ -7,7 +10,7 @@ interface ParsedConnectionString { } export function parseConnectionString(conn: string): ParsedConnectionString { - let parsed: { [id: string]: string } = {}; + const parsed: { [id: string]: string } = {}; conn.split(";").forEach((i) => { const assignmentPos = i.indexOf("="); diff --git a/sdk/web-pubsub/web-pubsub/src/utils.ts b/sdk/web-pubsub/web-pubsub/src/utils.ts index 0bf502f407f9..4d884d96b286 100644 --- a/sdk/web-pubsub/web-pubsub/src/utils.ts +++ b/sdk/web-pubsub/web-pubsub/src/utils.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { RequestBodyType } from "@azure/core-rest-pipeline"; function isRequestBody(obj: unknown): obj is RequestBodyType { diff --git a/sdk/web-pubsub/web-pubsub/test/conn.spec.ts b/sdk/web-pubsub/web-pubsub/test/conn.spec.ts index 8e2aa21717e4..ea56933d9699 100644 --- a/sdk/web-pubsub/web-pubsub/test/conn.spec.ts +++ b/sdk/web-pubsub/web-pubsub/test/conn.spec.ts @@ -6,8 +6,8 @@ import { assert } from "chai"; describe("Can parse connection string", function() { it("can parse valid connection string", async () => { - var conn = "Endpoint=http://localhost;AccessKey=ABC;Port=8080;Version=1.0;"; - var parsed = parseConnectionString(conn); + let conn = "Endpoint=http://localhost;AccessKey=ABC;Port=8080;Version=1.0;"; + let parsed = parseConnectionString(conn); assert.equal(parsed.credential.key, "ABC"); assert.equal(parsed.endpoint, "http://localhost:8080/"); conn = "Endpoint=http://localhost;AccessKey=ABC;";