hosseinmd / prettier-plugin-jsdoc

A Prettier plugin to format JSDoc comments.
MIT License
232 stars 28 forks source link

Unwanted capitalisation #143

Closed Dan503 closed 2 years ago

Dan503 commented 2 years ago

When I write this:

export interface ConfirmationParams {
    /**
     * A title for the dialog
     *
     * @default 'Are you sure?'
     */
    title?: string
}

I get unwanted capitalisation in the @default tag. It says "Are You sure?" instead of "Are you sure?"

export interface ConfirmationParams {
    /**
     * A title for the dialog
     *
     * @default 'Are You sure?'
     */
    title?: string
}
cobaltt7 commented 2 years ago

Yes, I also find this plugin to format /** @file A file description */ as /** @file A File description */

RishiKumarRay commented 2 years ago

So we have to just capitalise the y? to solve the bug

Dan503 commented 2 years ago

No the issue is that it is forcing a capital letter where there shouldn't be one.

Correct English is: "Are you sure?"

The bug is that it is forcing incorrect capitalisation on the 2nd word. "Are You sure?"

Dan503 commented 2 years ago

I want it to just let me handle my own capitalisation of words in this situation.

hosseinmd commented 2 years ago

This module recognized are is default value and others are description, this is reason of capitalizing 2nd word.

Dan503 commented 2 years ago

Can the capitalising of the first letter of the description feature just be removed from this plugin then?

I don't see it as an essential feature and I get the feeling that the code needed to know if it should or should not apply capitalisation would be super complicated and bug prone.

hosseinmd commented 2 years ago

Maybe we should do this with a configuration and set the default to false.

hosseinmd commented 2 years ago

false mean: do not capitalize

Dan503 commented 2 years ago

It could be called descriptionCapitalization

... might be a bit wordy though at least it's clear.

desCaps is shorter but less clear

hosseinmd commented 2 years ago

I forgot that, we have it with jsdocCapitalizeDescription name

Dan503 commented 2 years ago

There is one thing that the plugin can do here to prevent some unwanted capitalisation.

@default 'Are you sure?'

I have quote marks around the text here. The plugin should be able to recognize that the full text inside the quote marks is the value and the text after the quote marks is the description.

@default 'I am a value' I am the description

So I think the bug here is that it shouldn't capitalise text inside 'single quote', "double quote", or `backtick quote`.

Dan503 commented 2 years ago

Can you reopen the issue?

The quote marks issue stated in my previous comment is a valid bug.

Dan503 commented 2 years ago

I tried setting this in my prettierrc file and it didn't work :(

"jsdocCapitalizeDescription": false
{
    "printWidth": 120,
    "tabWidth": 4,
    "singleQuote": true,
    "semi": false,
    "jsxBracketSameLine": true,
    "arrowParens": "avoid",
    "jsdocParser": true,
    "jsdocCapitalizeDescription": false
}

I also tried this

{
    "printWidth": 120,
    "tabWidth": 4,
    "singleQuote": true,
    "semi": false,
    "jsxBracketSameLine": true,
    "arrowParens": "avoid",
    "jsdocParser": true,
    "plugins": [
        "./node_modules/prettier-plugin-jsdoc"
    ],
    "overrides": [
        {
            "files": "*.tsx, *.ts, *.js",
            "options": {
                "jsdocCapitalizeDescription": false
            },
        },
    ],
}
hosseinmd commented 2 years ago

There is one thing that the plugin can do here to prevent some unwanted capitalisation.

@default 'Are you sure?'

I have quote marks around the text here. The plugin should be able to recognize that the full text inside the quote marks is the value and the text after the quote marks is the description.

@default 'I am a value' I am the description

So I think the bug here is that it shouldn't capitalise text inside 'single quote', "double quote", or `backtick quote`.

Default tag has optional value if you want to declare value, you should keep it in {here} for example


/**
 * @deffault {true} default value is true
 */
hosseinmd commented 2 years ago

This is not supported by vs code.

hosseinmd commented 2 years ago

If you have an object as default value, how you can add it to jsdoc?

Dan503 commented 2 years ago

Objects are painful in jsDoc.

/**
 * @param {Object} numberObject
 * @param {number} numberObject.number - the number to add 1 to
 */
const add1 = numberObject => numberObject.number + 1
hosseinmd commented 2 years ago

https://jsdoc.app/tags-default.html this is jsdoc default documentation, but in syntax, there is no description

hosseinmd commented 2 years ago

On the other hand, VS Code rendering default tag like example tag.

hosseinmd commented 2 years ago

Yes, I also find this plugin to format /** @file A file description */ as /** @file A File description */

I fixed this

hosseinmd commented 2 years ago

Fixed V0.3.33