Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukepistrol committed Jun 23, 2022
1 parent b11f03f commit 63997e5
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 32 deletions.
32 changes: 18 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@ import PackageDescription

let package = Package(
name: "SwiftLintPlugin",
platforms: [
.iOS(.v13),
.watchOS(.v6),
.macOS(.v10_15),
.tvOS(.v13),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "SwiftLintPlugin",
targets: ["SwiftLintPlugin"]),
.plugin(
name: "SwiftLint",
targets: ["SwiftLint"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "SwiftLintPlugin",
dependencies: []),
.testTarget(
name: "SwiftLintPluginTests",
dependencies: ["SwiftLintPlugin"]),
.binaryTarget(
name: "SwiftLintBinary",
url: "https://github.com/realm/SwiftLint/releases/download/0.47.1/SwiftLintBinary-macos.artifactbundle.zip",
checksum: "82ef90b7d76b02e41edd73423687d9cedf0bb9849dcbedad8df3a461e5a7b555"
),
.plugin(
name: "SwiftLint",
capability: .buildTool(),
dependencies: ["SwiftLintBinary"]),
]
)
29 changes: 29 additions & 0 deletions Plugins/SwiftLint/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// main.swift
// Plugins/SwiftLint
//
// Created by Lukas Pistrol on 23.06.22.
//

import PackagePlugin

@main
struct SwiftLintPlugin: BuildToolPlugin {
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
return [
.buildCommand(
displayName: "Running SwiftLint for \(target.name)",
executable: try context.tool(named: "swiftlint").path,
arguments: [
"lint",
"--in-process-sourcekit",
"--path",
target.directory.string,
"--config",
"\(context.package.directory.string)/.swiftlint.yml"
],
environment: [:]
)
]
}
}
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# SwiftLintPlugin

A description of this package.
A SPM Plugin for [SwiftLint](https://github.com/realm/SwiftLint/).

Implementation like discussed [here](https://github.com/realm/SwiftLint/issues/3840#issuecomment-1085699163).

## Add to Package

First add a dependency from this package:

```swift
dependencies: [
// ...
.package(url: "https://github.com/lukepistrol/SwiftLintPlugin", from: "0.0.1"),
]
```

Then add it to your targets as a plugin:

```swift
targets: [
.target(
name: "YOUR_TARGET",
dependencies: [],
plugins: [
.plugin(name: "SwiftLint", package: "SwiftLintPlugin")
]
),
]
```
6 changes: 0 additions & 6 deletions Sources/SwiftLintPlugin/SwiftLintPlugin.swift

This file was deleted.

11 changes: 0 additions & 11 deletions Tests/SwiftLintPluginTests/SwiftLintPluginTests.swift

This file was deleted.

0 comments on commit 63997e5

Please sign in to comment.