fix(jsdocs): The jsDocParam group matched an expression containing op…#1261
Open
Gabrielito666 wants to merge 1 commit into
Open
fix(jsdocs): The jsDocParam group matched an expression containing op…#1261Gabrielito666 wants to merge 1 commit into
Gabrielito666 wants to merge 1 commit into
Conversation
…ening and closing curly brackets. I am making this change because the current regular expression may confuse a jsDocParam with a jsDocType. Whilst looking into the history of regular expressions, I came to the conclusion that this was simply a relaxation of the rules governing regular expressions to allow for use cases that do not exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix false positives in jsDocParam syntax highlighting
The jsDocParam group currently accepts parameter names enclosed in curly brackets, such as "{param2}". This syntax is unusual and is not supported by JSDoc. As a result, this can cause the syntax rules to incorrectly classify some jsDocType expressions as jsDocParam. Removing this possibility reduces ambiguity in the syntax rules and makes it easier to enhance certain tags, such as @template, in the future.
Below is a screenshot of the bug, which shows that Vim highlights “{param2}” as if it were a valid jsDocParam, even though TypeScript does not recognise it and marks it as
any:However, when you change the regex, Vim stops highlighting it as a
jsDocParamand starts highlighting it as a comment, which in this case is correct:This makes a programmer realise that this is not valid jsDocs syntax and prompts them to change it.
My change does not break compatibility with valid syntax such as ‘[param2]’:
I would appreciate your feedback on this approach.
Best regards!