-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Future-proofing rulesets #1615
Comments
This looks awesome, and definitely addresses #1329, so thanks! Something to consider, maybe not as minimum-viable-product, but in the design: I gather the But, again, not super important on day one since we can just embed all the code right in the file, totally self-contained, which is sweet and would solve so much. |
This seems like it'll make life a lot less confusing for people working on custom functions and custom rulesets in general. Can we provide any tooling around this, like eslint or some other code checking tools to assist them with the process? As followup work ofc. It also seems like it opens the door for spectral to get auto-fix logic, as rules could declare fixer functions too like eslint too. cc @mnaumanali94 |
We have the same set of issues at Stoplight here, so no worries about this one. We'll have to sort it out.
That's the primary hope. Instead of using a somewhat proprietary syntax, we'll try to use a more standard approach more people should be familiar with and can also find plenty of resources about if in doubt.
We'll certainly try to provide some tooling around this, because we'll need it for our own rulesets, thus hopefully we can share some of the concepts we used, to ensure that a) the majority of the community rulesets are more or less consistent b) rulesets are easier to author & test c) writing powerful rules requires less effort. |
Yes! I'm looking forward to us building that out once we have this out of the door. |
The current design of rulesets is slightly troublesome.
The list of user-facing problems includes, but not limits itself to:
The other side is us, engineers, that have quite a bit of burden to deal with:
Moreover, current rulesets have a set of features that are very uncommonly used, but do add a notable amount of complexity:
functionOptions
can be validated using a JSON schemaI could probably find more issues and flaws with the current state of things, but these are all that come to my mind at this very moment.
I'd like to propose a revision of the current design, that would address most of the issues described above, and at the same time would reduce the burden we have to deal with.
As you can see, the syntax is pretty much the same.
What's different is that you need to explicitly load formats or rulesets, but thanks to that you get control over versioning.
All the inheritance rules would be kept untouched, so
all/off/recommended
, etc. would all stay the sameProposed file extension:
/^\.?spectral\.mjs$/
.mjs
cause of Node.js.Breaking Changes
Benefits
With such an approach, any time we make a change to a ruleset or/and a function, we can quite easily roll it out to everyone.
If someone does want to stick to a particular version, it's as easy as specifying a version in the import.
Furthermore, most of the issues I listed above are solved.
Potential Challenges
Adjusting Studio Spectral ruleset form - I'll be able to do without any issues by working on ESTree rather than trying to dispatch JSON patches.
So basically, the flow would be:
astring
and write contents to diskSome migration for existing users.
Links
#845
#1329
#1561
The text was updated successfully, but these errors were encountered: