1"use strict";(self.webpackChunkopa_website=self.webpackChunkopa_website||[]).push([[10086],{28453:(n,e,t)=>{t.d(e,{R:()=>s,x:()=>a});var o=t(96540);const r={},i=o.createContext(r);function s(n){const e=o.useContext(i);return o.useMemo((function(){return"function"==typeof n?n(e):{...e,...n}}),[e,n])}function a(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:s(n.components),o.createElement(i.Provider,{value:e},n.children)}},35843:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>l,contentTitle:()=>a,default:()=>u,frontMatter:()=>s,metadata:()=>o,toc:()=>c});const o=JSON.parse('{"id":"rules/custom/naming-convention","title":"naming-convention","description":"Summary: Naming convention violation","source":"@site/projects/regal/rules/custom/naming-convention.md","sourceDirName":"rules/custom","slug":"/rules/custom/naming-convention","permalink":"/projects/regal/rules/custom/naming-convention","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{},"sidebar":"autoSidebar","previous":{"title":"missing-metadata","permalink":"/projects/regal/rules/custom/missing-metadata"},"next":{"title":"narrow-argument","permalink":"/projects/regal/rules/custom/narrow-argument"}}');var r=t(74848),i=t(28453);const s={},a="naming-convention",l={},c=[{value:"Description",id:"description",level:2},{value:"Configuration Options",id:"configuration-options",level:2},{value:"Related Resources",id:"related-resources",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"naming-convention",children:"naming-convention"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"Summary"}),": Naming convention violation"]}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"Category"}),": Custom"]}),"\n",(0,r.jsx)(e.h2,{id:"description",children:"Description"}),"\n",(0,r.jsx)(e.p,{children:"This custom rule allows teams and organizations to define their own naming conventions for their Rego projects, without\nhaving to write custom linter policies. Naming conventions are simply defined in the Regal configuration file using\nregex patterns."}),"\n",(0,r.jsx)(e.p,{children:"Regal can enforce naming conventions for:"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"Package names"}),"\n",(0,r.jsx)(e.li,{children:"Rule names"}),"\n",(0,r.jsx)(e.li,{children:"Function names"}),"\n",(0,r.jsx)(e.li,{children:"Variable names"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"configuration-options",children:"Configuration Options"}),"\n",(0,r.jsx)(e.p,{children:"This linter rule provides the following configuration options:"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-yaml",children:'rules:\n custom:\n naming-convention:\n # note that all rules in the "custom" category are disabled by default\n # (i.e. level "ignore") as some configuration needs to be provided by\n # the user (i.e. you!) in order for them to be useful.\n #\n # one of "error", "warning", "ignore"\n level: error\n conventions:\n # allow only "private" rules and functions, i.e. those starting with\n # underscore, or rules named "deny" or "allow"\n - pattern: "^_[a-z]+$|^deny$|^allow$"\n # one of "package", "rule", "function", "variable"\n targets:\n - rule\n - function\n # any number of naming rules may be added\n # package names must start with "acmecorp" or "system"\n - pattern: "^acmecorp|^system"\n targets:\n - package\n # a list of names may be provided in addition to a pattern\n # if both a pattern and a list of names are provided, identifiers\n # must match either the pattern or one of the names in the list\n - names:\n - i\n - j\n - k\n targets:\n - var\n'})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"Note:"})," In order to avoid characters accidentally getting escaped, always use single quotes to encode your regex\npatterns. Additionally, you'll most often want to include anch
1ors for the start and end of the string (",(0,r.jsx)(e.code,{children:"^"})," and ",(0,r.jsx)(e.code,{children:"$"}),") in\nyour patterns, or else your pattern might accidentally match only parts of the name rather than the whole name."]}),"\n",(0,r.jsx)(e.h2,{id:"related-resources",children:"Related Resources"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["GitHub: ",(0,r.jsx)(e.a,{href:"https://github.com/open-policy-agent/regal/blob/main/bundle/regal/rules/custom/naming-convention/naming_convention.rego",children:"Source Code"})]}),"\n"]})]})}function u(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(d,{...n})}):d(n)}}}]);
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.