Write your own linting rules using regular expressions.
Project description
reLint
Regular Expression Linter
Write your own linting rules using regular expressions.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file relint-3.3.1.tar.gz.
File metadata
- Download URL: relint-3.3.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b25197226ffaf5a227d746d783bce0b438e6878b75d91337e2f29d357e99cac
|
|
| MD5 |
7e9c1f51cd0ecd5d0880971a67af1b1e
|
|
| BLAKE2b-256 |
79ace124898c806d1c5b5bfdc8af944be55889acc002b2fb7a4a0b4cb13bb44b
|
File details
Details for the file relint-3.3.1-py3-none-any.whl.
File metadata
- Download URL: relint-3.3.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e5ee9b54cf34c0234dfb11fe0abe0924b1e56ad984c19d9df84b6f88a7c4265
|
|
| MD5 |
2200f46b4ee7d8866811f8ed1a168141
|
|
| BLAKE2b-256 |
f0cd5553a884a69d05e832c513524c85188d96bbd0d83c217656241c7b101f1a
|