Skip to content

Conversation

yelizhenden-mdb
Copy link
Collaborator

@yelizhenden-mdb yelizhenden-mdb commented Dec 19, 2024

Proposed changes

Jira ticket: CLOUDP-287247

Implement the rule for custom method must use camelCase

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works

Changes to Spectral

  • I have read the README file for Spectral Updates

Further comments

}

const isCamelCase = casing(methodName, { type: 'camel', disallowDigits: true });
if (isCamelCase !== undefined) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

undefined means that the methodName is validated against camelCase

@yelizhenden-mdb yelizhenden-mdb marked this pull request as ready for review December 19, 2024 15:12
@yelizhenden-mdb yelizhenden-mdb requested a review from a team as a code owner December 19, 2024 15:12
Comment on lines 24 to 27
const isCamelCase = casing(methodName, { type: 'camel', disallowDigits: true });
if (isCamelCase !== undefined) {
return ERROR_RESULT;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const isCamelCase = casing(methodName, { type: 'camel', disallowDigits: true });
if (isCamelCase !== undefined) {
return ERROR_RESULT;
}
return casing(methodName, { type: 'camel', disallowDigits: true });

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you want ot customize the error message, you can change the yaml here:
message: '{{error}} http://go/ipa/109' -> message: 'Custom error message here. http://go/ipa/109'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It would return undefined if validated or something like {... use camel case} if not validated.
Also, we disregard returning ERROR_RESULT.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you want ot customize the error message, you can change the yaml here:
message: '{{error}} http://go/ipa/109' -> message: 'Custom error message here. http://go/ipa/109'

I can send a custom message which includes the problematic method name

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I see, yeah it would be nice to have {methodName} must use camelCase, let's go with original approach and add the evaluated string to the message 👍

Copy link
Collaborator

@lovisaberggren lovisaberggren left a comment

Choose a reason for hiding this comment

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

LGTM, one nit on the error message 👍

@yelizhenden-mdb yelizhenden-mdb merged commit d6ae9be into main Dec 19, 2024
13 checks passed
@yelizhenden-mdb yelizhenden-mdb deleted the CLOUDP-287247 branch December 19, 2024 16:44
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