-
-
Notifications
You must be signed in to change notification settings - Fork 75
Support for visitorKeys
#532
Comments
An example of why this would be helpful. Adding support for This bradzacher/eslint-plugin-typescript#152 raises the following code which fails to be linted correctly (specifically for
Running this through astexplorer: https://astexplorer.net/#/gist/4ad1b40dcf08d8d10a7b453a0322f8df/e0aff8b19986c7fd05f3e0914532f06a6ee6ef70 The AST gets traversed via the types and properties:
If we want to handle this case, we have to then traverse the remaining tree manually:
|
Thank you for this issue! In fact, we are considering it on #516. |
#516 was merged, thanks! |
eslint v4.14.0 added the ability to extend the set of keys that the traverser visits on a given node.
https://github.com/eslint/eslint/blob/master/docs/developer-guide/working-with-custom-parsers.md
The reason I mention this, is because there are certain nodes that have a definition in the default config which prevents traversing children.
For example,
Identifier
is explicitly set to an empty array, meaning that the traverser will not traverse into thetypeAnnotation
.Rules in
eslint-plugin-typescript
have worked around this by explicitly handling the nodes (i.e.no-explicit-any
defines anIdentifier
selector).This causes confusion with new contributors who assume the
typeAnnotation
AST node should be traversed: bradzacher/eslint-plugin-typescript#117The confusion is compounded when certain nodes, like
ClassProperty
don't have entries in the default visitor key config, meaning that they fallback to the default keys, which includestypeAnnotation
.Is it worthwhile adding support for a custom set of
visitorKeys
, which add support fortypeAnnotation
where applicable?The text was updated successfully, but these errors were encountered: