Files
SwiftLint/Source/SwiftLintCoreMacros/SwiftLintCoreMacros.swift
Danny Mösch 77050e8c40 Enable a fully statically linked Linux executable (#6211)
If SwiftLint is built from this state using the Swift SDK, we'll get a
large self-contained Linux executable that runs without loading SourceKit.
It can do that by disabling any rule that requires SourceKit.

With `SWIFTLINT_DISABLE_SOURCEKIT` set on a normally (dynamically linked)
binary, the behavior is the same. That's different from the previously
reported more serious warnings.
2025-08-30 10:02:38 -04:00

41 lines
1.2 KiB
Swift

import SwiftCompilerPlugin
import SwiftDiagnostics
import SwiftSyntax
import SwiftSyntaxMacros
@main
struct SwiftLintCoreMacros: CompilerPlugin {
let providingMacros: [any Macro.Type] = [
AutoConfigParser.self,
AcceptableByConfigurationElement.self,
DisabledWithoutSourceKit.self,
SwiftSyntaxRule.self,
]
}
enum SwiftLintCoreMacroError: String, DiagnosticMessage {
case notStruct = "Attribute can only be applied to structs"
case severityBasedWithoutProperty = """
Severity-based configuration without a 'severityConfiguration' property is invalid
"""
case notEnum = "Attribute can only be applied to enums"
case noStringRawType = "Attribute can only be applied to enums with a 'String' raw type"
case noBooleanLiteral = "Macro argument must be a boolean literal"
var message: String {
rawValue
}
var diagnosticID: MessageID {
MessageID(domain: "SwiftLint", id: "SwiftLintCoreMacro.\(self)")
}
var severity: DiagnosticSeverity {
.error
}
func diagnose(at node: some SyntaxProtocol) -> Diagnostic {
Diagnostic(node: Syntax(node), message: self)
}
}