diff --git a/docs/development.md b/docs/development.md index 56cc39bdb..229bca863 100644 --- a/docs/development.md +++ b/docs/development.md @@ -66,8 +66,9 @@ in the relevant package: ``` bazel run //rslib:format bazel run //pylib:format -bazel run //pylib/rsbridge:format bazel run //qt:format +bazel run //ts:format +bazel run //pylib/rsbridge:format ``` If you're in one of those folders, you can use the short form: @@ -76,13 +77,6 @@ If you're in one of those folders, you can use the short form: bazel run format ``` -Currently the typescript code needs to be formatted differently: - -``` -cd ts -./node_modules/.bin/prettier --write . -``` - ## Building redistributable wheels ``` diff --git a/ts/.prettierignore b/ts/.prettierignore index 1facfe957..bacfa9aa7 100644 --- a/ts/.prettierignore +++ b/ts/.prettierignore @@ -1 +1,3 @@ src/backend/proto.d.ts +licenses.json +vendor diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel index 8b0e0c60e..91f8ac7c5 100644 --- a/ts/BUILD.bazel +++ b/ts/BUILD.bazel @@ -1,3 +1,7 @@ +load("//ts:prettier.bzl", "prettier") + +prettier() + # Exported files ################# diff --git a/ts/format.sh b/ts/format.sh new file mode 100755 index 000000000..11131be39 --- /dev/null +++ b/ts/format.sh @@ -0,0 +1,3 @@ +# this is a hack to invoke prettier directly from Bazel +ts=${BUILD_WORKSPACE_DIRECTORY}/ts +(cd $ts && ./node_modules/.bin/prettier --config .prettierrc --write . $ts/../qt/aqt/data/web/js) diff --git a/ts/prettier.bzl b/ts/prettier.bzl index e02678478..447c1a0b5 100644 --- a/ts/prettier.bzl +++ b/ts/prettier.bzl @@ -3,7 +3,7 @@ load( _prettier_test = "prettier_test", ) -def prettier_test(name = "format", srcs = [], **kwargs): +def prettier_test(name = "format_check", srcs = [], **kwargs): _prettier_test( name = name, args = [ @@ -17,3 +17,9 @@ def prettier_test(name = "format", srcs = [], **kwargs): ] + srcs, **kwargs ) + +def prettier(name = "format", **kwargs): + native.sh_binary( + name = name, + srcs = ["format.sh"], + )