Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with setRuleset doing instanceof check #2768

Open
Aaron-Mackay opened this issue Jan 2, 2025 · 0 comments
Open

Issue with setRuleset doing instanceof check #2768

Aaron-Mackay opened this issue Jan 2, 2025 · 0 comments

Comments

@Aaron-Mackay
Copy link

Describe the bug
In setRuleset() in spectral.ts, a check is done to confirm the ruleset is of the Ruleset class before setting it
this.ruleset = ruleset instanceof Ruleset ? ruleset : new Ruleset(ruleset);
Unfortunately if the package is being used by another package, as in a plugin, there can be a mismatch where the ruleset was initialised using a (identical) Ruleset class from the root level node_modules, and then checked against the local node_modules, resulting in instanceof returning false, and then a failed attempt at converting a Ruleset into a Ruleset.

Is there a way to change the type narrowing to allow for this?

To Reproduce
Example:

  1. Install spectral
  2. Install a dependency that uses its own local copy of spectral (in our case)
  3. Run and get error that linting has failed as ruleset is not an object.

Expected behavior
setRuleset() sees that the ruleset is of the Ruleset class

Environment (remove any that are not applicable):

  • Gitlab pipelines

Additional context
Some further context here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant