adrienverge/yamllint

Disable rules by key

Pandapip1 opened this issue ยท 2 comments

I have the following config:

...
jobs:
  markdownlint:
    name: ๐Ÿ–‹๏ธ Markdownlint
    runs-on: ubuntu-latest
    steps:
      - name: ๐Ÿ“ฆ Checkout Repository
        uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b  # v4.1.5
        with:
          fetch-depth: 2
...

Due to other tooling I have, those lines with uses are always going to be too long. I'd like to disable the line-length rule, but only for those lines, and without spamming yamllint disable-line everywhere.

This isn't currently possible, but I have two suggestions:

  1. Move the comment to be above the line

    jobs:
      markdownlint:
        name: ๐Ÿ–‹๏ธ Markdownlint
        runs-on: ubuntu-latest
        steps:
          - name: ๐Ÿ“ฆ Checkout Repository
            # v4.1.5
            uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b
            with:
              fetch-depth: 2
  2. Disable the line-length rule for part of the file, and optionally re-enable it for
    the rest of the file

    jobs:
      markdownlint:
        name: ๐Ÿ–‹๏ธ Markdownlint
        runs-on: ubuntu-latest
        steps:
          # yamllint disable rule:line-length
          - name: ๐Ÿ“ฆ Checkout Repository
            uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b  # v4.1.5
            with:
              fetch-depth: 2
    
          - name: ๐Ÿ Setup Python
            uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d  # v5.1.0
    
          # yamllint enable rule:line-length
          - name: ๐Ÿš Do stuff that you still want line-length linted on
            run: |
              for _ in {1..100}; do
                 echo hi
              done

Move the comment to be above the line

Unfortunately, this isn't possible due to the automatic dependency update system (Renovate) being used.

Disable the line-length rule for part of the file, and optionally re-enable it for
the rest of the file

I've just disabled that particular rule globally for now.

The ideal situation would be to be able to do something like

# yamllint disable-for-item *.uses rule:line-length
steps: