-
Notifications
You must be signed in to change notification settings - Fork 11
Conversation
lib/rules/camel-case-func.js
Outdated
|
||
const first = funcName.charAt(0); | ||
|
||
if (!(first === first.toLowerCase() && first !== first.toUpperCase())) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…tions cannot start with numbers
Added as part of #29