diff options
author | Skyler Grey <skyler.grey@collabora.com> | 2023-12-18 18:27:02 +0000 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2024-03-09 15:53:21 +0100 |
commit | a40be5499e29a95815bf4fe9c42ebc32c7c8b87b (patch) | |
tree | e9de2bfdd966d511d0b2b5cece63be7310283306 /Makefile.am | |
parent | cypress: fix annotation autosave tests (diff) | |
download | online-a40be5499e29a95815bf4fe9c42ebc32c7c8b87b.tar.gz online-a40be5499e29a95815bf4fe9c42ebc32c7c8b87b.zip |
Add prettier
Prettier is a code formatter for javascript/typescript. It's relatively
common to see complaints about style in pull requests or inconsistent
style getting in to Collabora Online. Also, without a formatter it's
harder for editors to automatically format code in sensible and
consistent ways
Prettier doesn't have many options, but those which it does have I have
set to the closest values to current behavior (e.g. single quotes) in
order to minimize unnecessary changes
This commit doesn't format all existing files. Doing so would cause
blames, cherry-picks and diffs to become much less useful. Instead, we
use browser/.beforeprettier to list all files that would need to be
changed, and this file is ignored. You are encouraged but not required
to set your editor's equivalent of 'editor.formatOnSaveMode' to only
format changed lines
This commit also does format of docstatefunctions.js, previously it did
not in to check that an incorrectly-formatted file could fail CI. Now it
does to make sure that formatting fixes the issue. This file was chosen
because it is very new and very small.
Change-Id: Ie6067f34aa658f887e149a08aebd0180b2354005
Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
Diffstat (limited to 'Makefile.am')
-rw-r--r-- | Makefile.am | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index 92f039cf4e..e0842a7a12 100644 --- a/Makefile.am +++ b/Makefile.am @@ -508,7 +508,7 @@ COMMON_PARAMS = \ --o:ssl.ca_file_path="$(abs_top_srcdir)/etc/ca-chain.cert.pem" \ --o:admin_console.username=admin --o:admin_console.password=admin -run: setup-wsd +run: prettier-write setup-wsd ./coolwsd $(COMMON_PARAMS) \ --o:security.capabilities="$(CAPABILITIES)" \ --o:logging.file[@enable]=${OUTPUT_TO_FILE} --o:logging.level=trace \ @@ -649,6 +649,23 @@ eslint: browser/node_modules --no-eslintrc \ --config browser/.eslintrc +prettier: browser/node_modules + browser/node_modules/.bin/prettier \ + --config browser/.prettierrc \ + --ignore-path browser/.prettierignore \ + --ignore-path browser/.beforeprettier \ + --check \ + browser/src browser/js browser/admin/src \ + || echo "To run prettier, you can use 'make prettier-write' or run COOLWSD with 'make run'" + +prettier-write: browser/node_modules + browser/node_modules/.bin/prettier \ + --config browser/.prettierrc \ + --ignore-path browser/.prettierignore \ + --ignore-path browser/.beforeprettier \ + --write \ + browser/src browser/js browser/admin/src + install-exec-hook: cd $(DESTDIR)$(bindir) && \ $(LN_S) coolconfig loolconfig && \ @@ -692,7 +709,7 @@ check-for-system-nss: check-recursive: eslint -check: check-for-system-nss eslint check-recursive +check: check-for-system-nss prettier eslint check-recursive $(GEN_COVERAGE_COMMAND) coverage-report: |