I'm trying to get SublimeLinter and HTMLTidy to ignore certain php warnings. Specifically the missing <!DOCTYPE> declaration
, inserting implicit <body>
, and inserting missing 'title' element
. It tells you right in the docs how to do this:
{
"ignore_match": [
"missing <!DOCTYPE> declaration",
"inserting (?:implicit <body>|missing 'title' element)"
]
}
Source: Linter Settings
Adding that to my SublimeLinter user settings file worked fine. The problem is that I want it only to apply to PHP files, because using just the above will also ignore it on HTML files.
The docs have an example for applying ignore_match
only to certain extensions:
{
"ignore_match": {
"inc": [
"missing <!DOCTYPE> declaration",
"inserting (?:implicit <body>|missing 'title' element)"
]
}
So I copied that and changed the inc
to php
and I still get those warnings on php files.
Here is what the htmltidy
section of my SublimeLinter settings file looks like:
"htmltidy": {
"@disable": false,
"args": [],
"excludes": [],
"ignore_match": {
"php": [
"missing <!DOCTYPE> declaration",
"inserting (?:implicit <body>|missing 'title' element)"
]
}
}
Any idea why ignore_match
works as it is supposed to until I specify an extension that the ignore_match
rule is supposed to apply to?
This is SublimeLinter bug. The settings tokenizer allows to replace tokens like ${project}
or ${home}
in settings. It tries to do it recursively but mess up when you use nested list inside ignore_match
dictionary.
I've tested it and it changes all strings, wraps it to list and assigns the list name as key to dictionary, so:
{"ignore_match": { "php": ["Error1", "Error2"]}}
is converted to:
{"ignore_match": None, "php": ["Error1","Error2"]}}
It's quite hard to debug what is going on so I have to recommend saving ignore_match settings before tokenizing and reset after it tokenize. Something like that in lint/linter.py get_merged_settings
:
ims = None
if 'ignore_match' in settings.keys():
ims = settings['ignore_match']
del settings['ignore_match']
self.replace_settings_tokens(settings)
if ims:
settings['ignore_match'] = ims