Load Rulesets via JS API
See original GitHub issueUser story. As a developer working with the JS API, I can do reference a custom ruleset (path, url, required from a NPM module), so that I do not need to mess around with the addRules() and addFunctions() interface.
This ticket should deprecate those two methods, but is not responsible for adding custom functions to rulesets. That will be handled in https://github.com/stoplightio/spectral/issues/311
Is your feature request related to a problem? V4.0 made it way easier to work with custom rulesets but working with the TS/JS interface still feels pretty clunky.
Describe the solution you’d like
TBD on the exact interface.
spectral.loadRuleset(‘file://something’)
Additional context
Relates to #365
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Create a Ruleset | Spectral - Stoplight
Rulesets are collections of rules written in JSON, YAML, or JavaScript. Rulesets provide powerful linting of other JSON or YAML files, such as...
Read more >Distribute Spectral Style Guides with NPM | APIs You Won't Hate
Create a JS file that will hold your ruleset, possibly called ruleset.js or spectral.js, whatever you feel like calling it. touch ruleset.js. In...
Read more >Use the Management API from within Rules - Auth0
In this example, we load version 2.9.1 of the library, then query the list of users and logs the users to the console...
Read more >JavaScript API overview - Drupal
info files in Drupal 7, are now referenced in .yml files. Also, stylesheets (CSS) and JavaScript (JS) are loaded through the same system...
Read more >EPM Cloud Ruleset REST API and examples
Supports rulesets with no runtime prompts or runtime prompts with default values. You can add parameters to rulesets for greater flexibility.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@marbemac @P0lip hey, it seems like you two were discussing some cool ideas for how the
loadRuleset()
this ticket suggests could be a helper for asetRuleset()
, but there seemed to also be concerns with the actual code being suggested.It’s getting close to implementation time, and I’d like to make sure this ticket has an implementation that somebody can pick up. Can we punt the setRuleset ideas for now and expose it as a new method later on?
I think we can get away with a simple
loadRulesets()
function which is doing whatloadRules()
andloadFunctions()
are currently doing? Seem ok?Yeah, I’d vote for holding on with that idea for a while and sticking to the original idea (
loadRuleset
method only).I’d like to work on that one, so lack of some details shouldn’t be an issue. 😄 ~Before we start that one, though, we need to have custom functions in place.~
EDIT: or we can add
loadRuleset
method and wait with removal ofaddRules
andaddFunctions
until custom functions are implemented.