1

I am trying to write a custom eslint rule that makes sure that for every react context that is created, that a display name is set.

const myContext = React.createContext()
myContext.displayName = "myName"

It is fairly trivial for me to write a rule that checks the first line and gets the variable name. How would I go about extending that rule to find the second line, and throw an error if it doesn't find it? Ideally, I would like some visit function that I can throw a visitor and a node.

davorb
  • 613
  • 1
  • 9
  • 17

0 Answers0