Skip to content

file_name rule does not consider macro types #6026

@fraioli

Description

@fraioli

New Issue Checklist

Bug Description

When a file has a macro type in it, that type isn't considered by the file_name rule when determining if the name of the file matches one of the types within.

The following code triggers a file_name issue within a file named MyMacro.swift

// MyMacro.swift
public macro MyMacro() = #externalMacro(module: "MyMacros", type: "MyMacro")
struct MyStruct {}

Mention the command or other SwiftLint integration method that caused the issue. Include stack traces or command output.

$ swiftlint lint MyMacro.swift
MyMacro.swift:1:1: warning: File Name Violation: File name should match a type or extension declared in the file (if any) (file_name)

Environment

  • SwiftLint version (run swiftlint version to be sure): 0.58.2
  • Xcode version (run xcodebuild -version to be sure): 16B40
  • Installation method used (Homebrew, CocoaPods, building from source, etc): Homebrew

Metadata

Metadata

Assignees

Labels

bugUnexpected and reproducible misbehavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions