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
Improve ora.promise()
#181
Conversation
The pull request needs a proper descriptive title. |
Please always run |
|
I found out why the test error was happening. The new promise() was calling the promise that always rejects. I thought the promise was being rejected before entering the promise() call. Also, the PromiseOptions type definition was missing, looks like I only had added it to the README. |
readme.md
Outdated
|
||
If undefined, will keep the initial text. */ | ||
failText?: ((error: Error) => string) | string; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The readme docs should use the same formatting as used here: https://github.com/sindresorhus/boxen#options (Not just a copy paste of the TS types).
All of the [options](#options) plus the following: | ||
|
||
##### successText | ||
Type: `string | ((result: T) => string)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the functions, I used this as pattern: https://github.com/sindresorhus/got/blob/main/documentation/5-https.md#checkserveridentity. Please, change it further if wanted to fit your README styling.
index.d.ts
Outdated
interface PromiseOptions<T> extends Options { | ||
/** | ||
The new text of the spinner when the promise is resolved. | ||
|
||
If undefined, will keep the initial text. | ||
*/ | ||
successText?: string | ((result: T) => string); | ||
|
||
/** | ||
The new text of the spinner when the promise is rejected. | ||
|
||
If undefined, will keep the initial text. | ||
*/ | ||
failText?: string | ((error: Error) => string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still messy formatting. Please look over the whole diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this is happening at all. In my VSCode the indentation is right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't have EditorConfig extension installed here, I was using 2 spaces instead of tab (size 2). The code was looking the same in VSCode, but looks like the diff in GitHub renders tabs as 8 spaces, that's why it was visually strange.
I activated the whitespace rendering, and that's what was happening:
I found out that you are the XO dev. Maybe would be a good idea to have a pre-commit/GitHub action to lint this. Or even, to throw a warn/error on test if spaces were found instead of tabs. In eslint, this is doable.
I hope everything is fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for your information, there is a cool eslint plugin for JSDoc: https://github.com/gajus/eslint-plugin-jsdoc
I will soon add it to my personal eslint-config, as I also have my personal taste for JSDoc comments. Maybe you could implement a similar thing for XO to avoid those issues among all your repos, in PRs like mine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even, to throw a warn/error on test if spaces were found instead of tabs. In eslint, this is doable.
That's already a thing. Ora just didn't have the latest XO version.
However, you are still expected to look over your own PR diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for your information, there is a cool eslint plugin for JSDoc: gajus/eslint-plugin-jsdoc
I plan to add it at some point, but it's some work to evaluate all the rules, and I haven't had the time to do that yet: xojs/xo#378
Ora.promise()
Thanks :) |
This reverts commit 9c01990.
Implemented #169 (comment)
Improves ora.promise:
await ora.promise(..)
.Fixes #169