-
-
Notifications
You must be signed in to change notification settings - Fork 241
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" similar to eslint #1021
Comments
Few reasonable limits to make this scoped:
|
I would suggest erring on the opinionated side of things to start (aka less flexible but hopefully simpler to implement well). Perhaps just starting with {
"overrides": [
{
"files": ["src/data/actions/*.yaml"],
"extends": "./rulesets/actions.yaml"
},
{
"files": ["src/data/jobs/*.yaml"],
"extends": "./rulesets/jobs.yaml"
}
]
}
💯. Just throwing out an alternative, but it might simplify a few things by constraining a bit further and considering this functionality as something like a spectral "workspace" (similar to monorepo workspace terminology). Where basically a spectral ruleset can EITHER define a workspace (that has the sort of "apply this ruleset to these files" info similar to above proposal), or rules, but not both. To simplify, I'd also propose that the first matched override applies (versus accumulating them). Thoughts? |
@marbemac I like this very much!
That indeed may help a lot, but might make troubleshooting a lot harder (Why did this rule has been applied? Why didn't this one?). Another aspect worth considering is that, even if nesting is disallowed, nothing prevents a user from being creative:
|
🎉 This issue has been resolved in version @stoplight/spectral-cli-v1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version @stoplight/spectral-core-v1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
User story.
As a user with a few different types of YAML and JSON in a repo, none of which have any particular format, I'd like to be able to apply Spectral rules and rulesets to specific files and folders without accidentally applying irrelevant rules to other files.
Is your feature request related to a problem?
Right now I am making a ruleset and Spectral VS Code is applying this custom ruleset to .spectral.yml, and everything in .spectral.yml is being applied to other random JSON files too.
Describe the solution you'd like
Configuration based on glob patterns looks like a good place to start.
https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
For example, picking a particular ruleset for a bunch of files:
This could be combined with custom rules for specifically those files:
Finally, setting a particular format, even a custom format, we can do this:
Then Spectral will know: those files are raml and a ruleset applying to format: "raml" will work fine.
This solves the issue we have currently where only CLI users get formats and nobody else can do anything about them.
The text was updated successfully, but these errors were encountered: