Skip to content

Commit

Permalink
chore: upstream aspect-build/rules_lint#417 (#197)
Browse files Browse the repository at this point in the history
* chore: upstream aspect-build/rules_lint#417

* Update BUILD.bazel

* Update prettier.config.cjs

* Update prettier.config.cjs
  • Loading branch information
alexeagle authored Oct 24, 2024
1 parent 0322b66 commit 2553e42
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ features:
globs:
- "*/package.json"
- "*/pnpm-*.yaml"
- "*/eslint.config.mjs*"
- "*/*.config.cjs*"
- "*/*.config.mjs*"
- "*/.npmrc"
- "**/packages/**"
- "*/tools/pnpm"
Expand Down
7 changes: 7 additions & 0 deletions {{ .ProjectSnake }}/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ js_library(
":node_modules/typescript-eslint",
],
)

js_library(
name = "prettierrc",
srcs = ["prettier.config.cjs"],
deps = [],
visibility = ["//tools/format:__pkg__"],
)
{{- end }}
{{- end }}
{{- if .Computed.python }}
Expand Down
13 changes: 13 additions & 0 deletions {{ .ProjectSnake }}/prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @see https://prettier.io/docs/en/configuration.html
*/
const config = {
tabWidth: 2,
plugins: [
// Add plugins here using a require() statement.
// This is required to ensure the node module resolution algorithm starts walking
// up the filesystem from this file, rather than from the location where prettier interprets it.
],
};

module.exports = config;
12 changes: 12 additions & 0 deletions {{ .ProjectSnake }}/tools/format/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ package(default_visibility = ["//:__subpackages__"])
{{ if .Computed.javascript -}}
prettier.prettier_binary(
name = "prettier",
# Allow the binary to be run outside bazel
env = {"BAZEL_BINDIR": "."},
# Include this js_library and its dependencies in the runfiles (runtime dependencies)
data = ["//:prettierrc"],
fixed_args = [
# `require` statements in the config file will be resolved relative to its location
# Therefore to make it hermetic, prettier must be pointed at the copy of the config file
# in the runfiles folder rather than the one in the source folder.
"--config=\"$$JS_BINARY__RUNFILES\"/$(rlocationpath //:prettierrc)",
# default log level is "log" which spams on success
# https://prettier.io/docs/en/cli.html#--log-level
"--log-level=warn",
],
)

{{ end -}}
Expand Down

0 comments on commit 2553e42

Please sign in to comment.