stylelint: Start using stylelint to lint our css.

Tweaked by tabbott to document it.

Fixes #8894.
This commit is contained in:
Aditya Bansal 2018-07-25 17:37:24 +05:30 committed by Tim Abbott
parent 6f392d36e2
commit 0042694e24
2 changed files with 8 additions and 18 deletions

View File

@ -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
validating manifests)
- [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
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 puppet manifests with the puppet validator.
- Check HTML templates for matching tags and indentations.
- Check CSS for parsability.
- Check CSS for parsability and formatting.
- Check JavaScript code for addClass calls.
The remaining lint checks occur in `./tools/run-mypy`. It is probably somewhat
@ -204,19 +205,10 @@ clean those files up eventually.
#### CSS
Zulip does not currently lint its CSS for any kind of semantic correctness,
but that is definitely a goal moving forward.
We do ensure that our home-grown CSS parser can at least parse the CSS code.
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)
Zulip uses [stylelint](https://github.com/stylelint/stylelint) to lint
its CSS; see our
[configuration](https://github.com/zulip/zulip/blob/master/.stylelintrc)
for the rules we currently enforce.
#### Markdown, shell scripts, JSON fixtures

View File

@ -91,7 +91,7 @@ def run():
sys.exit(1)
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
if args.backend:
file_types = backend_file_types
@ -158,6 +158,7 @@ def run():
lint_functions[name] = run_linter
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('tslint', ['node', 'node_modules/.bin/tslint', '-c',
'static/ts/tslint.json'], ['ts'])
@ -166,9 +167,6 @@ def run():
external_linter('urls', ['tools/check-urls'], ['py'])
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
if not args.no_gitlint:
external_linter('commit_messages', ['tools/commit-message-lint'])