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

🎨 👷‍♂️ K6 run Biome Lint and Format #921

Merged
merged 5 commits into from
Aug 1, 2024

Conversation

rblaine95
Copy link
Collaborator

@rblaine95 rblaine95 commented Jul 31, 2024

  • Run npm run format
  • Set Biome Formatter Indent Style to spaces
  • Set Biome Formatter Indent Width to 2
  • Use biome check instead of format or lint
    • Allows Organize Imports to run
  • Make npm run lint:fix not run the unsafe lint fixes
  • Add an npm run lint:fix:unsafe to enable the unsafe flag

Copy link
Collaborator

@cl0ete cl0ete left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Eslint (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@rblaine95
Copy link
Collaborator Author

rblaine95 commented Jul 31, 2024

Want to make sure npm run format doesn't cause anything to break.
If everything is successful after the format, I'll run the lint:fix (safe).
If everything is still successful after the safe lint, I'll run the unsafe lint.

scripts/k6/scenarios/delete-holders.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-proof.js Fixed Show fixed Hide fixed
scripts/k6/main.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-credentials.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-invitation.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-issuers.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-invitation.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-credentials.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-proof.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-holders.js Fixed Show fixed Hide fixed
@rblaine95
Copy link
Collaborator Author

Found the unsafe fix that was causing the k6 syntax error:

./libs/functions.js:75:11 lint/complexity/useOptionalChain  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Change to an optional chain.
  
    73 │       const firstItem = responseData[0];
    74 │       // Safely access wallet_id without optional chaining
  > 75 │       if (firstItem && firstItem.hasOwnProperty("wallet_id")) {
       │           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    76 │         return firstItem.wallet_id;
    77 │       }
  
  ℹ Unsafe fix: Change to an optional chain.
  
     73  73 │         const firstItem = responseData[0];
     74  74 │         // Safely access wallet_id without optional chaining
     75     │ - ······if·(firstItem·&&·firstItem.hasOwnProperty("wallet_id"))·{
         75 │ + ······if·(firstItem?.hasOwnProperty("wallet_id"))·{
     76  76 │           return firstItem.wallet_id;
     77  77 │         }

https://biomejs.dev/linter/rules/use-optional-chain/

It looks like K6 doesn't have ? operators.

Copy link
Collaborator

@ff137 ff137 left a comment

Choose a reason for hiding this comment

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

@rblaine95 I'll take a look at why regression tests failed and post a separate fix. Just seems like connection record was not ready after webhook indicated it is ...

Note: one "critical" codacy issue: Unexpected console statement.
We can add the following to ignore it, considering it's not for production / to be executed in a browser.

/* eslint no-console: ["error", { allow: ["warn", "error"] }] */

* Run `npm run format`
* Set Biome Formatter Indent Style to spaces
* Set Biome Formatter Indent Width to `2`
* Set Biome Formatter Line Width to `120`
* Use `biome check` instead of `format` or `lint`
  * Allows Organize Imports to run
* Make `npm run lint:fix` not run the unsafe lint fixes
* Add an `npm run lint:fix:unsafe` to enable the `unsafe` flag
scripts/k6/scenarios/create-credentials.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-holders.js Fixed Show fixed Hide fixed
scripts/k6/main.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-issuers.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-proof.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/create-invitation.js Fixed Show fixed Hide fixed
scripts/k6/scenarios/delete-holders.js Fixed Show fixed Hide fixed
Copy link

sonarcloud bot commented Aug 1, 2024

Copy link
Collaborator

@ff137 ff137 left a comment

Choose a reason for hiding this comment

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

Nice! 🎨

@rblaine95 rblaine95 merged commit 86df413 into development Aug 1, 2024
45 of 46 checks passed
@rblaine95 rblaine95 deleted the chore/k6-lint-format branch August 1, 2024 12:45
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.

3 participants