From ab6ed22bffcb239f010ccb94a25fc8381542a4ea Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 22 Jul 2020 12:25:49 -0700 Subject: [PATCH] docs: Document that we use Prettier. Signed-off-by: Anders Kaseorg --- README.md | 1 + docs/contributing/code-style.md | 18 +++++------------- docs/testing/linters.md | 3 +++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 78e57b5094..aa0f84c123 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ largest and fastest growing open source group chat project. [![CircleCI branch](https://img.shields.io/circleci/project/github/zulip/zulip/master.svg)](https://circleci.com/gh/zulip/zulip/tree/master) [![Coverage Status](https://img.shields.io/codecov/c/github/zulip/zulip/master.svg)](https://codecov.io/gh/zulip/zulip/branch/master) [![Mypy coverage](https://img.shields.io/badge/mypy-100%25-green.svg)][mypy-coverage] +[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![GitHub release](https://img.shields.io/github/release/zulip/zulip.svg)](https://github.com/zulip/zulip/releases/latest) [![docs](https://readthedocs.org/projects/zulip/badge/?version=latest)](https://zulip.readthedocs.io/en/latest/) [![Zulip chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://chat.zulip.org) diff --git a/docs/contributing/code-style.md b/docs/contributing/code-style.md index b45e3d3bb2..b80ca81d25 100644 --- a/docs/contributing/code-style.md +++ b/docs/contributing/code-style.md @@ -251,19 +251,11 @@ code a lot uglier, in which case it's fine to go up to 120 or so. ### JavaScript and TypeScript -When calling a function with an anonymous function as an argument, use -this style: - - my_function('foo', data => { - var x = ...; - // ... - }); - -The inner function body is indented one level from the outer function -call. The closing brace for the inner function and the closing -parenthesis for the outer call are together on the same line. This style -isn't necessarily appropriate for calls with multiple anonymous -functions or other arguments following them. +Our JavaScript and TypeScript code is formatted with +[Prettier](https://prettier.io/). You can ask Prettier to reformat +all code via our [linter tool](../testing/linters.md) with `tools/lint +--only=prettier --fix`. You can also [integrate it with your +editor](https://prettier.io/docs/en/editors.html). Combine adjacent on-ready functions, if they are logically related. diff --git a/docs/testing/linters.md b/docs/testing/linters.md index c2fc8548c3..570f1a651a 100644 --- a/docs/testing/linters.md +++ b/docs/testing/linters.md @@ -19,6 +19,7 @@ below will direct you to the official documentation for these projects. - [eslint](https://eslint.org) - [mypy](http://mypy-lang.org/) +- [Prettier](https://prettier.io/) - [puppet](https://puppet.com/) (puppet provides its own mechanism for validating manifests) - [pyflakes](https://pypi.python.org/pypi/pyflakes) @@ -100,6 +101,7 @@ following checks: - Check Python code with pyflakes. - Check JavaScript and TypeScript code with eslint. +- Check JavaScript, TypeScript, and YAML formatting with Prettier. - Check Python code for custom Zulip rules. - Check non-Python code for custom Zulip rules. - Check puppet manifests with the puppet validator. @@ -184,6 +186,7 @@ that we exempt may be deemed not worthwhile to fix. We check our JavaScript code in a few different ways: - We run eslint. +- We check code formatting with Prettier. - We perform custom Zulip regex checks on the code. #### Puppet manifests