Allow for custom node type keys#139
Conversation
michaelficarra
left a comment
There was a problem hiding this comment.
This WFM. It's a bit weird that our "class" matchers (:function, :expression, etc) are aliases for a hard-coded list of estree types. But as long as they don't use these selectors, things should work fine. That begs the question, then: should we even update the class selector implementation to use nodeTypeKey if it's specific to estree which uses type?
That's an excellent question. While some of them will definitely not work elsewhere, it seems like I was going to follow up with another PR that externalizes the class name resolution so we can pass in a custom resolver that will take the place of the internal one. That would solve the problem completely for ESLint. |
I don't really like the thought of someone relying on that. We currently take some shortcuts (like "ends with
I think this is a good approach. Let's drop the Design wise, I'm thinking the config is an object whose keys are class names that extend/override built-in class names and whose values are predicates. Not sure how much context is appropriate for the predicate parameters though. I would probably just start with passing the node for now. |
|
Sounds good. I've disabled classes when |
|
Thanks @nzakas. |
In ESLint, we are looking at being able to support different formats of ASTs, and as such, we can't guarantee that the node type will always be in the
typekey. This patch allows a customnodeTypeKeyoption to be passed in that will alter be used instead oftypewhen specified.I wasn't sure what kinds of tests you'd be looking for here, so I added one as an example, but please let me know if you'd like me to add others.