StyraInc / regal

Regal is a linter and language server for Rego, bringing your policy development experience to the next level!
https://docs.styra.com/regal
Apache License 2.0
261 stars 35 forks source link

Regal's parser should be made schema-aware #712

Open anderseknert opened 6 months ago

anderseknert commented 6 months ago

Having schemas to define things like the input document is a great way to prevent typos and mistakes that would otherwise only be caught at runtime. The opa check command allows providing a --schema directory, but there's no corresponding option for Regal.

Screenshot pictures a type error from typing an invalid input reference. This is caught by the "check on save" feature, but not by Regal so the error isn't inlined.

Screenshot 2024-05-10 at 15 42 40

We should allow pointing out a schema directory via .regal/config.yaml and provide that to the parse if found.

anderseknert commented 6 months ago

Tagging this "language server protocol" but this should benefit linting from the CLI as well.

anderseknert commented 5 months ago

This could also be used for code completions when provided, so that typing inp (or input., whatever) would bring up suggestions based on the possible attributes from the schema.