Skip to content
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

Support back-references with wildcards #109

Open
brettz9 opened this issue May 20, 2020 · 0 comments
Open

Support back-references with wildcards #109

brettz9 opened this issue May 20, 2020 · 0 comments

Comments

@brettz9
Copy link
Contributor

brettz9 commented May 20, 2020

We have come across a few use cases in eslint-plugin-jsdoc for allowing users to provide their own esquery contexts to indicate language features where comment blocks should apply.

For one example, there is a user who would like to require jsdoc blocks above a getter/setter pair, but not above each getter/setter. While they can define their allowable contexts like:

[
  'MethodDefinition:not([kind="get"],[kind="set"])',
  'MethodDefinition[kind="get"]:not(MethodDefinition[kind="set"] + MethodDefinition[kind="get"])',
  'MethodDefinition[kind="set"]:not(MethodDefinition[kind="get"] + MethodDefinition[kind="set"])'
],

...this doesn't perform checking to ensure that the getter preceded by a setter (or vice versa) that we are avoiding including is of the same name.

I would think that some kind of wildcard + backreference scheme such as:

'MethodDefinition[kind="set"]:not(MethodDefinition[kind="get"][key.name=(*)] + MethodDefinition[kind="set"][key.name="\\1"])'

...might help us solve these kinds of problems (the wildcard being necessary as the user doesn't know the method names in advance).

(Another use case we have currently is for only requiring docs on the top of a sequence of adjacent TSDeclareFunction's.)

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

No branches or pull requests

1 participant