ESLint: Disallow calling a function with only one argument in the code

  no-restricted-syntax:  # see https://stackoverflow.com/a/65205076
    - error
    - message: Please don't use useMediaQuery(query) . Use useMediaQuery2(query) instead
      selector: CallExpression[callee.name='useMediaQuery'][arguments.length=1]

  • All code that calls useMediaQuery(query) will be marked as error
  • Your useMediaQuery2 may be still calling useMediaQuery , but it will call it with more than one arguments. So it is still valid

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.