-
Notifications
You must be signed in to change notification settings - Fork 26.6k
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
Incorrect constant export example #3032
Comments
"constants" in this context is different than a I'm not sure what your suggested change clears up tbh. |
If we read the highlighted (bold) in the quoted section above, it basically means that exported constants should to be capitalized, but then the example is right opposite (it says "should obviously not be uppercased".) With respect to the second point around const, as per ECMASCRIPT specification it is NOT possible to change/reassign an exported const variable, but then the variable naming (in this example i.e., const THING_TO_BE_CHANGED) suggests that it is possible :) hope this was more clear. |
because a string with multiple words in it isn't a conceptual constant. |
irrespective of being a "conceptual" constant, it would not be possible to mutate/modify a variable declared using the "const" keyword that is assigned with a primitive as its value (in this case a "string"), hence the variable naming "THING_TO_BE_CHANGED" is not justified. It can never be changed, the JS spec simply doesn't allow it. Here the rule is about "const" variables
If it was about "constant" variables (including say "conceptual constants") I would have hoped it to read as:
In my opinion the rule is correct but only the example is misplaced. The rule clearly states that an exported "const" variable should be capitalized and a "const" variable within a file need NOT be capitalized. The example I am referring in this issue is "exporting" a const variable and hence should be capitalized. In my humble view, constants could very well be made of multiple words, e.g., official country names are perfect examples: |
Perhaps a more appropriate example could be Instead of choosing a string or primitive assignment, coz it confuses. |
True, that would make more sense. |
There are two points:
Current example:
Perhaps it could be:
The text was updated successfully, but these errors were encountered: