mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	check-templates: Insist on 4-space indents.
We now complain about programmers who don't use 4-space indents in template files, rather than letting the pretty printer fix them. This is partly just to simplify the pretty printer code (in future commits), but it also makes the symptom more obvious to newbie developers. They are probably just as able to react to the direct error messages as they are able to figure out how to read diffs from the pretty printer and grok the --fix syntax. And once they learn the convention and configure their editor, it should then be a one time problem.
This commit is contained in:
		@@ -453,6 +453,19 @@ def prevent_whitespace_violations(fn: str, tokens: List[Token]) -> None:
 | 
			
		||||
                    f"""Please just make row {token.line} in {fn} a truly blank line (no spaces)."""
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
            if len(token.s) % 4 != 0:
 | 
			
		||||
                raise TemplateParserException(
 | 
			
		||||
                    f"""
 | 
			
		||||
                        Please use 4-space indents for template files. Most of our
 | 
			
		||||
                        codebase (including Python and JavaScript) uses 4-space indents,
 | 
			
		||||
                        so it's worth investing in configuring your editor to use
 | 
			
		||||
                        4-space indents for files like
 | 
			
		||||
                        {fn}
 | 
			
		||||
 | 
			
		||||
                        The line at row {token.line} is indented with {len(token.s)} spaces.
 | 
			
		||||
                    """
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        if token.kind == "whitespace":
 | 
			
		||||
            if len(token.s) > 1:
 | 
			
		||||
                raise TemplateParserException(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user