cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
docs/ignoring.md
100lines · modecode
| 1 | --- |
| 2 | layout: default |
| 3 | title: Ignoring problems |
| 4 | parent: Documentation |
| 5 | nav_order: 2 |
| 6 | --- |
| 7 | |
| 8 | # Ignoring selected lines or files |
| 9 | |
| 10 | While parsing files pint will look for special comment blocks and use them to |
| 11 | exclude some parts or whole files from checks. |
| 12 | |
| 13 | ## Ignoring whole files |
| 14 | |
| 15 | Add a `# pint ignore/file` comment on top of the file, everything below that line |
| 16 | will be ignored. |
| 17 | |
| 18 | Example: |
| 19 | |
| 20 | ```yaml |
| 21 | # pint ignore/file |
| 22 | |
| 23 | groups: |
| 24 | - name: example |
| 25 | rules: |
| 26 | - record: job:http_inprogress_requests:sum |
| 27 | expr: sum by (job) (http_inprogress_requests) |
| 28 | ``` |
| 29 | |
| 30 | ## Ignoring individual lines |
| 31 | |
| 32 | To ignore just one line use `# pint ignore/line` at the end of that line or |
| 33 | `# ignore/next-line` on the line before. |
| 34 | This is useful if you're linting templates used to generate Prometheus |
| 35 | configuration and it contains some extra lines that are not valid YAML. |
| 36 | |
| 37 | Example: |
| 38 | |
| 39 | {% raw %} |
| 40 | ```yaml |
| 41 | {% set some_jinja_var1 = "bar" %} # pint ignore/line |
| 42 | groups: |
| 43 | - name: example |
| 44 | rules: |
| 45 | - record: job:http_inprogress_requests:sum |
| 46 | expr: sum by (job) (http_inprogress_requests) |
| 47 | |
| 48 | # pint ignore/next-line |
| 49 | {% set some_jinja_var2 = "foo" %} |
| 50 | ``` |
| 51 | {% endraw %} |
| 52 | |
| 53 | ## Ignoring a range of lines |
| 54 | |
| 55 | To ignore a part of a file wrap it with `# pint ignore/begin` and |
| 56 | `# pint ignore/end` comments. |
| 57 | |
| 58 | Example: |
| 59 | |
| 60 | {% raw %} |
| 61 | ```yaml |
| 62 | # pint ignore/begin |
| 63 | {% set some_jinja_var1 = "bar" %} |
| 64 | {% set some_jinja_var2 = "foo" %} |
| 65 | # pint ignore/end |
| 66 | |
| 67 | groups: |
| 68 | - name: example |
| 69 | rules: |
| 70 | - record: job:http_inprogress_requests:sum |
| 71 | expr: sum by (job) (http_inprogress_requests) |
| 72 | ``` |
| 73 | {% endraw %} |
| 74 | |
| 75 | ## Disabling checks globally |
| 76 | |
| 77 | To disable specific check globally, for all files and rules, add it to pint configuration |
| 78 | file. Syntax: |
| 79 | |
| 80 | ```js |
| 81 | checks { |
| 82 | disabled = [ "...", ... ] |
| 83 | } |
| 84 | ``` |
| 85 | |
| 86 | Example: |
| 87 | |
| 88 | ```js |
| 89 | checks { |
| 90 | disabled = ["alerts/template"] |
| 91 | } |
| 92 | ``` |
| 93 | |
| 94 | ## Disabling individual checks for specific rules |
| 95 | |
| 96 | To disable individual check for a specific rule use `# pint disable ...` comments. |
| 97 | A single comment can only disable one check, so repeat it for every check you wish |
| 98 | to disable. |
| 99 | |
| 100 | See each individual [check](checks/index.md) documentation for details. |
| 101 | |