Skip to content

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

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

Closed
jasikpark opened this issue Feb 13, 2025 · 3 comments

Comments

@jasikpark
Copy link

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.

@ahoppen
Copy link
Member

ahoppen commented Feb 14, 2025

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

@allevato
Copy link
Member

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

@ahoppen
Copy link
Member

ahoppen commented Feb 14, 2025

Let’s close this as a duplicate of #870

@ahoppen ahoppen closed this as completed Feb 14, 2025
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

3 participants