pinterest/arcanist-linters

Name: arcanist-linters

Owner: Pinterest

Description: A collection of custom Arcanist linters

Created: 2016-04-21 22:31:26.0

Updated: 2018-05-04 02:31:56.0

Pushed: 2018-04-16 20:28:49.0

Homepage:

Size: 43

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Arcanist Linters

This is a collection of custom Arcanist linters that we've written at Pinterest.

Linters
Apache Thrift

Lints for errors in Apache Thrift IDL (schema) files using the thrift compiler.


"type": "thrift",
"include": "(\\.thrift$)",
"flags": [
    "--allow-64bit-consts"
],
"version": ">= 0.9.0",
"thrift.generators": [
    "py:dynamic,utf8strings,new_style,slots",
    "java",
    "go",
    "erl"
],
"thrift.includes": [
    ".",
    "common"
]

Apache Thrift Generated

Lints files generated by the Apache Thrift compiler to ensure they were generated using a supported Thrift compiler.


"type": "thrift-gen",
"include": "(^schemas/.*\\.py$)",
"thrift-gen.version": ">=0.9.3"

Note: Currently only generated Python files are supported.

Checkstyle

Uses the Checkstyle tool to check Java code against a coding standard.


"type": "checkstyle",
"include": "(\\.java$)",
"checkstyle.config": "google_check.xml"

ESLint

Lints JavaScript and JSX files using ESLint.


"type": "eslint",
"include": "(\\.js$)",
"bin": "./node_modules/.bin/eslint",
"eslint.config": "~/my-eslint.json",
"eslint.env": "browser,node"

Go Vet

Uses the Go vet command to lint for suspicious code constructs.


"type": "govet",
"include": "(^src/example.com/.*\\.go$)"

Prettier

Formats JavaScript using Prettier.


"type": "prettier",
"include": "(\\.js$)",
"bin": "./node_modules/.bin/prettier",
"prettier.cwd": "./"

Prettier ESLint

Formats JavaScript using Prettier and then fixes with ESLint.


"type": "prettier-eslint",
"include": "(\\.js$)",
"bin": "./node_modules/.bin/prettier-eslint",
"prettier-eslint.cwd": "./"

Python Imports

Lints for illegal Python module imports.


"type": "python-imports",
"python-imports.pattern": "(mock)",
"include": "(\\.py$)",
"exclude": "(^tests/)"

Python isort

Lints Python imports using isort.


"type": "isort",
"include": "(\\.py$)"

Python Requirements

Ensures Python package requirements in requirements.txt files are sorted, unique, and pinned to exact versions.


"type": "requirements-txt",
"include": "(requirements.txt$)"

Individual requirement lines can be excluded by adding a # noqa comment:

=1.10.0  # noqa: allow any recent version of six
Installation

In short, you'll need to add this repository to your local machine and tell Arcanist to load the extension. You either can do this globally or on a per-project basis.

Once installed, the individual linters can be enabled and configured via the project's .arclint file. See the Arcanist Lint User Guide for details.

Global Installation

Arcanist can load modules from an absolute path, but because it also searches for modules one level up from itself on the filesystem, it's convenient to clone this repository at the same level as arcanist and libphutil.

t clone https://github.com/pinterest/arcanist-linters.git pinterest-linters

nist
erest-linters
hutil

Then, tell Arcanist to load the module by editing ~/.arcconfig (or /etc/arcconfig):


oad": ["pinterest-linters"]

Project Installation

You can also load arcanist-linters on a per-project basis. In that case, using a git submodule is probably the most convenient approach.

t submodule add https://github.com/pinterest/arcanist-linters.git .pinterest-linters
t submodule update --init

Then, enable the module in your project-level .arcconfig file:


oad": [".pinterest-linters"]


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.