mirror of https://github.com/zulip/zulip.git
linter: Make duplicate html tag id detection work with archives.
We modify check-templates to check for duplicate id's in archive templates and app templates separately. This means we are allowing app and archive templates to potentially use same id's. This is needed because we intend to re use some js from the main app and having same id's help achieve that. Note: We haven't up until this point actually added archive templates. This commit is more of a preparatory commit for merging the basic archive infra.
This commit is contained in:
parent
9629be689b
commit
a62efd55df
|
@ -49,6 +49,7 @@ def check_html_templates(templates, all_dups):
|
|||
if 'templates/zerver/team.html' in templates:
|
||||
templates.remove('templates/zerver/team.html')
|
||||
|
||||
def check_for_duplicate_ids(templates: List[str]) -> Dict[str, List[str]]:
|
||||
template_id_dict = build_id_dict(templates)
|
||||
# TODO: Clean up these cases of duplicate ids in the code
|
||||
IGNORE_IDS = [
|
||||
|
@ -84,8 +85,20 @@ def check_html_templates(templates, all_dups):
|
|||
"' present at following files:")
|
||||
for fn in fns:
|
||||
print(fn)
|
||||
return bad_ids_dict
|
||||
|
||||
if list(bad_ids_dict.keys()):
|
||||
bad_ids_list = [] # type: List[str]
|
||||
archive_templates = list(filter(
|
||||
lambda fn: ('templates/zerver/archive' in fn),
|
||||
templates))
|
||||
templates = list(filter(
|
||||
lambda fn: ('templates/zerver/archive' not in fn),
|
||||
templates))
|
||||
|
||||
bad_ids_list += list(check_for_duplicate_ids(archive_templates).keys())
|
||||
bad_ids_list += list(check_for_duplicate_ids(templates).keys())
|
||||
|
||||
if bad_ids_list:
|
||||
print('Exiting--please clean up all duplicates before running this again.')
|
||||
sys.exit(1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue