Add the "quote-percent" option

pull/244/head
Leo Feyer 5 years ago committed by GitHub
parent 542ae758f5
commit b41de1d46c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -72,9 +72,11 @@ from yamllint.linter import LintProblem
ID = 'quoted-strings'
TYPE = 'token'
CONF = {'quote-type': ('any', 'single', 'double'),
'required': (True, False, 'only-when-needed')}
'required': (True, False, 'only-when-needed'),
'quote-percent': (True, False)}
DEFAULT = {'quote-type': 'any',
'required': True}
'required': True,
'quote-percent': False}
DEFAULT_SCALAR_TAG = u'tag:yaml.org,2002:str'
START_TOKENS = {'#', '*', '!', '?', '@', '`', '&',
@ -129,6 +131,9 @@ def check(conf, token, prev, next, nextnext, context):
elif not token.plain:
if conf['quote-percent']:
START_TOKENS.add('%')
# Quotes are disallowed when not needed
if (tag == DEFAULT_SCALAR_TAG and token.value
and token.value[0] not in START_TOKENS):

Loading…
Cancel
Save