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

167
Visualizações
How to use/parse generated js file without eval?

I'm working on a openapi validator project where we use Spectral. One of the feature we provide for the user is that they can use their own spectral rulesets. They can do it by placing it in a .spectral.yaml file.

The application reads this file, migrates it to a ruleset file (it uses the @stoplight/spectral-ruleset-migrator package, example is here). The migrator transforms a yaml file to a js file and ensures that different spectral ruleset formats are managed. The migrator returns a js file. The result starts with export default {}. Which is seemingly a json-ish file.

I can see two options to work with the returned file. With a little clean up I can use it as a json file and can parse it. It requires some plumbing, but it is ok.

The other way is parsing the js file and just using it. eval() would do the job, but everyone says that I shouldn't use it.

Is there another way to parse a generated js file and add it to an already running application and using it (calling its functions, check its properties, and so on)?

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