Skip to content

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

skip

--[no-]regex-lint-skip

PANTS_REGEX_LINT_SKIP

default: False

If true, don't use regex-lint when running pants lint.

config

--regex-lint-config="{'key1': val1, 'key2': val2, ...}"

PANTS_REGEX_LINT_CONFIG

default: {}

Config schema is as follows:

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

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

one of: none, summary, nonmatching, names, all

default: nonmatching

How much detail to include in the result.

Advanced options

None

Deprecated options

None