> For the complete documentation index, see [llms.txt](https://thorstenkramm.gitbook.io/saltstack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thorstenkramm.gitbook.io/saltstack/linter.md).

# Linter

### Was sind Linter

\
Ein Linter ist ein Programm, das Code analysiert und potenzielle Fehler aufdeckt. Linter werden in der Softwareentwicklung eingesetzt, um die Qualität des Codes zu verbessern und Fehler zu vermeiden.

Hier sind ein paar Gründe, warum Sie Linter nutzen sollten:

* Linter finden Fehler, die Sie sonst übersehen würden.
* Linter helfen Ihnen, Ihren Code sauberer und lesbarer zu gestalten.
* Linter können Ihnen helfen, Ihren Code effizienter zu gestalten.
* Linter können Ihnen helfen, Ihren Code sicherer zu gestalten.
* Linter können Ihnen Zeit und Mühe sparen.

### Yaml Lint

Der Basis-Linter, der Inkonsistenzen in Yaml-Dateien aufdeckt.

```
apt install yamllint
```

<figure><img src="/files/7TVNKjmgwT5mmk1ejiYu" alt=""><figcaption><p>Yamllint in Aktion</p></figcaption></figure>

Durch das Anlegen einer Konfigurationsdatei in `/srv/salt/.yamllint` können Sie die Regeln anpassen. Beispiel:

{% code title="/srv/salt/.yamllint" %}

```yaml
---
extends: default

yaml-files:
  - '*.yaml'
  - '*.yml'
  - '.yamllint'
  - '*.sls'

rules:
  # 80 chars should be enough, but don't fail if a line is longer
  line-length:
    max: 160
    level: warning

  # don't bother me with this rule
  indentation: disable
```

{% endcode %}

Führen Sie das Kommando `yamllint` immer aus dem Verzeichnis `/srv/salt` aus, damit die Konfigurationsdatei berücksichtigt wird.&#x20;

Alle Konfigurationsoption von Yamllint finden Sie in der [offiziellen Dokumentation](https://yamllint.readthedocs.io/en/stable/).

### Salt-Lint

Folgen Sie den Best-Practices von Salt-Lint, damit all Ihre State-Files einen einheitlichen Stil habe.

```
apt install pip
pip3 install salt-lint --break-system-packages
```

<figure><img src="/files/JwMVbw1fiJAcastWjbSA" alt=""><figcaption><p>Salt-Lint in Aktion</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://thorstenkramm.gitbook.io/saltstack/linter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
