Skip to content

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

Closed
@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.

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

    Issue actions