Skip to content

FR: .swiftformatignore, etc to ignore Pods/ and other folders when recursively formatting #931

@jasikpark

Description

@jasikpark

TLDR:

  • allow only disabling linting and only enabling formatting
  • allow ignoring specific folders and files when running recursively

I want to set up formatting and linting for my Flutter project that uses Cocoapods for dependency management on the Swift/Xcode side of things.

Flutter formatting is simple:

name: Flutter format
on:
  push:
    branches:
      - main
  pull_request:
    paths:
      - '.github/workflows/flutterfmt.yml'
      - '.github/workflows/flutterfmt.sh'
      - '**.dart'
jobs:
  flutterfmt:
    name: Run flutter format
    runs-on: ubuntu-latest
    steps:
      - name: Install flutter
        uses: subosito/flutter-action@v2
        with:
          flutter-version: '3.29.0'

      - name: Check out code
        uses: actions/checkout@v4
        with:
          show-progress: false

      - name: Check formating
        run: dart format -l120 lib/ --set-exit-if-changed --suppress-analytics --output none

I tried to add a swift-format check similarly going off of https://calebhearth.com/swift-format-github-action:

name: Swift format
on:
  push:
    branches:
      - main
  pull_request:
    paths:
      - '.github/workflows/swiftfmt.yml'
      - '**.swift'
jobs:
  swiftfmt:
    name: Run swift format
    runs-on: macos-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v4
        with:
          show-progress: false

      - name: Check formating
        run: |
            xcrun swift-format lint . \
            --parallel \
            --recursive \
            --strict

This mostly works, but I had to run xcrun swift-format dump-configuration and then disable offending rules while I consider enabling them / work to enable them. I was able to ignore everything except for these last lints:

ios/Pods/Sentry/Sources/Swift/Integrations/SessionReplay/SentrySessionReplay.swift:192:100: warning: [EndOfLineComment] move end-of-line comment that exceeds the line length

I don't have control over my Cocoapods vendored code, and I would like to ignore those files accordingly.

Activity

ahoppen

ahoppen commented on Feb 14, 2025

@ahoppen
Member

Synced to Apple’s issue tracker as rdar://144825272

allevato

allevato commented on Feb 14, 2025

@allevato
Member

An initial version of this was started in #873, but it looks like it's stalled.

ahoppen

ahoppen commented on Feb 14, 2025

@ahoppen
Member

Let’s close this as a duplicate of #870

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @allevato@ahoppen@jasikpark

        Issue actions

          FR: `.swiftformatignore`, etc to ignore `Pods/` and other folders when recursively formatting · Issue #931 · swiftlang/swift-format