Stickler CI Documentation

Want to customize the various linters Stickler CI uses? This page contains reference documentation on how to customize each of the tools that Stickler offers.

If you're still looking for answers, please tweet us @sticklerci or email us at support@stickler-ci.com.

Stickler CI Configuration

Stickler CI is configured through a yaml file in your repository. This yaml file controls which linters are enabled and what their options are.

Put your .stickler.yml file in the root directory of your project. An example file is

linters:
    flake8:
    jscs:
        config: './jscs.config'
    csslint:
files:
    ignore: ['src/generated/*', 'webroot/bower_components/*']
    

In this example we've enabled flake8, jscs, and csslint. We are using a custom config file for jscs, and have ignored all files in src/generated/* and webroot/bower_components.

General Options

In addition to configuring specific linters, you can also configure how Stickler CI inspects your code:

  • The files section lets you define which files should be excluded from all checks. It is a newline separated list of files that accept glob patterns like src/generated/*.py.
  • The branches section lets you define branches that Stickler CI will ignore. You can use this option to disable reviews when a pull request is against a particular set of branches.

An example of the above config options would be:

files:
    ignore: ['src/generated/*.py', 'webroot/bower_components/*']

branches:
    ignore: ['wip', 'feedback']

The above would not review any pull requests against the wip or feedback branches, and also ignore any .py in src/generated and all files in webroot/bower_components.

Default Linters

A number of languages have de-facto linters in use. To save you having to always enable these linters, Stickler CI provides a base configuration file for every repository. The default configuration enables phpcs, csslint, rubocop, and flake8. It also ignores files in vendor/*, bower_components/*, and node_modules/*.

Disabling Default Linters

If you want to disable one of the default linters, you can do so using the enable attribute:

linters:
    flake8:
        enable: false

The above would disable the flake8 linter which is enabled by default.

Ansible

Apply Ansible Lint to ansible playbooks/YAML files.

Options

  • ignore The rule id/tags that you do not want applied.

Example

linters:
    ansible:
        ignore: 'ANSIBLE0004,ANSIBLE0005'

Bash, Zsh, Sh

Check bash, zsh and sh scripts with shellcheck for lint and common mistakes.

Options

  • shell Select which shell dialect to check against. Valid values are: bash, sh, ksh or zsh. Default: sh
  • exclude Comma separated IDs of checks to ignore. Example: SC2154,SC2069

Example

linters:
    shellcheck:
        shell: bash
        exclude: 'SC2154,SC2069'
    

Chef

Check chef scripts with Foodcritic.

Options

  • path If your cookbooks aren't stored in the root, use this to set the path that foodcritic runs against. Example: path = cookbooks

CSS

CSSLint

Check CSS files with csslint.

Both warnings and errors will be turned into code review comments. If you don't want code review comments for specific rules, you should ignore them via the ignore option.

Options

  • ignore A comma separated list of rule ids to ignore.

Example

linters:
    csslint:
        ignore: 'box-model,ids'

Go

Check go-lang code with golint.

Options

  • min_confidence Set the confidence level of a problem before it is reported.

Example

linters:
    golint:
        min_confidence: 0.85

Java

Check java code with checkstyle 7.7.

Options

  • config Define the path to your checkstyle.xml file. This option is required.

Example

linters:
    checkstyle:
        config: ./checkstyle.xml

Javascript

ESLint

Check Javascript, and JSX code with eslint. In addition to the core ESLint rules, we also provide rule presets for React and Ember.js

Options

  • config Provide a path to the JSON config file for eslint.

Example

linters:
    eslint:
        config: './eslint.config'

Usage with React

To get started linting React applications, you can use the following ESLint configuration:

// in eslint.config
{
  "extends": ["eslint:recommended", "plugin:react/recommended"],
  "plugins": ["react"]
}

Usage with Ember.js

To start linting Ember.js projects, you can use the following ESLint configuration:

// in eslint.config
{
  "extends": [
    "eslint:recommended",
    "plugin:ember/recommended",
    "plugin:ember-best-practices/recommended"
  ],
  "plugins": ["ember", "ember-best-practices"]
}

Stickler CI offers the following ESLint presets:

  • eslint:recommended
  • plugin:react/all
  • plugin:react/recommended
  • plugin:ember/base
  • plugin:ember/recommended
  • plugin:ember-best-practices/base
  • plugin:ember-best-practices/recommended
  • plugin:ember-best-practices/experimental

If there is a preset you'd like to see support for drop us a line.

JSCS

Check Javascript with JSCS. If you don't supply a config file or a preset, the default JSCS rules will be used.

Options

  • config Provide a path to the json config file for JSCS.
  • preset Set which JSCS preset you want to use. Unused if config is set.

Example

linters:
    jscs:
        config: './jscs.config'

JSHint

Check Javascript code with jshint. If you don't supply a config file the jshint defaults will be used.

Options

  • config Provide a path to the json config file for jshint.

Example

linters:
    jshint:
        config: './jshint.config'

StandardJs

Use StandardJs to check Javascript. Standard offers easy to use style rules with no configuration to manage.

Example

linters:
    standardjs:

XO

Use XO to check Javascript. XO offers opinionated rules with no configuration files to manage.

Example

linters:
    xo:

PHP

Check PHP, Javascript and or CSS code with phpcs.

Options

  • standard The coding standard to use. By default the PSR2 standard is used. You can use one of the supported standards: CakePHP, PEAR, PSR1, PSR2, Squiz, WordPress, WordPress-Core or Zend.
  • extensions The extensions to check. By default only .php files will be checked.
  • tab_width The number of spaces to convert tabs into, this is useful for projects using tabs for indentation.
  • ignore A comma separated list of glob patterns of that should be excluded from PHPCS analysis.
  • exclude A comma separated list of sniff names to ignore.

Example

linters:
    phpcs:
        standard: 'PSR2'
        exclude: 'Generic.Files.LineLength,PSR2.Files.EndFileNewline'
        ignore: 'tests/fixtures/generated/*'
        extensions: '.php,.ctp'
        tab_width: 4

Puppet

Check puppet manifests with puppet-lint, against the puppetlabs style guide. .puppet-lintrc files will be respected, to allow each project to disable checks. A list of checks can be found by running puppet-lint --help locally.

Python

Flake8

Check Python code with flake8.

Options

  • ignore Set which pep8 error codes you wish to ignore.
  • exclude Exclude files or directories which match these comma separated patterns (default: .svn, CVS, .bzr, .hg, .git)
  • filename When parsing directories, only check filenames matching these comma separated patterns (default: *.py)
  • select Select errors and warnings (e.g. E,W6)
  • max-line-length Set maximum allowed line length (default: 79)
  • format Set the error format [default|pylint|]
  • max-complexity McCabe complexity threshold

Example

linters:
    flake8:
        ignore: 'W28'
        max-line-length: 80
        max-complexity: 20

pep8

Check python code with pep8.

Options

  • ignore Set which pep8 error codes you wish to ignore.

Example

linters:
    pep8:
        ignore: 'W28'

Ruby

Check ruby with rubocop.

Options

  • display_cop_names Set to true to pass display cop names in offense messages.

.rubocop.yml files will be respected, as described here.

Example

linters:
    rubocop:
        display_cop_names: true

Sass

Check sass and scss files with sass-lint.

Options

  • ignore A comma separated list of files to ignore.
  • config Project relative path to the sass-lint config file you want applied.

Example

linters:
    sasslint:
        config: ./sasslint.conf
        ignore: vendor/*.scss

Swift

Check swift files with swiftlint.

Options

There are no configuration file options for this linter. Any .swiftlint.yml files will be respected as described in the swiftlint documentation.

Example

linters:
    swiftlint:

TypeScript

Check typescript code with tslint. You need to include a tslint.json configuration file in your project or use the config option to provide a path to a config file.

Options

  • config Define a custom location for your tslint.json configuration file.

Example

linters:
    tslint:
        config: build/tslint.json

YAML (Yet Another Markup Language)

Check YAML files with yamllint. This is handy to examine confiugration files for many tools, and heira data in puppet.

Options

  • config Provide a path to the yaml config file for yamlhint.

Example

linters:
    yamllint:
        config: ./yamllint.conf

Didn't find what you were looking for?

Please tweet at us @sticklerci or email us at support@stickler-ci.com and we will help you out.