Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable rules by key #672

Open
Pandapip1 opened this issue May 14, 2024 · 2 comments
Open

Disable rules by key #672

Pandapip1 opened this issue May 14, 2024 · 2 comments

Comments

@Pandapip1
Copy link

Pandapip1 commented May 14, 2024

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.

@andrewimeson
Copy link
Contributor

andrewimeson commented May 16, 2024

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

@Pandapip1
Copy link
Author

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants