Skip to main content

Write your own linting rules using regular expressions.

Project description

/(re)lint/

reLint

Regular Expression Linter

Write your own linting rules using regular expressions.

PyPi Version Test Coverage GitHub License

Installation

python3 -m pip install relint
# or, if you have super advanced linting expressions
python3 -m pip install "relint[regex]"

Examples & Recipes – The reLint Cookbook

Usage

You can write your own regular rules in a YAML file, like so:

- name: No ToDo
  pattern: '(?i)todo' # case insensitive flag
  hint: Get it done right away!
  filePattern: .*\.(py|js)
  error: false

The name attribute is the name of your linter, the pattern can be any regular expression. The linter does lint entire files, therefore your expressions can match multiple lines and include newlines.

You can narrow down the file types your linter should be working with, by providing the optional filePattern attribute. The default is .*.

The optional error attribute allows you to only show a warning but not exit with a bad (non-zero) exit code. The default is true.

The following command will lint all files in the current directory:

relint -c .relint.yml FILE FILE2 ...

The default configuration file name is .relint.yml within your working directory, but you can provide any YAML or JSON file.

If you prefer linting changed files (cached on git) you can use the option --diff [-d] or --git-diff [-g]:

git diff --unified=0 | relint my_file.py --diff

pre-commit

You can automate the linting process by adding a pre-commit hook to your project. Add the following entry to your .pre-commit-config.yaml:

- repo: https://github.com/codingjoe/relint
  rev: 1.4.0
  hooks:
    - id: relint
      args: [-W]  # optional, if you want to fail on warnings during commit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

relint-3.4.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

relint-3.4.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file relint-3.4.0.tar.gz.

File metadata

  • Download URL: relint-3.4.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for relint-3.4.0.tar.gz
Algorithm Hash digest
SHA256 8fecbe5bcc66f257121aa91f280c4bdffaf81fc802ea68bef9b8e1a308d38952
MD5 10653d1eef322c2069ce241805c03a51
BLAKE2b-256 c1fe2971e50d7d8d141b106fad6cfbf6e494a075fbfe3f447727787f585dee77

See more details on using hashes here.

Provenance

The following attestation bundles were made for relint-3.4.0.tar.gz:

Publisher: release.yml on codingjoe/relint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file relint-3.4.0-py3-none-any.whl.

File metadata

  • Download URL: relint-3.4.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for relint-3.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2234c48e36194242b4197321dc600a9ba0628c64900b0943bf8c836875c97499
MD5 9d339b751010a58b39c9364fc1830b46
BLAKE2b-256 41ae91e4f8820ab9c70cf25c7677bbf83193d8fe778cce2fd55dc3b6930a8ffe

See more details on using hashes here.

Provenance

The following attestation bundles were made for relint-3.4.0-py3-none-any.whl:

Publisher: release.yml on codingjoe/relint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page