-
Notifications
You must be signed in to change notification settings - Fork 3.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
JavaScript/Typescript Upper_Snake_Case issues #4072
Comments
I think we'd be open to a simple patch to NOT highlight identifiers It looks like Github is tagging this |
I updated examples a little bit. I was unable co find what acronym or word smi means in this contexts, could you please explain? If I understand correctly you would want for instance that upper snake case that correctly colors const function not to be colored after patch? Having no broken highlight is better than having colors, but that would basically mean having no highlighter at all. I would expect the highlighter just to finish what it started in color of first word. Some context for this non idiomatic JS. Now if I were to look into this, I would need to understand what may cause these inconsistencies
For me the expected behavior would be that if highligter takes in token it finishes the job on the id in color it started with. The first word is consistent if it is both camelCase or snake_case - both upper and lower, so I wonder what is the reason this happens. I would be ok to look into the code and solve it myself if we could think how this would be reasonable to fix and if I could understand what could cause the problem. |
Exactly. We don't care much about highlighting non idiomatic JS "correctly" or that we poorly highlight non idiomatic JS. We're solving for the most common use cases here. However, as I mentioned, if a simple enough patch was proposed to prevent poor highlighting of these mixed Camel+Snake case we'd likely accept it. Probably a matter of matching on a word boundary in addition to a negative lookahead for the underscore. We highlight only valid syntax and very popular idiomatic patterns that are common. The highlighting is all based on regex patterns. You could indeed highlight these weirdly named variables/constants if you wrote a custom grammar to do so and wrote the appropriate regex. If you want to modify grammars or buid your own I'd suggest reading our docs and then becoming familiar with regex patterns for describing matches. |
Ok, I will let you know what I find about it and whether there is some simple solution, I started go through some code and will look more into how this all works internally, thank you for comment. |
Hi, so I created PR, I discovered one more case where it was working before changes (class declaration). I looked into the code a little, made a tiny change to one regex, this didn't affect any highlighting that was working before, and all the naming is now consistent across the rules. I just wasn't sure where to put new markups so I created new one inside TS markups which checks all the things that are common with JS but also has code with TS types. |
Describe the issue
Wen you have non standard code style - using Upper Snake case in this instance - most types of Ids except for variable that is assigned arrow style function, have highlight that is composed of two colors, rendering only first part of Id correctly.
Which language seems to have the issue?
TypeScript/JavaScript
Are you using
highlight
orhighlightAuto
?I noticed this issue on StackOverflow and ChatGPT and would like to see naming style I use highlighted properly
Sample Code to Reproduce
Here github code for instance has no broken Upper Snake Case
Expected behavior
Single Id of any kind should not be colored in 2 separate colors.
The text was updated successfully, but these errors were encountered: