Skip to content

Commit adfa1a4

Browse files
committed
Add an error attribute to not fail and only show warnings
1 parent 67fcaa7 commit adfa1a4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.relint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
filename:
55
- "*.py"
66
- "*.js"
7+
error: false

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ You can write your own regular rules in a YAML file, like so:
2525
filename:
2626
- "*.py"
2727
- "*.js"
28+
error: false
2829
2930
The ``name`` attribute is the name of your linter, the ``pattern`` can be
3031
any regular expression. The linter does lint entire files, therefore your
@@ -33,6 +34,9 @@ expressions can match multiple lines and include newlines.
3334
You can narrow down the file types your linter should be working with, by
3435
providing the optional ``filename`` attribute. The default is ``*``.
3536

37+
The optional `error` attribute allows you to only show a warning but not exit
38+
with a bad (non-zero) exit code. The default is `true`.
39+
3640
The following command will lint all files in the current directory:
3741

3842
.. code-block:: bash

relint.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def parse_args():
2828
return parser.parse_args()
2929

3030

31-
Test = namedtuple('Test', ('name', 'pattern', 'hint', 'filename'))
31+
Test = namedtuple('Test', ('name', 'pattern', 'hint', 'filename', 'error'))
3232

3333

3434
def load_config(path):
@@ -42,6 +42,7 @@ def load_config(path):
4242
pattern=re.compile(test['pattern']),
4343
hint=test.get('hint'),
4444
filename=filename,
45+
error=test.get('error', True)
4546
)
4647

4748

@@ -79,7 +80,7 @@ def main():
7980
exit_code = 0
8081

8182
for filename, test, match in matches:
82-
exit_code = 1
83+
exit_code = test.error if exit_code == 0 else exit_code
8384
if filename != _filename:
8485
_filename = filename
8586
lines = match.string.splitlines()

0 commit comments

Comments
 (0)