Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

completed-docs: Add support for enum members #2911

Merged
merged 1 commit into from
Jun 23, 2017
Merged

completed-docs: Add support for enum members #2911

merged 1 commit into from
Jun 23, 2017

Conversation

reduckted
Copy link
Contributor

@reduckted reduckted commented Jun 11, 2017

PR checklist

Overview of change:

I've extended the completed-docs rule to check enum members. This is disabled by default and can be enabled by including a new argument "enum-members". This can also be configured to only require documentation for members of internal enums or exported enums.

CHANGELOG.md entry:

[new-rule-option] completed-docs: Add enum-members option

// the requirements, use the node that is being checked.
if (requirementNode === undefined) {
requirementNode = node;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You could replace these lines with requirementNode: ts.Declaration = node

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh cool, I didn't realise you could do that!

this.checkComments(node, this.describeNode(nodeType), comments, requirementNode);
}

private describeNode(nodeType: DocType): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems a little hardcody to just do this to ARGUMENT_ENUM_MEMBERS. How about generalizing the logic by taking in both node and requirementNode? If node is an ancestor of requirementNode, append " members" to the description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I thought about some sort of camel-case-to-words thing, but it seemed like overkill. Now that I've changed enumMembers to enum-members, I could just do:

return nodeType.replace("-", " ");

/**
* ...
*/
enum EnumWithMember {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: EnumWithMembers

@@ -39,6 +39,7 @@ export const ALL = "all";

export const ARGUMENT_CLASSES = "classes";
export const ARGUMENT_ENUMS = "enums";
export const ARGUMENT_ENUM_MEMBERS = "enumMembers";
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: other rules have options like "check-accessor", "member-variable-declaration", "array-simple", etc. This should probably be "enum-member".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

enum-member or enum-members?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, the plural :)

@reduckted
Copy link
Contributor Author

What's the convention for pushing changes to a pull request? Do I make a new commit and push it, or should I be amending my previous commit and force pushing?

@JoshuaKGoldberg
Copy link
Contributor

I've always just pushed additional and nobody's complained yet.

@reduckted
Copy link
Contributor Author

FYI, I've just rebased these changes onto master to fix the merge conflict caused by #2924.

@adidahiya adidahiya merged commit 0d133da into palantir:master Jun 23, 2017
@adidahiya
Copy link
Contributor

thanks @reduckted!

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

Successfully merging this pull request may close these issues.

4 participants