Allow disabling all checks for a file

Allow disabling of a file, even if it is invalid YAML (syntax error) by
including `# yamllint disable-file` in the first line.
This commit is contained in:
Joel Baranick
2019-11-13 23:32:36 -08:00
committed by Adrien Vergé
parent 92324ae730
commit fb400dc64b
3 changed files with 133 additions and 0 deletions

View File

@@ -189,6 +189,10 @@ def _run(buffer, conf, filepath):
assert hasattr(buffer, '__getitem__'), \
'_run() argument must be a buffer, not a stream'
first_line = next(parser.line_generator(buffer)).content
if re.match(r'^#\s*yamllint disable-file\s*$', first_line):
return
# If the document contains a syntax error, save it and yield it at the
# right line
syntax_error = get_syntax_error(buffer)