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)?