-
Notifications
You must be signed in to change notification settings - Fork 90
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
Allow for custom node type keys #139
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
type
key. This patch allows a customnodeTypeKey
option to be passed in that will alter be used instead oftype
when 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.