Skip to content

fix(jsdocs): The jsDocParam group matched an expression containing op…#1261

Open
Gabrielito666 wants to merge 1 commit into
pangloss:masterfrom
Gabrielito666:fix/jsDocParam_bug
Open

fix(jsdocs): The jsDocParam group matched an expression containing op…#1261
Gabrielito666 wants to merge 1 commit into
pangloss:masterfrom
Gabrielito666:fix/jsDocParam_bug

Conversation

@Gabrielito666

Copy link
Copy Markdown

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:

image

However, when you change the regex, Vim stops highlighting it as a jsDocParam and starts highlighting it as a comment, which in this case is correct:

image

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]’:

image

I would appreciate your feedback on this approach.

Best regards!

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant