Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Add rule 'camel-case-func' #36

Merged
merged 2 commits into from
Oct 16, 2017
Merged

Add rule 'camel-case-func' #36

merged 2 commits into from
Oct 16, 2017

Conversation

vannuysm
Copy link
Contributor

Added as part of #29

@vannuysm vannuysm requested a review from nishtahir as a code owner October 16, 2017 15:24

const first = funcName.charAt(0);

if (!(first === first.toLowerCase() && first !== first.toUpperCase())) {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I understand what's going on here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We grab the first character of the function name and make sure it's lowercase. The reason for the check on both toLowerCase() and toUpperCase() is because numbers in JS are neither upper nor lowercase but '1'.toLowerCase() will evaluate to true.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure we need to do this since
https://sdkdocs.roku.com/display/sdkdoc/Expressions%2C+Variables%2C+and+Types#Expressions,Variables,andTypes-Identifiers

must start with an alphabetic character (a – z) or the symbol "_" (underscore)
may consist of alphabetic characters, numbers, or the symbol "_" (underscore)
are not case sensitive
may be of any length
may not use a "reserved word" as the name (see Reserved Words for list of reserved words).
if a variable: may end with an optional type designator character ($ for string, % for integer, ! for float, # for double) (function names do not support a type designator character).

Copy link
Member

Choose a reason for hiding this comment

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

I guess we should also check the string to see if delimited with underscores

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but I wasn't sure if BS supports UTF-8, in which case there are other letters that could be affected by this same situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the logic is still a bit wonky for that though, I'll submit a patch that handles that situation a bit better

Copy link
Member

Choose a reason for hiding this comment

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

Well it looks like a strict must there which we're looking for here -
https://github.com/willowtreeapps/bslint/blob/master/grammar/BrightScript.g4#L531

Any UTF8 would fail to parse so I doubt it would be an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Valid point...I'll update accordingly.

@vannuysm vannuysm merged commit 5c2f327 into master Oct 16, 2017
@vannuysm vannuysm deleted the rule/camel-case-func branch October 16, 2017 20:37
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.

2 participants