-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add Prettier for linting frontend code #2493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
CLAs are fine because I wrote or generated all of these commits. The author is intentionally tensorboard-gardener@google.com. |
6d79959 to
2d291e4
Compare
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
|
Travis failures are unrelated: the No idea why Travis is trying to install those old versions; I’ll clear (By this point in the build, Prettier has already passed.) |
2d291e4 to
ac2df34
Compare
|
Tests pass after cherry-picking #2494. |
stephanwlee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not look at all files so instead sampled a few. Changes look mostly perfect except a few.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it impossible to get trailing comma here too?
Rationale is the same as other trailing commas: I want git-diff to be minimal when adding/removing arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish, but our version of TypeScript doesn’t support that:
ERROR: ${PWD}/tensorboard/plugins/histogram/tf_histogram_dashboard/BUILD:7:1: Compiling 34 TypeScript files //tensorboard/plugins/histogram/tf_histogram_dashboard:tf_histogram_dashboard failed (Exit 1) execrooter failed: error executing command bazel-out/host/bin/tensorboard/scripts/execrooter bazel-out/k8-fastbuild/bin/tensorboard/plugins/histogram/tf_histogram_dashboard/tf_histogram_dashboard-tsc-execroot.json ... (remaining 16 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
../../../../../../../../../../../../../../tmp/tmp_VP6Gz/tf-histogram-dashboard/histogramCore.ts(23,11): error TS1009: Trailing comma not allowed.
../../../../../../../../../../../../../../tmp/tmp_VP6Gz/tf-histogram-dashboard/histogramCore.ts(29,26): error TS1009: Trailing comma not allowed.
See:
- TypeScript "trailing comma not allowed" error in type parameters prettier/prettier#1820
- Allow trailing commas in type parameter/argument lists microsoft/TypeScript#16152
If at some point we upgrade our toolchains, we can flip this flag and
re-Prettify; the diff is comparatively small (1800 lines).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, didn't realize our version of tsc didn't support this. Okay, LGTM.
tensorboard/components/tf_dashboard_common/dashboard-style.html
Outdated
Show resolved
Hide resolved
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
stephanwlee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💅!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(remove the [testing...] bit from the PR title if you are ready for submission :) )
Summary:
Justifications:
- We use `singleQuote: true` is for consistency with Google’s
JavaScript style guide.
- We don’t use `trailingComma: "all"` because that’s incompatible with
some compilers in our toolchain; `trailingComma: "es5"` gets us most
of the way there.
- Other options are due to prevalence/preference.
Test Plan:
Running Prettier on the `.prettierrc.json` file itself succeeds, so the
file is syntactically and semantically valid.
wchargin-branch: prettierrc
Summary: Pinned to an exact version because Prettier’s semver does not extend to stylistic changes (by design). Test Plan: Running `yarn && yarn prettier --version` now prints `1.18.2`. wchargin-branch: deps-prettier
Test Plan: Running `yarn lint` currently fails with a long list of bad files and a nice, human-readable message. Running `yarn fix-lint` effects a large diff, after which `yarn lint` passes. wchargin-branch: package-prettier
ac2df34 to
b4dd900
Compare
This will be rebased, but sure. The rebase will also likely get clabot |
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
Summary:
The `--ignore-engines` appears to be needed on Travis (but not locally);
without it, Angular cannot be installed:
```
error @angular-devkit/architect@0.800.6: The engine "node" is incompatible with this module. Expected version ">= 10.9.0".
error Found incompatible module
```
The preceding large sequence of change commits was generated with:
```
#!/bin/sh
set -eu
yarn fix-lint
export GIT_AUTHOR_NAME="TensorBoard Gardener"
export GIT_AUTHOR_EMAIL="tensorboard-gardener@google.com"
# Commit each directory in order of longest-named directory to
# shortest-named, to force a topological ordering. Collapse test and
# demo directories, and group by parent directory to reduce from ~110
# commits to about ~20.
git diff --numstat \
| awk '{ print $3 }' \
| rev \
| cut -d / -f 2- \
| rev \
| sed -e 's#/\(test\|demo\)$##' \
| xargs -n 1 dirname \
| sort -u \
| awk '{ print length($0), $0 }' \
| sort -nrs \
| awk '{ print $2 }' \
| while read -r dir
do
git add "${dir}"
if git commit -m "prettier: reformat directory ${dir}" >/dev/null 2>&1; then
printf 'reformat %s: ' "${dir}"
git show --oneline --shortstat | tail -n 1
else
printf 'skip %s (covered by subtrees)\n' "${dir}"
fi
done
```
Test Plan:
Running `yarn lint` currently passes, as all files have been fixed up.
It takes about 11 seconds on my machine.
wchargin-branch: ci-prettier
b4dd900 to
3c715b6
Compare
Yes, per discussion.
Sure; we can group by parent directory to reduce to 21 commits, the Breakdown of
|
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
|
CLAs are fine because I wrote or generated all of these commits. The author is intentionally tensorboard-gardener@google.com. |
Fixes #2466. See commit messages for discussion: