title: How to configure JSHint to catch TypeErrors as in a browser console?
body: <p>I am working on a custom editor which uses Monaco editor to accept the user snippets (pre-defined in JS lang) and I am using JSHint to evaluate their validity before submitting it to the backend.</p>
  <p>There are a set number of custom functions acceptable for a data type as per my app. Let's take an example of String to provide some more clarity on my situation.</p>
  <p>I have initialized JSHint using the following script:</p>
  <pre><code>String.prototype.myFunc = param =&gt; {};
  String.prototype.myAnotherFunc = paramTwo =&gt; {};
  </code></pre>
  <p>So the two acceptable functions in my program for all strings are <code>myFunc</code> and <code>myAnotherFunc</code>.</p>
  <p>However JSHint doesn't throw any TypeErrors if a user enters/calls any other function like</p>
  <pre><code>&quot;testString&quot;.invalidFunc();
  </code></pre>
  <p>I would like it to throw errors like browser console would do.</p>
  <p><a href="https://i.stack.imgur.com/MbJge.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MbJge.png" alt="enter image description here" /></a></p>
  <p>I have checked the 'errors' array inside <code>jsHintData</code> variable as well. Could somebody please help me understand where I am going wrong?</p>
  <p>Here's my JSHint config if that helps:</p>
  <pre><code>    const script = [
      'String.prototype.myFunc = param =&gt; {};',
  'String.prototype.myAnotherFunc = paramTwo =&gt; {};',
  '&quot;testString&quot;.invalidFunc();'
    ];
  
    try {
      JSHINT(script, { maxerr: Infinity, asi: true, latedef: true });
      const jsHintData = JSHINT.data();
     } catch (error) {
      return error;
    }
  </code></pre>