Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

313
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda