Yamllint: Difference between revisions

From Omnia
Jump to navigation Jump to search
Line 17: Line 17:
See https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration
See https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration


  .yamllint
Specify config with:
  yamllint -c .yamllint file.yaml
 
Default config location:
* a file named .yamllint, .yamllint.yaml, or .yamllint.yml in the current working directory, or a parent directory (the search for this file is terminated at the user’s home or filesystem root)
* a filename referenced by $YAMLLINT_CONFIG_FILE, if set
* a file named $XDG_CONFIG_HOME/yamllint/config or ~/.config/yamllint/config, if present
 
WARNING: ~/.yamllint or ~/.yamllint.yml ~/.yamllint.yaml should work, but doesn't seem to work for me?
 
This did work:
~/.config/yamllint/config


Default:
Default:

Revision as of 20:18, 25 February 2024

yamllint

Install:

apt install yamllint

Use:

yamllint file.yaml

Note:

  • Defaults to max lines 80 limit

Doc:

https://yamllint.readthedocs.io/en/stable/

default configuration

See https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration

Specify config with:

yamllint -c .yamllint file.yaml

Default config location:

  • a file named .yamllint, .yamllint.yaml, or .yamllint.yml in the current working directory, or a parent directory (the search for this file is terminated at the user’s home or filesystem root)
  • a filename referenced by $YAMLLINT_CONFIG_FILE, if set
  • a file named $XDG_CONFIG_HOME/yamllint/config or ~/.config/yamllint/config, if present

WARNING: ~/.yamllint or ~/.yamllint.yml ~/.yamllint.yaml should work, but doesn't seem to work for me?

This did work:

~/.config/yamllint/config

Default:

---

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

rules:
  anchors: enable
  braces: enable
  brackets: enable
  colons: enable
  commas: enable
  comments:
    level: warning
  comments-indentation:
    level: warning
  document-end: disable
  document-start:
    level: warning
  empty-lines: enable
  empty-values: disable
  float-values: disable
  hyphens: enable
  indentation: enable
  key-duplicates: enable
  key-ordering: disable
  line-length: enable
  new-line-at-end-of-file: enable
  new-lines: enable
  octal-values: disable
  quoted-strings: disable
  trailing-spaces: enable
  truthy:
    level: warning

Extending to disable comments indentation:

# This is my first, very own configuration file for yamllint!
# It extends the default conf by adjusting some options.

extends: default

rules:
  comments-indentation: disable  # don't bother me with this rule

Extending to extend line length:

extends: default

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

  # accept both     key:
  #                   - item
  #
  # and             key:
  #                 - item
  indentation:
    indent-sequences: whatever

yaml

See yaml