Summary: Prefer importing packages over rules
Type: Aggregate - only runs when more than one file is provided for linting
# Rule imported directly
# Not obvious where "first_names" comes from
"Waldo" in first_names
# Package imported rather than rule
# Obvious where "first_names" comes from
"Waldo" in users.first_names
Importing packages and using the package name as a "namespace" for imported rules and functions tends to make your code easier to follow. This is especially true for large policies, where the distance from the import to actual use may be several hundreds of lines.
Regal has no way of knowing whether an import points to a rule, function or some external data — only that it doesn't
point to a package. Use the
ignore-import-paths configuration option if you want to make exceptions for e.g. imports
of external data, or use the various ignore options to ignore entire files.
This linter rule provides the following configuration options:
# one of "error", "warning", "ignore"
# Make an exception for some specific import paths
- Rego Style Guide: Prefer importing packages over rules and functions
If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules,
or just talk about Regal in general, please join us in the
#regal channel in the Styra Community