Skip to main content
Version: 2.15 (deprecated)

regex-lint


Lint your code using regex patterns, e.g. to check for copyright headers.

To activate this with the lint goal, you must set [regex-lint].config.

Unlike other linters, this can run on files not owned by targets, such as BUILD files.

Backend: pants.backend.project_info

Config section: [regex-lint]

Basic options

config

--regex-lint-config="{'key1': val1, 'key2': val2, ...}"
PANTS_REGEX_LINT_CONFIG
pants.toml
[regex-lint.config]
key1 = val1
key2 = val2
...
default: {}

Config schema is as follows:

{
'required_matches': {
'path_pattern1': [content_pattern1, content_pattern2],
'path_pattern2': [content_pattern1, content_pattern3],
...
},
'path_patterns': [
{
'name': path_pattern1',
'pattern': <path regex pattern>,
'inverted': True|False (defaults to False),
'content_encoding': <encoding> (defaults to utf8)
},
...
],
'content_patterns': [
{
'name': 'content_pattern1',
'pattern': <content regex pattern>,
'inverted': True|False (defaults to False)
}
...
]
}

Meaning: if a file matches some path pattern, its content must match all the corresponding content patterns.

It's often helpful to load this config from a JSON or YAML file. To do that, set [regex-lint].config = '@path/to/config.yaml', for example.

detail_level

--regex-lint-detail-level=<DetailLevel>
PANTS_REGEX_LINT_DETAIL_LEVEL
pants.toml
[regex-lint]
detail_level = <DetailLevel>
one of: none, summary, nonmatching, names, all
default: nonmatching

How much detail to include in the result.

skip

--[no-]regex-lint-skip
PANTS_REGEX_LINT_SKIP
pants.toml
[regex-lint]
skip = <bool>
default: False

If true, don't use regex-lint when running /home/josh/work/scie-pants/dist/pants lint.

Advanced options

None

Deprecated options

None

None