# import-shadows-rule

**Summary**: Import shadows rule

**Category**: Bugs

**Avoid**

```
package policyimport data.resources# 'resources' shadowed by importresources contains resource if {    # ...}
```

**Prefer**

```
package policyimport data.resources# using a different name for the rulereport contains resource if {    # ...}
```

```
package policy# using an alias to avoid shadowing 'resources' ruleimport data.resources as inventoryresources contains resource if {    # ...}
```

## Rationale

Imported identifers like `bar` in `import data.foo.bar` has higher precedence than a rule named `bar` in the same package. This means that any rule that is shadowed by an import is effectively unreachable inside of the module. Avoid shadowing either by renaming your rule or by using an alias for the imported identifier.

## Configuration Options

This linter rule provides the following configuration options:

```
rules:  bugs:    import-shadows-rule:      # one of "error", "warning", "ignore"      level: error
```

## Related Resources

*   GitHub: [Source Code](https://github.com/open-policy-agent/regal/blob/main/bundle/regal/rules/bugs/import-shadows-rule/import_shadows_rule.rego)