lint: Clean up json_rules logic for tab-based whitespace.

This both improves the comment to be more readable, and also uses the
new and improved exclude feature to limit the exclusion to just the
webhook fixtures (where it's needed).

Also fixes a mypy error.
This commit is contained in:
Tim Abbott
2017-11-23 11:56:05 -08:00
parent fb88eaa2d8
commit 15501c8b07
2 changed files with 17 additions and 12 deletions

View File

@@ -1,16 +1,16 @@
{
"env": {
"shared-node-browser": true
"shared-node-browser": true
},
"globals": {
"assert": false,
"casper": false,
"document": false,
"set_global": false,
"window": false,
"zrequire": false
"assert": false,
"casper": false,
"document": false,
"set_global": false,
"window": false,
"zrequire": false
},
"rules": {
"no-sync": 0
"no-sync": 0
}
}

View File

@@ -604,14 +604,19 @@ def build_custom_checkers(by_lang):
'description': "Period should be part of the translatable string."},
]
json_rules = [
# Here, we don't use `whitespace_rules`, because the tab-based
# whitespace rule flags a lot of third-party JSON fixtures
# under zerver/webhooks that we want preserved verbatim. So
# we just include the trailing whitespace rule and a modified
# version of the tab-based whitespace rule (we can't just use
# exclude in whitespace_rules, since we only want to ignore
# JSON files with tab-based whitespace, not webhook code).
trailing_whitespace_rule,
# Since most json files are fixtures containing 3rd party json code,
# we allow tab-based whitespace except for a whitelist of files.
{'pattern': '\t',
'strip': '\n',
'include_only': set(['zerver/fixtures/']),
'exclude': set(['zerver/webhooks/']),
'description': 'Fix tab-based whitespace'},
]
] # type: RuleList
markdown_rules = markdown_whitespace_rules + prose_style_rules + [
{'pattern': '\[(?P<url>[^\]]+)\]\((?P=url)\)',
'description': 'Linkified markdown URLs should use cleaner <http://example.com> syntax.'},