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

312
Views
How to configure JSHint to catch TypeErrors as in a browser console?

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.

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.

I have initialized JSHint using the following script:

String.prototype.myFunc = param => {};
String.prototype.myAnotherFunc = paramTwo => {};

So the two acceptable functions in my program for all strings are myFunc and myAnotherFunc.

However JSHint doesn't throw any TypeErrors if a user enters/calls any other function like

"testString".invalidFunc();

I would like it to throw errors like browser console would do.

enter image description here

I have checked the 'errors' array inside jsHintData variable as well. Could somebody please help me understand where I am going wrong?

Here's my JSHint config if that helps:

    const script = [
    'String.prototype.myFunc = param => {};',
'String.prototype.myAnotherFunc = paramTwo => {};',
'"testString".invalidFunc();'
  ];

  try {
    JSHINT(script, { maxerr: Infinity, asi: true, latedef: true });
    const jsHintData = JSHINT.data();
   } catch (error) {
    return error;
  }
about 4 years ago · Juan Pablo Isaza
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!