diff --git a/Plugins/SwiftLintCommandPlugin/SwiftLintCommandPlugin.swift b/Plugins/SwiftLintCommandPlugin/SwiftLintCommandPlugin.swift index 21754b5..fb208c4 100644 --- a/Plugins/SwiftLintCommandPlugin/SwiftLintCommandPlugin.swift +++ b/Plugins/SwiftLintCommandPlugin/SwiftLintCommandPlugin.swift @@ -42,10 +42,20 @@ extension SwiftLintCommandPlugin { var argExtractor = ArgumentExtractor(arguments) let targetNames = argExtractor.extractOption(named: "target") let remainingArguments = argExtractor.remainingArguments - guard !targetNames.isEmpty, commandsNotExpectingPaths.isDisjoint(with: remainingArguments) else { + + if !commandsNotExpectingPaths.isDisjoint(with: remainingArguments) { try lintFiles(with: context, arguments: remainingArguments) return } + guard !targetNames.isEmpty else { + if let pathArgument = remainingArguments.last, FileManager.default.fileExists(atPath: pathArgument) { + Diagnostics.remark("No targets provided. Files provided in path arguments will be linted.") + try lintFiles(in: [], with: context, arguments: remainingArguments) + } else { + try lintFiles(with: context, arguments: remainingArguments) + } + return + } for target in try context.targets(named: targetNames) { try lintFiles(in: target.paths, for: target.name, with: context, arguments: remainingArguments) }