Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

311
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda