stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI (v3.1, v3.0, and v2.0), Arazzo v1.0, as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.51k stars 240 forks source link

Calling a ruleset function in a custom function for browser based linting #2400

Closed OllieTho closed 1 year ago

OllieTho commented 1 year ago

Discussed in https://github.com/stoplightio/spectral/discussions/2398

Please see details provided in comments of issue. I'm attempting to build the package locally and the package-lock.json file generated appears to require the fsevents package with is incompatible with non-Mac-OS systems, making building the project impossible on other systems. Originally posted by **OllieTho** February 9, 2023 This is building off of my previous issue I posted here: https://github.com/stoplightio/spectral/discussions/2323 I have a custom function and I am wanting to use a function included in the oas ruleset provided with spectral inside the custom function. I found a solution using the require() function for linting with spectral-cli by doing the following: `const {oasUnusedComponent} = require('@stoplight/spectral-rulesets/dist/oas/functions');` I'm also needing this to be functional in the browser however and since require() is a Node.js function, this solution does not work there. I'm aware that the oas ruleset exists in the js delivered to the browser, but it has been minified, so the path to calling the function is obfuscated and I'm not sure there's a reliable way to call it from there. Any help is appreciated!
P0lip commented 1 year ago

Let's track this in https://github.com/stoplightio/spectral/discussions/2398