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

check-tag-names: autofix @prop tags onto props if they exist? #1054

Open
JoshuaKGoldberg opened this issue Apr 27, 2023 · 0 comments
Open

check-tag-names: autofix @prop tags onto props if they exist? #1054

JoshuaKGoldberg opened this issue Apr 27, 2023 · 0 comments

Comments

@JoshuaKGoldberg
Copy link
Contributor

Motivation

From https://github.com/DefinitelyTyped/DefinitelyTyped/pull/65080/files#r1162947538: sometimes we see JSDoc @prop comments on an object that really should be on individual properties of the object. For example:

/**
 * @prop BASIC - icon, title, message, expandedMessage, up to two buttons.
 * @prop IMAGE - icon, title, message, expandedMessage, image, up to two buttons.
 */
declare const TemplateType: {
    BASIC: 'basic',
    IMAGE: 'image',
}

Current behavior

Right now check-tag-names only knows to fix this by removing @prop:

/**
- * @prop BASIC - icon, title, message, expandedMessage, up to two buttons.
- * @prop IMAGE - icon, title, message, expandedMessage, image, up to two buttons.
+ * BASIC - icon, title, message, expandedMessage, up to two buttons.
+ * IMAGE - icon, title, message, expandedMessage, image, up to two buttons.
 */
declare const TemplateType: {
    BASIC: 'basic',
    IMAGE: 'image',
}

Desired behavior

It'd be nice in situations where the prop name matches the @prop tag to move the comment onto the property itself:

/**
- * @prop BASIC - icon, title, message, expandedMessage, up to two buttons.
- * @prop IMAGE - icon, title, message, expandedMessage, image, up to two buttons.
 */
declare const TemplateType: {
+    /** 
+	  * icon, title, message, expandedMessage, up to two buttons.
+	  */
    BASIC: 'basic',

+    /** 
+	  * icon, title, message, expandedMessage, image, up to two buttons.
+	  */
    IMAGE: 'image',
}

Alternatives considered

Honestly this feels pretty low priority to me. The "before" pattern mentioned here is not very common. But it'd be cool to see this happen, maybe? 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants