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

[event-hubs] fix eslint errors (round 1) #13013

Closed
wants to merge 4 commits into from
Closed

Conversation

chradek
Copy link
Contributor

@chradek chradek commented Dec 23, 2020

Round 1 addressing #10777
These changes addresses ~300 of the eslint errors and some warnings found by running eslint with the TSDoc rules disabled.

This leaves 13 errors and 51 warnings left after this PR is merged.

  • 5 'options parameter type is not prefixed with the class|method name' errors. Fixing this changes the public API so holding off on this.
  • 4 'Promise executor functions should not be async' errors. Fixing this will take a lot of care and I would want these to be reviewed on their own so they don't get lost in the noise.
  • 2 'X was used before it was defined' errors. These are somewhat misleading because they are used within methods and defined before those methods can be invoked. We might be able to fix these if we refactor the async promise executor functions.
  • 1 'Argument X should be types with a non-any type'. This isn't an external API so this should be fine. Need to think about best way to disable this (maybe just eslint-disable-line).
  • 1 'N is already defined'. This is due to a constant matching an interface name.

@@ -8,7 +8,7 @@
* @internal
*/
export function parseEndpoint(endpoint: string): { host: string; hostname: string; port?: string } {
const hostMatch = endpoint.match(/.*:\/\/([^\/]*)/i);
const hostMatch = endpoint.match(/.*:\/\/([^/]*)/i);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. doesn't make a difference, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. ESLint was complaining because that backslash was unnecessary.

Copy link
Member

@deyaaeldeen deyaaeldeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am super happy with the push to fix linting issues. One thing I left a comment about is that we should move away from any as an argument type and use unknown instead.

@@ -24,14 +24,15 @@ export const defaultDataTransformer = {
* - multiple: true | undefined.
*/
encode(body: any): any {
// eslint-disable-line @typescript-eslint/explicit-module-boundary-types
let result: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change any to unknown in the argument type throughout to fix the linting the issue? it could be a bit painful sometimes but it is safer to work with.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to refactor the if/else block to return early so that we don't need to have the result variable at all.

if (isBuffer(body) {
     return message.data_section(body);
}

try {
   const bodyStr = JSON.stringify(body);
   return message.data_section(Buffer.from(bodyStr, "utf8"));
} catch (err) {

}

Copy link
Member

@deyaaeldeen deyaaeldeen Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramya-rao-a sorry for the confusion by putting my comment on line 28 instead of line 26. I meant to do this change for arguments only (body in this case). This is where eslint complains.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all of the @typescript-eslint/explicit-module-boundary-types overrides in #13285

@@ -57,6 +58,7 @@ export const defaultDataTransformer = {
* @return {*} decoded body or the given body as-is.
*/
decode(body: any): any {
// eslint-disable-line @typescript-eslint/explicit-module-boundary-types
let processedBody: any = body;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

@@ -30,6 +31,7 @@ const smallMessageMaxBytes = 255;
* @ignore
*/
export function isEventDataBatch(eventDataBatch: any): eventDataBatch is EventDataBatch {
// eslint-disable-line @typescript-eslint/explicit-module-boundary-types
return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

@@ -1,6 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

// Disable eslint rule since these functions aren't part of the public API.
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Member

@richardpark-msft richardpark-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still reviewing, but noticed something interesting.

@chradek
Copy link
Contributor Author

chradek commented Jan 19, 2021

Closing in favor of #13285

@chradek chradek closed this Jan 19, 2021
ghost pushed a commit that referenced this pull request Jan 21, 2021
Round 1 addressing #10777
Replaces #13013 

This leaves 5 errors and 15 warnings (excluding TSDoc) after this PR is merged.

- 4 'Promise executor functions should not be async' errors. Fixing this will take a lot of care and I would want these to be reviewed on their own so they don't get lost in the noise.
- 1 'N is already defined'. This is due to a constant matching an interface name.
ljian3377 pushed a commit to ljian3377/azure-sdk-for-js that referenced this pull request Jan 22, 2021
Round 1 addressing Azure#10777
Replaces Azure#13013 

This leaves 5 errors and 15 warnings (excluding TSDoc) after this PR is merged.

- 4 'Promise executor functions should not be async' errors. Fixing this will take a lot of care and I would want these to be reviewed on their own so they don't get lost in the noise.
- 1 'N is already defined'. This is due to a constant matching an interface name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants