{"id":13684430,"url":"https://github.com/ashfurrow/danger-swiftlint","last_synced_at":"2025-09-30T05:30:44.354Z","repository":{"id":63904944,"uuid":"113681848","full_name":"ashfurrow/danger-swiftlint","owner":"ashfurrow","description":"Automated Swift linting on pull requests","archived":false,"fork":false,"pushed_at":"2019-01-04T15:30:29.000Z","size":76,"stargazers_count":145,"open_issues_count":1,"forks_count":15,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-02T01:11:35.332Z","etag":null,"topics":["danger-plugin","danger-swift","swiftlint"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ashfurrow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-09T15:59:09.000Z","updated_at":"2024-02-07T16:14:51.000Z","dependencies_parsed_at":"2022-11-28T19:21:13.303Z","dependency_job_id":null,"html_url":"https://github.com/ashfurrow/danger-swiftlint","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2Fdanger-swiftlint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2Fdanger-swiftlint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2Fdanger-swiftlint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2Fdanger-swiftlint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashfurrow","download_url":"https://codeload.github.com/ashfurrow/danger-swiftlint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234705847,"owners_count":18874423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["danger-plugin","danger-swift","swiftlint"],"created_at":"2024-08-02T14:00:33.462Z","updated_at":"2025-09-30T05:30:39.080Z","avatar_url":"https://github.com/ashfurrow.png","language":"Swift","funding_links":[],"categories":["Plugins"],"sub_categories":["Swift (danger-swift)"],"readme":"**Deprecation Notice**: This repo has been deprecated, since SwiftLint integration is now a part of [Danger Swift](https://github.com/danger/swift) as a first-class feature. You can read [this issue](https://github.com/ashfurrow/danger-swiftlint/issues/17) for context. This repo will remain available for legacy use, but **new projects should _not_ use this repo**.\n\n---\n\n[![CircleCI](https://circleci.com/gh/ashfurrow/danger-swiftlint.svg?style=svg)](https://circleci.com/gh/ashfurrow/danger-swiftlint)\n\n# Danger SwiftLint\n\n[Danger Swift](https://github.com/danger/danger-swift) plugin for [SwiftLint](https://github.com/realm/SwiftLint/). So you can get SwiftLint warnings on your pull requests!\n\n(**Note**: If you're looking for the _Ruby_ version of this Danger plugin, it has been moved [here](https://github.com/ashfurrow/danger-ruby-swiftlint).)\n\n## Usage\n\n[Install and run](https://github.com/danger/danger-swift#ci-configuration) Danger Swift as normal and install SwiftLint in your CI's config file. Something like:\n\n```yaml\ndependencies:\n  override:\n  - npm install -g danger # This installs Danger\n  - brew install danger/tap/danger-swift # This installs Danger-Swift\n  - brew install swiftlint # This is for the Danger SwiftLint plugin.\n```\n\nThen use the following `Dangerfile.swift`.\n\n```swift\n// Dangerfile.swift\n\nimport Danger\nimport DangerSwiftLint // package: https://github.com/ashfurrow/danger-swiftlint.git\n\nSwiftLint.lint()\n```\n\nThat will lint the created and modified files\n\n#### Inline mode\n\nIf you want the lint result shows in diff instead of comment, you can use inline_mode option. Violations that out of the diff will show in danger's fail or warn section.\n\n```swift\nSwiftLint.lint(inline: true)\n```\n\n#### Config \u0026 Directory\n\nYou can also specify a path to the config file using `configFile` parameter and a path to the directory you want to lint using `directory` parameter. This is helpful when you want to have different config files for different directories. E.g. Harvey wants to lint test files differently than the source files, thus they have the following  setup:\n\n```swift\nSwiftLint.lint(directory: \"Sources\", configFile: \".swiftlint.yml\")\nSwiftLint.lint(directory: \"Tests\", configFile: \"Tests/HarveyTests/.swiftlint.yml\")\n```\n\n### Lint all files\n\nBy default, only files that were added or modified are linted.\n\nIt's not possible to use [nested configurations](https://github.com/realm/SwiftLint#nested-configurations) in that case, because Danger SwiftLint lints each file on it's own, and by doing that the nested configuration is disabled. If you want to learn more details about this, read the whole issue [here](https://github.com/ashfurrow/danger-swiftlint/issues/4).\n\nHowever, you can use the `lintAllFiles` option to lint all the files. In that case, Danger SwiftLint doesn't lint files individually, which makes nested configuration to work. It'd be the same as you were running `swiftlint` on the root folder:\n\n```swift\nSwiftLint.lint(lintAllFiles: true)\n```\n\n### Custom SwiftLint binary path\n\nBy default, Danger SwiftLint runs `swiftlint` assuming it's installed globally. However, there're cases where it makes sense to use a different path. One example would be if you've installed SwiftLint using [CocoaPods](https://github.com/CocoaPods/CocoaPods).\n\nTo use another binary, you can use the `swiftlintPath` option:\n\n```swift\nSwiftLint.lint(swiftlintPath: \"Pods/SwiftLint/swiftlint\")\n```\n\n# Contributing\n\nIf you find a bug, please [open an issue](https://github.com/ashfurrow/danger-swiftlint/issues/new)! Or a pull request :wink: \n\nNo, seriously.\n\nThis is the first command line Swift I've ever written, and it's the first Danger Swift plugin _anyone_ has ever written, so if something doesn't work, I could really use your help figuring out the problem.\n\nA good place to start is writing a failing unit test. Then you can try to fix the bug. First, you'll need to fork the repo and clone your fork locally. Build it and run the unit tests. \n\n```sh\ngit clone https://github.com/YOUR_USERNAME/danger-swiftlint.git\ncd danger-swiftlint\nswift build\nswift test\n```\n\nAlright, verify that everything so far works before going further. To write your tests and modify the plugin files, run `swift package generate-xcodeproj`. Open the generated Xcode project and enjoy the modernities of code autocomplete and inline documentation. You can even run the unit tests from Xcode (sometimes results are inconsistent with running `swift test`).\n\nOne place that unit tests have a hard time covering is the integration with the `swiftlint` command line tool. If you're changing code there, open a pull request ([like this one](https://github.com/Moya/Harvey/pull/15)) to test everything works.\n\n# Customizing\n\nThere are tonnes of ways this plugin can be customized for individual use cases. After building [the Ruby version](https://github.com/ashfurrow/danger-ruby-swiftlint) of this plugin, I realized that it's really difficult to scale up a tool that works for everyone. So instead, I'm treating this project as a template, that you to do fork and customize however you like!\n\n1. [Fork](https://github.com/ashfurrow/danger-swiftlint#fork-destination-box) this project.\n1. Change the `import DangerSwiftLint` package URL to point to your fork.\n1. After making your changes to the plugin, push them to your fork and **push a new tag**.\n\nBecause you need to tag a new version, testing your plugin can be tricky. I've built some basic unit tests, so you should be able to use test-driven development for most of your changes. \n\nIf you think you've got a real general-purpose feature that most users of this plugin would benefit from, I would be grateful for a pull request.\n\n# License\n\n[#MIT4Lyfe](LICENSE)\n\n# A Fun GIF\n\n\u003cdetails\u003e\n\u003csummary\u003eYour feeling when you lint your swift code\u003c/summary\u003e\n\u003cimg src=\"https://imgur.com/L6NkEtz.gif\" /\u003e\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashfurrow%2Fdanger-swiftlint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashfurrow%2Fdanger-swiftlint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashfurrow%2Fdanger-swiftlint/lists"}