question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load Rulesets via JS API

See original GitHub issue

User 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:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
philsturgeoncommented, Aug 9, 2019

@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 a setRuleset(), 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 what loadRules() and loadFunctions() are currently doing? Seem ok?

0reactions
P0lipcommented, Aug 10, 2019

Can we punt the setRuleset ideas for now and expose it as a new method later on?

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 of addRules and addFunctions until custom functions are implemented.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found