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

build(sdk): Add ESLint/prettier for the @mermaidchart/sdk library #13

Merged
merged 5 commits into from
May 14, 2024

Conversation

aloisklink
Copy link
Contributor

@aloisklink aloisklink commented Nov 29, 2023

📖 Description

This PR adds a pnpm run lint and pnpm run lint:fix rule to the packages/sdk folder that runs ESLint and Prettier. I've also setup CI to run linting automatically, but only for the packages/sdk subfolder, since I don't want to cause merge conflicts with anything @jgreywolf is working on in packages/office.

I've also fixed all of the ESLint and Prettier errors in the SDK (although most of them were from my recent PRs!).

There are no functionality changes to the code, it's all just formatting changes.

✍️ Type of Change

  • DevOps change
  • Style changes

Copy link

vercel bot commented Nov 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
office-plugin-site ⬜️ Ignored (Inspect) Visit Preview Apr 22, 2024 5:57am

Comment on lines 60 to 61
// don't care if this function rejects/resolves
void this.resetAccessToken();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sidharthv96, this.resetAccessToken() here returns a Promise, but we're not await-ing on it. This looks okay to me, but is this expected behaviour?

It looks like this.resetAccessToken() in packages/office/src/lib/mermaidChartApi.ts doesn't return a Promise, so maybe it's a bug:

public resetAccessToken() {

public async resetAccessToken(): Promise<void> {

Copy link
Contributor

Choose a reason for hiding this comment

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

Because it was not awaited, and if memory serves is being called from a non-async function, I removed the Promise expectation from the office version

Copy link
Member

Choose a reason for hiding this comment

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

You can remove async from resetAccessToken. The implementation doesn't require it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed by 203aabc

I was reluctant to make this change, since changing a function to/from async is a breaking change, but 🤷, I think other than Mermaid-Chart/vscode-mermaid-chart#6, nobody is using the @mermaidchart/sdk library. Plus, it will be easy for us to bump the version to ^0.2.0.

Base automatically changed from feat/add-setDocument-to-sdk to main December 4, 2023 08:54
@aloisklink aloisklink marked this pull request as ready for review December 4, 2023 09:07
Most of these were autofixed with `eslint --fix src/`
This matches TypeScript's default rules (e.g. what VS Code uses).
Change `MermaidChart#resetAccessToken()` so that it no longer returns a
`Promise`.
@aloisklink aloisklink merged commit 3fd5a09 into main May 14, 2024
6 checks passed
@aloisklink aloisklink deleted the chore/sdk-add-linting branch May 14, 2024 13:27
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