-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Custom validation/linting rules #814
Comments
Hi @sanketshevkar, I'm eager to work on the pull request. Could you please assign it to me? Thanks! |
hey @vr-varad |
Please use this issue for discussion or doubts regarding this project idea. |
hey @jamieshorten @sanketshevkar does this need to convert a concert model file into a AST JSON format and then the linter will check one by one all the classes, properties, etc and validate with certain rules? |
Yes! Conversion of Concerto model to JSON AST already exists. But the linting part is missing. |
Can you point out where the |
You need to add file to the modelManager, that will give you a modelFile object, which has a getAST method, which would return the JSON AST. @dselman is there any better way for this? |
No, that's the way to do it if you want to ensure the AST is valid and consistent (references resolve). |
We can use Spectral as the framework for defining our own rules over the Concerto AST (JSON): Here are two sample rules:
When used with this CTO:
To create the AST:
test.json: {
"$class": "concerto.metamodel@1.0.0.Model",
"decorators": [],
"namespace": "test@1.0.0",
"imports": [],
"declarations": [
{
"$class": "concerto.metamodel@1.0.0.EnumDeclaration",
"name": "Gender",
"properties": [
{
"$class": "concerto.metamodel@1.0.0.EnumProperty",
"name": "Male"
},
{
"$class": "concerto.metamodel@1.0.0.EnumProperty",
"name": "Female"
},
{
"$class": "concerto.metamodel@1.0.0.EnumProperty",
"name": "Other"
}
]
},
{
"$class": "concerto.metamodel@1.0.0.ConceptDeclaration",
"name": "person",
"isAbstract": false,
"properties": [
{
"$class": "concerto.metamodel@1.0.0.StringProperty",
"name": "name",
"isArray": false,
"isOptional": false
}
]
}
]
} Produces the output:
|
I have gone through the readme section and I am having one question that - |
Hi. I've been looking into this project's requirements and am interested in working on it. This is my current understanding of how the linter would work for a general user, please correct me if I'm wrong-
|
Yes, that's correct! For the following point
We already have methods in Concerto that can get you the AST, rule checking is something that you'll have to build. |
Something like that. It seems like a good approach to start with. I haven't played much around with spectral yet, so please take this with a grain of salt. On a high level it seems like a good approach to me. |
Hey I have tried both options like cli and javascript ruleset both worked fine
`async function lintConcertoModel() {
}
|
hey @dselman as this issue had been under gsoc'24 but still seems to be open , could you let me know about it if its available to work and what were the complications faced with the previous flow that was listed in the comments? |
Yes, the issue is still open. There wasn't any major issue with the approach described, it was just deprioritised for GSoC. I still think it would be a valuable contribution, and by leveraging Spectral should not be too costly or difficult to implement. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Feature Request ποΈ
Create a linter to allow users to specify rules for how their Concerto models are structured
Use Case
It would be useful to have a tool to allow users to do some / all of the following:
@Term
decorators on all declarations and properties e.t.cContext
The text was updated successfully, but these errors were encountered: