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

Add ESLint typescript configuration and address warnings in src folder #81

Merged
merged 3 commits into from
Dec 23, 2023

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Nov 17, 2023

This Pull Request adds a ESLint configuration to the src folder, specific to typescript, based on @EdvinasDaugirdas 's recommendation to use the eslint-typescript:recommended plugin.

This PR also addresses linter warnings in the src/ folder, and adds a linting Github action.

@oleiade oleiade requested a review from a team as a code owner November 17, 2023 15:22
@oleiade oleiade requested review from codebien and joanlopez and removed request for a team November 17, 2023 15:22
Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

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

It would be great if we could have a shared linter config as a single source of truth and import it here and in the docs. I could stay under our k6/examples folder.

@@ -3,20 +3,22 @@
* @param value
* @returns
*/
export function isArrayBuffer(value: any): value is ArrayBuffer {
export function isArrayBuffer(value: unknown): value is ArrayBuffer {
Copy link
Contributor

Choose a reason for hiding this comment

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

wow 🤕

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, I'm sure there's something more clever to do there, but in the meantime, it will do.

What I learned in the process is that the unknown type is less permissive than any and will force you to do type assertions whenever you're using that value. See this article that I found useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm much more concerned about the current inability to make type checking on the crypto.hmac calls though to be fair 👍🏻

(looking into switching to webcrypto there down the road)

@oleiade
Copy link
Member Author

oleiade commented Nov 21, 2023

It would be great if we could have a shared linter config as a single source of truth and import it here and in the docs.
I agree. I'm just not sure how we would set and communicate the source of truth, though 🤔 In a convenient way, I mean.

Also, in some recent discussions, we questioned whether the examples were something we wanted to keep or care about, so I'm not sure this would be the right place, in light of that.

@oleiade oleiade merged commit 6bcc04a into main Dec 23, 2023
4 checks passed
@oleiade oleiade deleted the eslint branch December 23, 2023 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants