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

"overrides" section from included ruleset is ignored #2331

Closed
anikitin opened this issue Nov 8, 2022 · 8 comments · Fixed by #2369
Closed

"overrides" section from included ruleset is ignored #2331

anikitin opened this issue Nov 8, 2022 · 8 comments · Fixed by #2369

Comments

@anikitin
Copy link

anikitin commented Nov 8, 2022

Describe the bug
I have a master ruleset file which includes other files via "extends".
I need to define some "overrides" rules and I want to place them in a separate file and add it via "extens".
So, when I define the "overrides" section in external file, it is not applied.
If I do the same in master file, it works as expected.

To Reproduce

  1. Create two ruleset files where ruleset-1 includes ruleset-2 via "extends"
  2. Define "overrides" section in ruleset-2

Actual behavior
Overrides from included file are not applied

Expected behavior
Overrides from included file should be applied

Environment:

  • spectral-cli 6.6.0
@P0lip
Copy link
Contributor

P0lip commented Nov 8, 2022

Hey!
That is expected. Overrides aren't inherited.

@anikitin
Copy link
Author

anikitin commented Nov 9, 2022

Hm, is there a reason behind it? Is it stated in the documentation somewhere?
I haven't found anything about this in https://docs.stoplight.io/docs/spectral/293426e270fac-overrides and https://docs.stoplight.io/docs/spectral/83527ef2dd8c0-extending-rulesets.

What other sections will NOT be picked up from the ruleset files connected through "extends"?

@anikitin
Copy link
Author

It seems that #2237 is about similar inheritance problem with aliases...

@philsturgeon
Copy link
Contributor

A good outcome here would be to either let overrides be inhereted, or document why overrides are not being inhereted. Making it clear either way is the main thing. @mnaumanali94 @heitortsergent

@P0lip
Copy link
Contributor

P0lip commented Nov 14, 2022

If you really do want to overrides to be be inherited, you can use JS rulesets, and so something as follows

import rulesetA from './ruleset';

export default {
  extends: rulesetA,
  overrides: rulesetA.overrides,
};

The reason they are not inherited is mostly to avoid confusion. Overrides are usually specific to a particular project you lint, so having a shareable ruleset with some overrides in it doesn't make much sense.

@philsturgeon
Copy link
Contributor

Perfect, if we could put that into documentation then there won’t be any confusion, and we’re offering people a workaround if they really want it.

@heitortsergent
Copy link
Contributor

I'll update the docs with the workaround and the reason. :)

@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 6.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

5 participants