Skip to content
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

Add comment ignores to example #314

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions docs/buf.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion example/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
version: v2
lint:
use:
- IMPORT_USED
- DEFAULT
except:
- RPC_REQUEST_STANDARD_NAME
- PACKAGE_DEFINED
3 changes: 3 additions & 0 deletions example/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ args+=(
# See https://github.com/aspect-build/rules_ts/pull/574#issuecomment-2073632879
"--norun_validations"
"--build_event_json_file=$buildevents"
# Required for the buf allow_comment_ignores option to work properly
# See https://github.com/bufbuild/rules_buf/issues/64#issuecomment-2125324929
"--experimental_proto_descriptor_sets_include_source_info"
"--output_groups=rules_lint_human"
"--remote_download_regex='.*AspectRulesLint.*'"
)
Expand Down
13 changes: 13 additions & 0 deletions example/src/file.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
syntax = "proto3";

import "src/unused.proto";

message HttpBody {
string name = 1;
}

message Empty {}

service HttpService {
// Receives an inbound message an http client.
// buf:lint:ignore RPC_RESPONSE_STANDARD_NAME
// buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE
rpc ReceiveMessage(HttpBody) returns (Empty) {}
}
2 changes: 1 addition & 1 deletion example/test/lint_test.bats
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ EOF
refute_output --partial '@typescript-eslint/no-unsafe-member-access'

# Buf
assert_output --partial 'src/file.proto:1:1:Import "src/unused.proto" is unused.'
assert_output --partial 'src/file.proto:3:1:Import "src/unused.proto" is unused.'

# Vale
echo <<"EOF" | assert_output --partial
Expand Down
2 changes: 2 additions & 0 deletions lint/buf.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ buf = buf_lint_aspect(
config = "@@//path/to:buf.yaml",
)
```

**Important:** while using buf's [`allow_comment_ignores` functionality](https://buf.build/docs/configuration/v1/buf-yaml#allow_comment_ignores), the bazel flag `--experimental_proto_descriptor_sets_include_source_info` is required.
"""

load("@rules_proto//proto:defs.bzl", "ProtoInfo")
Expand Down
Loading