You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it was @johanfylling who suggested that we should have a style category rule to enforce ordering of imports, as well as grouping based on the "base path" in the imports. Something along the lines of:
Logic is fairly simple: imports of language "directives" like rego.v1 should always come first. After that follows alphabetically ordered imports, where the "base" attribute, like "alpha" in "data.alpha" is used for grouping. This is 100% compatible with opa fmt, and if implemented, we should also ensure that we implement this in regal fix so that this convention can be applied automatically to a project.
The text was updated successfully, but these errors were encountered:
One thing that I hadn't considered is comments. While it's hard to imagine scenarios where commenting imports adds much of value, and don't think it's common, we'd still need to deal with it I guess. And we'll need to do it in a way that's compatible with the formatter, which currently always separates a comment from the line above with an extra newline. Presence of comments will also make it much harder to rewrite the imports using regal fix...
We could either spend 90% of the effort here catering to that 1% of policies, or we could just bail out when we find comments somewhere between the first import and the last. As long as we document that behavior, I think that's good enough for a first implementation.
I think it was @johanfylling who suggested that we should have a
style
category rule to enforce ordering of imports, as well as grouping based on the "base path" in the imports. Something along the lines of:Avoid
Prefer
Logic is fairly simple: imports of language "directives" like
rego.v1
should always come first. After that follows alphabetically ordered imports, where the "base" attribute, like "alpha" in "data.alpha" is used for grouping. This is 100% compatible withopa fmt
, and if implemented, we should also ensure that we implement this inregal fix
so that this convention can be applied automatically to a project.The text was updated successfully, but these errors were encountered: