From ebc11db0fdd37b740ff8ca8413e04055683b9317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Pr=C3=B6schel?= Date: Tue, 9 Mar 2021 17:06:56 +0100 Subject: [PATCH] [#1183] Add the prettier and eslint config to the repository for better developer experience --- .prettierignore | 2 +- .prettierrc.json | 26 ++++++++++++++++++++++++++ BUILD | 2 ++ WORKSPACE | 4 ++-- docs/BUILD.bazel | 1 + frontend/assets/BUILD | 3 +++ frontend/chat-plugin/BUILD | 3 +++ frontend/ui/BUILD | 5 +++-- frontend/ui/public/BUILD | 3 +++ lib/typescript/dates/BUILD | 3 +++ lib/typescript/httpclient/BUILD | 3 +++ lib/typescript/render/BUILD | 3 +++ lib/typescript/types/BUILD | 3 +++ lib/typescript/websocketclient/BUILD | 3 +++ tools/lint/BUILD | 1 + tools/lint/web.bzl | 8 ++++++++ 16 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 .prettierrc.json create mode 100644 tools/lint/BUILD create mode 100644 tools/lint/web.bzl diff --git a/.prettierignore b/.prettierignore index 275dce31e8..7c1045e399 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,3 @@ -docs/docs/cli/reference.md +**/*/cli/reference.md build/ bazel-* diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000000..3fe6909f5e --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,26 @@ +{ + "bracketSpacing": false, + "singleQuote": true, + "jsxBracketSameLine": true, + "semi": true, + "trailingComma": "es5", + "printWidth": 120, + "arrowParens": "avoid", + "endOfLine": "auto", + "overrides": [ + { + "files": "*.{ts,tsx}", + "options": { + "parser": "typescript" + } + }, + { + "files": "*.md", + "options": { + "singleQuote": false, + "quoteProps": "preserve", + "trailingComma": "none" + } + } + ] +} diff --git a/BUILD b/BUILD index c4b6f3cdba..2583c31dae 100644 --- a/BUILD +++ b/BUILD @@ -15,6 +15,7 @@ alias( fix_prettier( name = "fix_prettier", + config = "//:.prettierrc.json", ignore = "//:.prettierignore", ) @@ -174,6 +175,7 @@ java_library( exports_files( [ "package.json", + ".eslintrc", ".prettierrc.json", ".prettierignore", "yarn.lock", diff --git a/WORKSPACE b/WORKSPACE index 1017cc10fc..3533046acb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -9,9 +9,9 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") # Airy Bazel tools git_repository( name = "com_github_airyhq_bazel_tools", - commit = "9cf55cc0a42d68f0198883b04493ce7c7b3113ed", + commit = "18642f4f2483933d738138cb4a850d83c62f438d", remote = "https://github.com/airyhq/bazel-tools.git", - shallow_since = "1614958086 +0100", + shallow_since = "1615304389 +0100", ) load("@com_github_airyhq_bazel_tools//:repositories.bzl", "airy_bazel_tools_dependencies", "airy_jvm_deps") diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index d4e4f04548..fe60e65263 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -3,6 +3,7 @@ load("@com_github_airyhq_bazel_tools//lint:prettier.bzl", "prettier") prettier( name = "prettier", + config = "//:.prettierrc.json", ignore = "//:.prettierignore", ) diff --git a/frontend/assets/BUILD b/frontend/assets/BUILD index f7c7094bb7..9abae49b92 100644 --- a/frontend/assets/BUILD +++ b/frontend/assets/BUILD @@ -1,3 +1,4 @@ +load("//tools/lint:web.bzl", "web_lint") load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") load("@com_github_airyhq_bazel_tools//web:typescript.bzl", "ts_web_library") @@ -8,3 +9,5 @@ ts_web_library( ) check_pkg(name = "buildifier") + +web_lint() diff --git a/frontend/chat-plugin/BUILD b/frontend/chat-plugin/BUILD index 2a6379637b..2c3ac609fc 100644 --- a/frontend/chat-plugin/BUILD +++ b/frontend/chat-plugin/BUILD @@ -1,3 +1,4 @@ +load("//tools/lint:web.bzl", "web_lint") load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") load("@npm//@bazel/typescript:index.bzl", "ts_config") load("@com_github_airyhq_bazel_tools//web:typescript.bzl", "ts_web_library") @@ -101,3 +102,5 @@ container_release( ) check_pkg(name = "buildifier") + +web_lint() diff --git a/frontend/ui/BUILD b/frontend/ui/BUILD index 95738d3e7d..3d42baa725 100644 --- a/frontend/ui/BUILD +++ b/frontend/ui/BUILD @@ -1,3 +1,4 @@ +load("//tools/lint:web.bzl", "web_lint") load("@com_github_airyhq_bazel_tools//web:typescript.bzl", "ts_web_library") load("@com_github_airyhq_bazel_tools//web:web_app.bzl", "web_app") load("@rules_pkg//:pkg.bzl", "pkg_tar") @@ -5,8 +6,6 @@ load("//tools/build:container_release.bzl", "container_release") load("@io_bazel_rules_docker//container:container.bzl", "container_image") load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") -check_pkg() - check_pkg(name = "buildifier") module_deps = [ @@ -76,3 +75,5 @@ container_release( registry = "ghcr.io/airyhq/frontend", repository = "ui", ) + +web_lint() diff --git a/frontend/ui/public/BUILD b/frontend/ui/public/BUILD index 9b864009bc..d0c2f25172 100644 --- a/frontend/ui/public/BUILD +++ b/frontend/ui/public/BUILD @@ -1,3 +1,4 @@ +load("//tools/lint:web.bzl", "web_lint") load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") package(default_visibility = ["//visibility:public"]) @@ -10,3 +11,5 @@ filegroup( ) check_pkg(name = "buildifier") + +web_lint() diff --git a/lib/typescript/dates/BUILD b/lib/typescript/dates/BUILD index 5bfcc3d1ee..e5b80937ff 100644 --- a/lib/typescript/dates/BUILD +++ b/lib/typescript/dates/BUILD @@ -1,3 +1,4 @@ +load("//tools/lint:web.bzl", "web_lint") load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") load("@com_github_airyhq_bazel_tools//web:typescript.bzl", "ts_web_library") @@ -11,3 +12,5 @@ ts_web_library( ) check_pkg(name = "buildifier") + +web_lint() diff --git a/lib/typescript/httpclient/BUILD b/lib/typescript/httpclient/BUILD index e9a422bc16..4d08cf05e5 100644 --- a/lib/typescript/httpclient/BUILD +++ b/lib/typescript/httpclient/BUILD @@ -1,3 +1,4 @@ +load("//tools/lint:web.bzl", "web_lint") load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") load("@com_github_airyhq_bazel_tools//web:typescript.bzl", "ts_web_library") @@ -13,3 +14,5 @@ ts_web_library( ) check_pkg(name = "buildifier") + +web_lint() diff --git a/lib/typescript/render/BUILD b/lib/typescript/render/BUILD index 12416077ed..8fbbaf4abe 100644 --- a/lib/typescript/render/BUILD +++ b/lib/typescript/render/BUILD @@ -1,3 +1,4 @@ +load("//tools/lint:web.bzl", "web_lint") load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") load("@com_github_airyhq_bazel_tools//web:typescript.bzl", "ts_web_library") @@ -20,3 +21,5 @@ ts_web_library( ) check_pkg(name = "buildifier") + +web_lint() diff --git a/lib/typescript/types/BUILD b/lib/typescript/types/BUILD index 21e87404e4..14340f7c18 100644 --- a/lib/typescript/types/BUILD +++ b/lib/typescript/types/BUILD @@ -1,3 +1,4 @@ +load("//tools/lint:web.bzl", "web_lint") load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") load("@com_github_airyhq_bazel_tools//web:typescript.bzl", "ts_web_library") @@ -15,3 +16,5 @@ ts_web_library( ) check_pkg(name = "buildifier") + +web_lint() diff --git a/lib/typescript/websocketclient/BUILD b/lib/typescript/websocketclient/BUILD index f192ce151d..0a81e5cbbb 100644 --- a/lib/typescript/websocketclient/BUILD +++ b/lib/typescript/websocketclient/BUILD @@ -1,3 +1,4 @@ +load("//tools/lint:web.bzl", "web_lint") load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") load("@com_github_airyhq_bazel_tools//web:typescript.bzl", "ts_web_library") @@ -15,3 +16,5 @@ ts_web_library( ) check_pkg(name = "buildifier") + +web_lint() diff --git a/tools/lint/BUILD b/tools/lint/BUILD new file mode 100644 index 0000000000..4540c600b4 --- /dev/null +++ b/tools/lint/BUILD @@ -0,0 +1 @@ +exports_files(["prettier.bzl"]) diff --git a/tools/lint/web.bzl b/tools/lint/web.bzl new file mode 100644 index 0000000000..2d9124fb01 --- /dev/null +++ b/tools/lint/web.bzl @@ -0,0 +1,8 @@ +load("@com_github_airyhq_bazel_tools//lint:prettier.bzl", "prettier") +load("@com_github_airyhq_bazel_tools//lint:eslint.bzl", "eslint") + +def web_lint(): + if "prettier" not in native.existing_rules().keys(): + prettier(name = "prettier", config = "//:.prettierrc.json", ignore = "//:.prettierignore") + if "eslint" not in native.existing_rules().keys(): + eslint(name = "eslint", config = "//:.eslintrc", ignore = "//:.prettierignore")