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

168
Vistas
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 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