当前位置: 首页 > 软件库 > 大数据 > 数据查询 >

arcanist-linters

A collection of custom Arcanist linters
授权协议 Apache-2.0 License
开发语言 Java
所属分类 大数据、 数据查询
软件类型 开源软件
地区 不详
投 递 者 金阳曜
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Arcanist Linters

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

We also welcome additional contributions.

Linters

Apache Thrift

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

{
    "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 weregenerated 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.

Black

Uses the Black opinionated code formatterto normalize the format of Python code.

{
    "type": "black",
    "include": "(\\.py$)",
    "flags": ["-S", "--line-length=132"]
}

Checkstyle

Uses the Checkstyle tool to check Javacode 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"
}

Flake8

Lints Python source files using Flake8. This is anextended version of the stock ArcanistFlake8Linter that adds support forchecking required Python and extension versions.

{
    "type": "flake8ext",
    "include": "(\\.py$)",
    "flake8.python": "< 3.0",
    "flake8.extensions": {
        "assertive": "1.0.1",
        "naming": "0.7.0"
    }
}

Flawfinder

Lints C/C++ source files using flawfinder.

{
    "type": "flawfinder",
    "include": "(\\.(c|cc|cpp|h)$)"
}

GraphQL Schema Linter

Lint GraphQL Schema Definition Language (SDL) using graphql-schema-linter.

{
    "type": "graphql-schema",
    "include": "(\\.(graphql|gql)$)",
    "graphql-schema.rules": [
        "fields-have-descriptions",
        "types-have-descriptions"
    ],
    "graphql-schema.config": "config",
    "graphql-schema.custom-rules": [
        "config/custom-rules/*.js",
        "vendor/extra-graphql-rules/*.js"
    ],
    "graphql-schema.ignore": {
        "fields-have-descriptions": [
            "Obvious",
            "Query.obvious",
            "Query.something.obvious"
        ]
    },
    "graphql-schema.comment-descriptions": false,
    "graphql-schema.old-implements-syntax": false
}

Go Vet

Uses the Go vet command to lint for suspiciouscode constructs.

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

OpenAPI Validator

Lint OpenAPI specifications using openapi-validator.

(Supports openapi-validator version 0.36.0 and later.)

{
    "type": "openapi-spec",
    "version": ">=0.36.0",
    "openapi-spec.config": ".validaterc",
    "openapi-spec.debug": false,
    "openapi-spec.errors_only": true,
    "include": [
        "(\\.yaml$)"
    ]
}

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$)"
}

Pylint

Lints Python using pylint. Unlike the module thatships with Arcanist, this implementation works with recent releases of Pylintand also supports virtual environments.

{
    "type": "pinterest-pylint",
    "include": "(\\.py$)"
}

Pyright

Type-checks Python code using Pyright.

{
    "type": "pyright",
    "include": "(\\.py$)"
}

Python Requirements

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

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

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

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

Spectral

Lints OpenAPI documents using Spectral.

{
    "type": "spectral",
    "include": "(openapi.yaml)",
    "spectral.ruleset": ".spectral.yml",
}

ThriftCheck

Lints Thrift IDL files using ThriftCheck.

{
    "type": "thriftcheck",
    "include": "(\\.thrift$)",
    "thriftcheck.config": ".thriftcheck.toml",
    "thriftcheck.includes": [
        ".",
        "common"
    ]
}

Installation

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

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

Global Installation

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

$ git clone https://github.com/pinterest/arcanist-linters.git pinterest-linters
$ ls
arcanist
pinterest-linters
libphutil

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

{
  "load": ["pinterest-linters"]
}

Project Installation

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

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

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

{
  "load": [".pinterest-linters"]
}