Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
Prevent screen.findByX without an await with eslint no-restricted-syntax?

This medium article shows me how to prevent an await preceding a property:

"no-restricted-syntax": [
  "error",
  {
    "message": "promise.then is unnecessary when using async/await",
    "selector": "AwaitExpression[argument.callee.property.name=\" then\"]"
  }
]

But I want the opposite, I want to restrict these:

expect(screen.findByRole(...))....;
screen.findByRole(...);

but allow these:

expect(await screen.findByRole(...))....;
await screen.findByRole(...);

I tried this under my overrides for test files:

"no-restricted-syntax": [
  "error",
  {
    "message": "Find By queries must be followed by an await",
    "selector": ":not(AwaitExpression[argument.callee.property.name=/findBy.*/])"
  }
]

But now every line is showing that error. I also tried putting * in front, hoping it would allow anything (the *) unless is was followed by my banned syntax expression, but no dice.

How can I make this work?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!