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

@@ -37,7 +37,7 @@ class SimpleConfigTestCase(unittest.TestCase):
config.YamlLintConfigError,
'invalid config: no such rule: "this-one-does-not-exist"'):
config.YamlLintConfig('rules:\n'
' this-one-does-not-exist: {}\n')
' this-one-does-not-exist: enable\n')
def test_missing_option(self):
with self.assertRaisesRegexp(
@@ -65,6 +65,11 @@ class SimpleConfigTestCase(unittest.TestCase):
self.assertEqual(config.validate_rule_conf(Rule, False), False)
self.assertEqual(config.validate_rule_conf(Rule, 'disable'), False)
self.assertEqual(config.validate_rule_conf(Rule, {}),
{'level': 'error'})
self.assertEqual(config.validate_rule_conf(Rule, 'enable'),
{'level': 'error'})
config.validate_rule_conf(Rule, {'level': 'error'})
config.validate_rule_conf(Rule, {'level': 'warning'})
self.assertRaises(config.YamlLintConfigError,