Project Linter to enforce your non-code best practices.
- Xcode 9.3+ and Swift 4.1+
- Xcode Command Line Tools (see here for installation instructions)
To install the latest version of ProjLint simply run this command:
$ mint install JamitLabs/ProjLint
ProjLint provides the following sub commands:
lint: Lints the current directory and shows warnings and errors as console output.
-v: Prints out more detailed information about steps taken.
-x: Output are done in a format that is compatible with Xcode – for usage in Build Scripts.
-t: Seconds to wait for network requests until skipped.
-i: Ignores network timeouts or missing network connection errors.
NOTE: It is recommended to set the options
--timeout 2 and
--ignore-network-errors if you plan to run
projlint lint automatically on every build. Otherwise your build time might increase significantly on bad/missing internet connections.
To configure the checks ProjLint does for you, you need to have a YAML configuration file named
.projlint.yml in the current directory. In there, you have the following sections:
Default Options: Documented below, these options are applied to all rules unless they override them specifically.
Rules with Options: The list of rules to check & correct when the appropriate tasks are run with ability to customize them.
Shared Variables: Define String variables to be replaced in rule options using structure
In addition to the
.projlint.yml file, you can also place an additional
.projlint-local.yml file with the same possibilities as in the normal config file. This allows you to share the same
.projlint.yml file amongst multiple projects and keep them in sync while adding project-specific rules via the
-local config file. Note that defaults options and shared variables with the same keys in the
-local file will override those from the normal file.
The following default options are available:
Option | Type | Required? | Description
--- | --- | --- | ---
String | no | One of
error – specifies when the
lint command should fail.
String | no | One of
error – enforces the specified level on all violations.
All default options can be overridden by specifying a different value within the rule options. Here's an example:
default_options: lint_fail_level: error
Rules with Options
A list of all currently available rules and their options can be found in the Rules.md file. The structure of how rules can be configures looks like the following:
rules: - file_existence: # rule identifier forced_violation_level: warning # override default option paths: # note the additional indentation # rule option - .swiftlint.yml - README.md - CONTRIBUTING.md - CHANGELOG.md - file_content_template: #rule identifier matching: # rule option .swiftlint.yml: template_url: "https://github.com/User/Templates/blob/stable/SwiftLint.stencil"
A dictionary where you can define variables which can be used in strings anywhere amongst rule options. Say a variable named
project_name was specified with the value
MyAmazingProject, then all appearances of
<:project_name:> in rule option strings will be replaced by
MyAmazingProject. Here's what a config file using shared variables might look like:
shared_variables: project_name: MyAmazingProject rules: - file_existence: paths: - <:project_name:>.xcodeproj - <:project_name:>/Sources/AppDelegate.swift
See the file CONTRIBUTING.md.
This library is released under the MIT License. See LICENSE for details.