Skip to content

jonathanrauch/IBLinter

 
 

Repository files navigation

IBLinter

Build Status Swift 4.0

A linter tool to normalize .xib and .storyboard files. Inspired by realm/SwiftLint

Installation

Using Homebrew

$ brew install IBDecodable/homebrew-tap/iblinter

Using CocoaPods

pod 'IBLinter'

This will download the IBLinter binaries and dependencies in Pods/ during your next pod install execution and will allow you to invoke it via ${PODS_ROOT}/IBLinter/bin/iblinter in your Script Build Phases.

Compiling from source

You can build from source by cloning this repository and running

$ make install

iblinter will be installed in /usr/local/bin.

Usage

You can see all description by iblinter help

$ iblinter help
Available commands:

   help      Display general or command-specific help
   lint      Print lint warnings and errors (default command)
   version   Display the current version of SwiftLint

Xcode

Add a Run Script Phase to integrate IBLinter with Xcode

if which iblinter >/dev/null; then
  iblinter lint
else
  echo "warning: IBLinter not installed, download from https://github.com/IBDecodable/IBLinter"
fi

Alternatively, if you've installed IBLinter via CocoaPods the script should look like this:

"${PODS_ROOT}/IBLinter/bin/iblinter"

Rules

Rule id description
custom_class_name Custom class name of ViewController in storyboard should be same as file name.
relative_to_margin Forbid to use relative to margin option.
misplaced Display error when views are misplaced.
ambiguous Display error when views are ambiguous.
enable_autolayout Force to use useAutolayout option
duplicate_constraint Display warning when view has duplicated constraint.
storyboard_viewcontroller_id Check that Storyboard ID same as ViewController class name.
image_resources Check if image resouces are valid.
custom_module Check if custom class match custom module by custom_module_rule config.

Pull requests are encouraged.

Configuration

You can configure IBLinter by adding a .iblinter.yml file from project root directory.

key description
enabled_rules Enabled rules id.
disabled_rules Disabled rules id.
excluded Path to ignore for lint.
included Path to include for lint.
custom_module_rule Custom module rule configs.

CustomModuleConfig

You can configure custom_module rule by CustomModuleConfig list.

key description
module Module name.
included Path to *.swift classes of the module for custom_module lint.
excluded Path to ignore for *.swift classes of the module for custom_module lint.
enabled_rules:
  - relative_to_margin
disabled_rules:
  - custom_class_name
excluded:
  - Carthage
  - App
included:
  - App/Views
custom_module_rule:
  - module: UIComponents
    included:
      - UIComponents/Classes
    excluded:
      - UIComponents/Classes/Config/Generated

About

A linter tool for Interface Builder

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 97.7%
  • Makefile 1.7%
  • Ruby 0.6%