Project Linter to enforce your non-code best practices.
- Xcode 10.2+ and Swift 5.0+
- Xcode Command Line Tools (see here for installation instructions)
To install ProjLint the first time run these commands:
brew tap JamitLabs/ProjLint https://github.com/JamitLabs/ProjLint.git brew install projlint
To update to the latest version run:
brew upgrade projlint
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.
-s: Exit with non-zero status on warnings, too. (Only for errors by default.)
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 – 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: forced_violation_level: warning
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 configured looks like the following:
rules: - file_existence: # rule identifier forced_violation_level: warning # override default option paths: # rule option (note the additional indentation) - .swiftlint.yml - README.md - CONTRIBUTING.md - CHANGELOG.md - file_content_template: #rule identifier matching: # rule option .swiftlint.yml: template_url: "https://raw.githubusercontent.com/JamitLabs/ProjLintTemplates/master/iOS/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.
You may find interesting
- 2019-09-11 04:46:16
- Make the rule
File Content Regexprint the offending lines.
Issue: #31 | PR: #32 | Author: Andrés Cecilia Luque
- Added the
allowed_paths_regexsubrule under the file existance rule. Now it is possible to specify the allowed paths in a project by using multiple regexes. Issues: #16, #20 | PR: #34 | Author: Andrés Cecilia Luque
lint_fail_levelconfiguration option with
strictcommand line argument. Specify
-sif you want the tool to fail on warnings.