PageSourceSearch

https://www.openpolicyagent.org/assets/js/8809e07e.6aeeb176.js

js openpolicyagent.org collected 2026-09-24 08:29:29 UTC 3,604 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkopa_website=self.webpackChunkopa_website||[]).push([[16589],{1927:(e,r,t)=>{t.r(r),t.d(r,{assets:()=>a,contentTitle:()=>l,default:()=>u,frontMatter:()=>s,metadata:()=>n,toc:()=>c});const n=JSON.parse('{"id":"rules/imports/import-after-rule","title":"import-after-rule","description":"Summary: Import declared after rule","source":"@site/projects/regal/rules/imports/import-after-rule.md","sourceDirName":"rules/imports","slug":"/rules/imports/import-after-rule","permalink":"/projects/regal/rules/imports/import-after-rule","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{},"sidebar":"autoSidebar","previous":{"title":"implicit-future-keywords","permalink":"/projects/regal/rules/imports/implicit-future-keywords"},"next":{"title":"import-shadows-builtin","permalink":"/projects/regal/rules/imports/import-shadows-builtin"}}');var o=t(74848),i=t(28453);const s={},l="import-after-rule",a={},c=[{value:"Rationale",id:"rationale",level:2},{value:"Configuration Options",id:"configuration-options",level:2},{value:"Related Resources",id:"related-resources",level:2}];function p(e){const r={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(r.header,{children:(0,o.jsx)(r.h1,{id:"import-after-rule",children:"import-after-rule"})}),"\n",(0,o.jsxs)(r.p,{children:[(0,o.jsx)(r.strong,{children:"Summary"}),": Import declared after rule"]}),"\n",(0,o.jsxs)(r.p,{children:[(0,o.jsx)(r.strong,{children:"Category"}),": Imports"]}),"\n",(0,o.jsx)(r.p,{children:(0,o.jsx)(r.strong,{children:"Avoid"})}),"\n",(0,o.jsx)(r.pre,{children:(0,o.jsx)(r.code,{className:"language-rego",children:'package policy\n\nrequired_role := "developer"\n\nimport data.identity.users\n'})}),"\n",(0,o.jsx)(r.p,{children:(0,o.jsx)(r.strong,{children:"Prefer"})}),"\n",(0,o.jsx)(r.pre,{children:(0,o.jsx)(r.code,{className:"language-rego",children:'package policy\n\nimport data.identity.users\n\nrequired_role := "developer"\n'})}),"\n",(0,o.jsx)(r.h2,{id:"rationale",children:"Rationale"}),"\n",(0,o.jsx)(r.p,{children:"Imports should be declared at the top of a policy, and before any rules. This makes it easy to quickly see the\ndependencies imported in the policy simply by looking at the top of the file."}),"\n",(0,o.jsx)(r.h2,{id:"configuration-options",children:"Configuration Options"}),"\n",(0,o.jsx)(r.p,{children:"This linter rule provides the following configuration options:"}),"\n",(0,o.jsx)(r.pre,{children:(0,o.jsx)(r.code,{className:"language-yaml",children:'rules:\n  imports:\n    import-after-rule:\n      # one of "error", "warning", "ignore"\n      level: error\n'})}),"\n",(0,o.jsx)(r.h2,{id:"related-resources",children:"Related Resources"}),"\n",(0,o.jsxs)(r.ul,{children:["\n",(0,o.jsxs)(r.li,{children:["GitHub: ",(0,o.jsx)(r.a,{href:"https://github.com/open-policy-agent/regal/blob/main/bundle/regal/rules/imports/import-after-rule/import_after_rule.rego",children:"Source Code"})]}),"\n"]})]})}function u(e={}){const{wrapper:r}={...(0,i.R)(),...e.components};return r?(0,o.jsx)(r,{...e,children:(0,o.jsx)(p,{...e})}):p(e)}},28453:(e,r,t)=>{t.d(r,{R:()=>s,x:()=>l});var n=t(96540);const o={},i=n.createContext(o);function s(e){const r=n.useContext(i);return n.useMemo((function(){return"function"==typeof e?e(r):{...r,...e}}),[r,e])}function l(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:s(e.components),n.createElement(i.Provider,{value:r},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.