yonaskolb / ProjLint

Project Linter to lint & autocorrect your non-code best practices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Codebeat Badge Version: 0.1.1 Swift: 4.1 Platforms: macOS | Linux License: MIT

InstallationUsageContributingLicense

ProjLint

Project Linter to lint & autocorrect your non-code best practices.

Requirements

  • Xcode 9.3+ and Swift 4.1+
  • Xcode Command Line Tools (see here for installation instructions)

Installation

Using Mint:

To install ProjLint simply run this command:

$ mint install JamitLabs/ProjLint

To update to the newest version of TranslationManager when you have an old version already installed run:

$ mint update JamitLabs/ProjLint

Usage

ProjLint provides the following sub commands:

  • lint: Lints the current directory and shows warnings and errors as console output.
  • correct: Corrects all correctable violations in the current directory.

Shared Flags:

  • --verbose, -v: Prints out more detailed information about steps taken.

Lint-only Flags:

  • --xcode, -x: Output are done in a format that is compatible with Xcode – for usage in Build Scripts.
  • --timeout, -t: Seconds to wait for network requests until skipped.
  • --ignore-network-errors, -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.

Configuration

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 <:var_name:>.

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.

Default Options

The following default options are available:

Option Type Required? Description
lint_fail_level String no One of warning or error – specifies when the lint command should fail.
forced_violation_level String no One of warning or 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"

Shared Variables

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

Contributing

See the file CONTRIBUTING.md.

License

This library is released under the MIT License. See LICENSE for details.

ezoic increase your site revenue

About

Project Linter to lint & autocorrect your non-code best practices.

License:MIT License


Languages

Language:Swift 100.0%