Config: Allow 'enable' keyword for rules

In the same manner as 'disable', 'enable' allows setting a rule on
without worrying about its options.
This commit is contained in:
Adrien Vergé
2016-03-06 07:44:32 +01:00
parent 69ef9a7272
commit 8fca8a7a33
7 changed files with 22 additions and 14 deletions

View File

@@ -34,11 +34,11 @@ rules:
spaces: 2
indent-sequences: yes
check-multi-line-strings: no
key-duplicates: {}
key-duplicates: enable
line-length:
max: 80
allow-non-breakable-words: yes
new-line-at-end-of-file: {level: error}
new-line-at-end-of-file: enable
new-lines:
type: unix
trailing-spaces: {}
trailing-spaces: enable

View File

@@ -83,6 +83,8 @@ class YamlLintConfig(object):
def validate_rule_conf(rule, conf):
if conf is False or conf == 'disable':
return False
elif conf == 'enable':
conf = {}
if type(conf) == dict:
if 'level' not in conf:
@@ -117,7 +119,8 @@ def validate_rule_conf(rule, conf):
(optkey, rule.ID))
else:
raise YamlLintConfigError(('invalid config: rule "%s": should be '
'either "disable" or a dict') % rule.ID)
'either "enable", "disable" or a dict')
% rule.ID)
return conf