lint: Use Prettier for JavaScript files.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-14 14:34:29 -07:00 committed by Tim Abbott
parent b65d2e063d
commit ed183fb95f
3 changed files with 20 additions and 2 deletions

1
.prettierignore Normal file
View File

@ -0,0 +1 @@
/static/third

View File

@ -1,3 +1,19 @@
module.exports = { module.exports = {
bracketSpacing: false, bracketSpacing: false,
tabWidth: 4,
trailingComma: "all",
overrides: [
{
files: ["frontend_tests/casper_tests/*.js", "frontend_tests/casper_lib/*.js"],
options: {
trailingComma: "es5",
},
},
{
files: ["**.yml", "**.yaml"],
options: {
tabWidth: 2,
},
},
],
}; };

View File

@ -93,9 +93,10 @@ def run() -> None:
linter_config.external_linter('isort', ['isort'], ['py'], linter_config.external_linter('isort', ['isort'], ['py'],
description="Sorts Python import statements", description="Sorts Python import statements",
check_arg=['--check-only', '--diff']) check_arg=['--check-only', '--diff'])
linter_config.external_linter('prettier', ['node_modules/.bin/prettier'], ['yaml', 'yml'], linter_config.external_linter('prettier', ['node_modules/.bin/prettier'],
['js', 'ts', 'yaml', 'yml'],
check_arg=['--check'], fix_arg=['--write'], check_arg=['--check'], fix_arg=['--write'],
description="Formats YAML files", description="Formats JavaScript and YAML",
# https://github.com/prettier/prettier/pull/8703 # https://github.com/prettier/prettier/pull/8703
suppress_line=lambda line: line in ["Checking formatting...\n", "All matched files use Prettier code style!\n"]) suppress_line=lambda line: line in ["Checking formatting...\n", "All matched files use Prettier code style!\n"])