Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

lint: Use Prettier for JavaScript files.

Anders Kaseorged183fb95fcb
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 00000000000..59c243b8b00
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1 @@
+/static/third
diff --git a/prettier.config.js b/prettier.config.js
index 5f9d8da1698..1a98a2c0e59 100644
--- a/prettier.config.js
+++ b/prettier.config.js
@@ -1,3 +1,19 @@
module.exports = {
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,
+ },
+ },
+ ],
};
diff --git a/tools/lint b/tools/lint
index 7d7753cd2a3..a537c0abd5c 100755
--- a/tools/lint
+++ b/tools/lint
@@ -93,9 +93,10 @@ def run() -> None:
linter_config.external_linter('isort', ['isort'], ['py'],
description="Sorts Python import statements",
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'],
- description="Formats YAML files",
+ description="Formats JavaScript and YAML",
# https://github.com/prettier/prettier/pull/8703
suppress_line=lambda line: line in ["Checking formatting...\n", "All matched files use Prettier code style!\n"])