Skip to content

addComment V3 support simple string body #260

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

Merged
merged 2 commits into from
Apr 12, 2023

Conversation

Cellule
Copy link
Contributor

@Cellule Cellule commented Apr 12, 2023

I was implementing adding a comment to an issue with api V3 and stumbled on this todo

async addComment<T = Models.Comment>(parameters: Parameters.AddComment, callback?: Callback<T>): Promise<void | T> {
// todo add simple comment structure (string)
const config: RequestConfig = {

Since I basically implemented the same thing in my project, I figured I'd take a stab at it directly here.

I had to tweak .prettierrc to match closer the .editorconfig file because the linter was complaining a lot about some choices Prettier made.
I still had an indentation issue with a ternary, but worked around the problem by making a function instead

@@ -145,7 +145,23 @@ export class IssueComments {
*/
async addComment<T = Models.Comment>(parameters: Parameters.AddComment, callback?: never): Promise<T>;
async addComment<T = Models.Comment>(parameters: Parameters.AddComment, callback?: Callback<T>): Promise<void | T> {
// todo add simple comment structure (string)
const getBody = (body: Parameters.AddComment['body']): Models.Document | undefined => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
const getBody = (body: Parameters.AddComment['body']): Models.Document | undefined => {
const body = typeof parameters.body === 'string' ? {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [{ type: 'text', text: parameters.body }],
},
],
} : parameters.body;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hahaha yeah that's the spot I was talking about, if I try to do that, prettier changes it to something the linter really doesn't like
image

Copy link
Owner

Choose a reason for hiding this comment

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

Let me check

Copy link
Owner

Choose a reason for hiding this comment

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

Install eslint-config-prettier package and add "prettier" in "extends" section of eslintrc..

Doc: https://github.com/prettier/eslint-config-prettier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

humm it does solve the error, but it looks like it simply disables that rule
https://github.com/prettier/eslint-config-prettier/blob/88ba724915c0d52c822d7c0d499be21c30c5380a/index.js#L90

I'd rather not make too big a change in your linter rules in this pull request by adding a whole other configuration.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, okay. I will complete all work with linter by myself. Conceptually everything was done and I express my great gratitude for your contribution!

@MrRefactoring MrRefactoring merged commit 81c91a8 into MrRefactoring:master Apr 12, 2023
@Cellule Cellule deleted the addComment-simple-string branch April 12, 2023 19:02
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