-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a "quote-percent" option to the "quoted-strings" rule #244
Conversation
Hello @leofeyer, thanks for your proposal. I'm against features specific to one program (including Symfony), and I think However, we could imagine something more general, like a new option Then for Symfony you could use: quoted-strings:
required: only-when-needed
needed-extra-regex: ^%.*%$ If you like the idea, feel free to open a new PR! |
What about making CONF = {'quote-type': ('any', 'single', 'double'),
'required': (True, False, 'only-when-needed'),
'start-tokens': set()}
DEFAULT = {'quote-type': 'any',
'required': True,
'start-tokens': {'#', '*', '!', '?', '@', '`', '&', ',', '-', '{', '}', '[', ']', ':'}} I am not familiar with Python, so no idea if that is the correct syntax. |
It wouldn't be a general solution. What if I want to quote strings that look like phone numbers, for example? A regex would be more configurable. |
I agree. 👍 As I said, I am not familiar with Python, but I will try my best to create a PR that implements the |
Cool! I recommend starting by writing tests in |
See #246. 🎉 |
Change implementation of `required: only-when-needed`, because maintaining a list of `START_TOKENS` and just looking at the first character of string values has proven to be partially broken. Cf. discussion at #246 (comment). Fixes #242 and #244.
Change implementation of `required: only-when-needed`, because maintaining a list of `START_TOKENS` and just looking at the first character of string values has proven to be partially broken. Cf. discussion at #246 (comment). Fixes #242 and #244.
Change implementation of `required: only-when-needed`, because maintaining a list of `START_TOKENS` and just looking at the first character of string values has proven to be partially broken. Cf. discussion at #246 (comment). Fixes #242 and #244.
I really like the new
required: only-when-needed
option that has been added to thequoted-strings
rule in version 1.21.0. Thank you for that.When linting Symfony configuration files, there is a kind of false-positive though: Symfony requires placeholders such as
%kernel.project_dir%
or%env(DATABASE_URL)%
to be quoted. Now even though this deviates from the YAML standard, it would be nice if yamllint would support this somehow.This PR outlines a possible solution by adding a
quote-percent
option to thequoted-strings
rule. Tests are still missing, because I wanted to discuss the implementation first. WDYT?