From 2e029eb58b9a8ca2d041f3dd1dc2c8aed2755438 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 23 Jul 2020 16:16:46 -0700 Subject: [PATCH] lint: Use Prettier for JSON files. Signed-off-by: Anders Kaseorg --- .editorconfig | 23 +++++++++++++---------- .prettierignore | 5 +++++ prettier.config.js | 6 +++--- tools/lint | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.editorconfig b/.editorconfig index 08c0da732b..d6aa1e2e18 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,19 +3,22 @@ root = true [*] end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.{sh,py,pyi,js,ts,json,xml,css,scss,hbs,html}] indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{sh,py,pyi,xml,css,scss,hbs,html}] indent_size = 4 -[*.py] -max_line_length = 110 - -[*.{js,ts}] +[{*.{js,json,ts},check-openapi}] +indent_size = 4 max_line_length = 100 -[*.{svg,rb,pp}] -indent_style = space +[*.{py,pyi}] +max_line_length = 110 + +[*.{svg,rb,pp,yaml,yml}] +indent_size = 2 + +[package.json] indent_size = 2 diff --git a/.prettierignore b/.prettierignore index 59c243b8b0..790e11b2eb 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,6 @@ +/corporate/tests/stripe_fixtures +/locale /static/third +/tools/setup/emoji/emoji_map.json +/zerver/tests/fixtures +/zerver/webhooks/*/fixtures diff --git a/prettier.config.js b/prettier.config.js index 1a98a2c0e5..c638745810 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,6 +1,5 @@ module.exports = { bracketSpacing: false, - tabWidth: 4, trailingComma: "all", overrides: [ { @@ -10,9 +9,10 @@ module.exports = { }, }, { - files: ["**.yml", "**.yaml"], + files: ["tsconfig.json"], options: { - tabWidth: 2, + parser: "json5", + quoteProps: "preserve", }, }, ], diff --git a/tools/lint b/tools/lint index 352e6548d7..750c91f6d8 100755 --- a/tools/lint +++ b/tools/lint @@ -94,7 +94,7 @@ def run() -> None: description="Sorts Python import statements", check_arg=['--check-only', '--diff']) linter_config.external_linter('prettier', ['node_modules/.bin/prettier', '--check'], - ['js', 'ts', 'yaml', 'yml'], + ['js', 'json', 'ts', 'yaml', 'yml'], fix_arg=['--write'], description="Formats JavaScript and YAML", # https://github.com/prettier/prettier/pull/8703