Git Product home page Git Product logo

swiftlint-plugin's Introduction

SwiftLint Swift Package Plugin

A SwiftLint Swift Package plugin.

This Plugin differs from the official SwiftLint plugin by using a binary version of SwiftLint, so you don't have to build SwiftLint from source.

Requirements

  • Swift 5.7+

Setup

Build Tool Plugin

Add the SwiftLintPlugin dependency to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/adamayoung/swiftlint-plugin.git", from: "0.51.0")
]

For each of the Swift Package targets you want to lint during a build, add the plugin:

targets: [
    .target(
        name: "MyTarget",
        plugins: [
            .plugin(name: "SwiftLintPlugin", package: "swiftlint-plugin")
        ]
    ),
...
]

Now, when you build your Swift Package in Xcode, you will get inline SwiftLint warnings and errors.

Command Plugin

To run SwiftLint from the command line in your Swift Package (e.g. during CI workflows):

swift package swiftlint

Options

The command plugin also supports the following options:

Option Description
--config <path to .swiftlint.yml file> the path to one or more SwiftLint configuration files
--reporter <reporter name> the reporter used to log errors and warnings e.g. github-actions-logging
--strict to upgrade warnings to serious violations

swiftlint-plugin's People

Contributors

adamayoung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

trud-rakva 4np

swiftlint-plugin's Issues

Compilation error for a project depending on a library which uses SwiftLintPlugin

I have a Swift package executable project that depends on a Swift package library (the library name is swift-duration). The library uses SwiftLintPlugin and it works fine for that library. The problem is with the executable project. The compilation of the executable project finishes with the following error: product 'SwiftLint' required by package 'swift-duration' target 'Duration' not found in package 'SwiftLintPlugin'. The plugin make the library useless as it breaks compilation. It looks like the plugin can not be used as a linter for a dependency or description how to make it work is missing.

Steps to reproduce:
Create a Swift executable project for instance:

$ mkdir tmp
$ cd tmp
$ swift package init --type executable

In the Package.swift file add the dependency to the swift-duration library. The library depends on the plugin.

let package = Package(
    name: "tmp",
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://github.com/rojarand/swift-duration", exact: "1.2.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.
        .executableTarget(
            name: "tmp",
            dependencies: [.product(name: "Duration", package: "swift-duration")]),
        .testTarget(
            name: "tmpTests",
            dependencies: ["tmp"]),
    ]
)

Try to compile the project from the command line:

$ swift build

or from Xcode IDE.

You will receive the error with the message I mentioned before.

Env details:
swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
Target: arm64-apple-macosx12.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.