mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	stylelint: Start using stylelint to lint our css.
Tweaked by tabbott to document it. Fixes #8894.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							6f392d36e2
						
					
				
				
					commit
					0042694e24
				
			@@ -22,6 +22,7 @@ below will direct you to the official documentation for these projects.
 | 
				
			|||||||
- [puppet](https://puppet.com/) (puppet provides its own mechanism for
 | 
					- [puppet](https://puppet.com/) (puppet provides its own mechanism for
 | 
				
			||||||
  validating manifests)
 | 
					  validating manifests)
 | 
				
			||||||
- [pyflakes](https://pypi.python.org/pypi/pyflakes)
 | 
					- [pyflakes](https://pypi.python.org/pypi/pyflakes)
 | 
				
			||||||
 | 
					- [stylelint](https://github.com/stylelint/stylelint)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Zulip also uses some home-grown code to perform tasks like validating
 | 
					Zulip also uses some home-grown code to perform tasks like validating
 | 
				
			||||||
indentation in template files, enforcing coding standards that are unique
 | 
					indentation in template files, enforcing coding standards that are unique
 | 
				
			||||||
@@ -90,7 +91,7 @@ following checks:
 | 
				
			|||||||
- Check non-Python code for custom Zulip rules.
 | 
					- Check non-Python code for custom Zulip rules.
 | 
				
			||||||
- Check puppet manifests with the puppet validator.
 | 
					- Check puppet manifests with the puppet validator.
 | 
				
			||||||
- Check HTML templates for matching tags and indentations.
 | 
					- Check HTML templates for matching tags and indentations.
 | 
				
			||||||
- Check CSS for parsability.
 | 
					- Check CSS for parsability and formatting.
 | 
				
			||||||
- Check JavaScript code for addClass calls.
 | 
					- Check JavaScript code for addClass calls.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The remaining lint checks occur in `./tools/run-mypy`.  It is probably somewhat
 | 
					The remaining lint checks occur in `./tools/run-mypy`.  It is probably somewhat
 | 
				
			||||||
@@ -204,19 +205,10 @@ clean those files up eventually.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#### CSS
 | 
					#### CSS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Zulip does not currently lint its CSS for any kind of semantic correctness,
 | 
					Zulip uses [stylelint](https://github.com/stylelint/stylelint) to lint
 | 
				
			||||||
but that is definitely a goal moving forward.
 | 
					its CSS; see our
 | 
				
			||||||
 | 
					[configuration](https://github.com/zulip/zulip/blob/master/.stylelintrc)
 | 
				
			||||||
We do ensure that our home-grown CSS parser can at least parse the CSS code.
 | 
					for the rules we currently enforce.
 | 
				
			||||||
This is a slightly more strict check than checking that the CSS is
 | 
					 | 
				
			||||||
compliant to the official spec, as our parser will choke on unusual
 | 
					 | 
				
			||||||
constructs that we probably want to avoid in our code, anyway.  (When
 | 
					 | 
				
			||||||
the parser chokes, the lint check will fail.)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You can find the code here:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- driver: [check-css](https://github.com/zulip/zulip/blob/master/tools/check-css)
 | 
					 | 
				
			||||||
- engine: [lib/css_parser.py](https://github.com/zulip/zulip/blob/master/tools/lib/css_parser.py)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Markdown, shell scripts, JSON fixtures
 | 
					#### Markdown, shell scripts, JSON fixtures
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,7 +91,7 @@ def run():
 | 
				
			|||||||
            sys.exit(1)
 | 
					            sys.exit(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    backend_file_types = ['py', 'sh', 'pp', 'json', 'md', 'txt', 'text', 'yaml', 'rst']
 | 
					    backend_file_types = ['py', 'sh', 'pp', 'json', 'md', 'txt', 'text', 'yaml', 'rst']
 | 
				
			||||||
    frontend_file_types = ['js', 'css', 'handlebars', 'html']
 | 
					    frontend_file_types = ['js', 'css', 'scss', 'handlebars', 'html']
 | 
				
			||||||
    file_types = backend_file_types + frontend_file_types
 | 
					    file_types = backend_file_types + frontend_file_types
 | 
				
			||||||
    if args.backend:
 | 
					    if args.backend:
 | 
				
			||||||
        file_types = backend_file_types
 | 
					        file_types = backend_file_types
 | 
				
			||||||
@@ -158,6 +158,7 @@ def run():
 | 
				
			|||||||
        lint_functions[name] = run_linter
 | 
					        lint_functions[name] = run_linter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    external_linter('add_class', ['tools/find-add-class'], ['js'])
 | 
					    external_linter('add_class', ['tools/find-add-class'], ['js'])
 | 
				
			||||||
 | 
					    external_linter('css', ['node', 'node_modules/.bin/stylelint'], ['css', 'scss'])
 | 
				
			||||||
    external_linter('eslint', ['node', 'node_modules/.bin/eslint', '--quiet', '--cache'], ['js'])
 | 
					    external_linter('eslint', ['node', 'node_modules/.bin/eslint', '--quiet', '--cache'], ['js'])
 | 
				
			||||||
    external_linter('tslint', ['node', 'node_modules/.bin/tslint', '-c',
 | 
					    external_linter('tslint', ['node', 'node_modules/.bin/tslint', '-c',
 | 
				
			||||||
                               'static/ts/tslint.json'], ['ts'])
 | 
					                               'static/ts/tslint.json'], ['ts'])
 | 
				
			||||||
@@ -166,9 +167,6 @@ def run():
 | 
				
			|||||||
    external_linter('urls', ['tools/check-urls'], ['py'])
 | 
					    external_linter('urls', ['tools/check-urls'], ['py'])
 | 
				
			||||||
    external_linter('swagger', ['node', 'tools/check-swagger'], ['yaml'])
 | 
					    external_linter('swagger', ['node', 'tools/check-swagger'], ['yaml'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Note that check-css no longer runs due to the SCSS conversion.
 | 
					 | 
				
			||||||
    # See #8894 for more details.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Disabled check for imperative mood until it is stabilized
 | 
					    # Disabled check for imperative mood until it is stabilized
 | 
				
			||||||
    if not args.no_gitlint:
 | 
					    if not args.no_gitlint:
 | 
				
			||||||
        external_linter('commit_messages', ['tools/commit-message-lint'])
 | 
					        external_linter('commit_messages', ['tools/commit-message-lint'])
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user