diff --git a/docs/buf.md b/docs/buf.md index 539a210d..c9ac2252 100644 --- a/docs/buf.md +++ b/docs/buf.md @@ -12,6 +12,8 @@ buf = buf_lint_aspect( ) ``` +**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. + ## buf_lint_action diff --git a/example/buf.yaml b/example/buf.yaml index d17e77d2..6797fb24 100644 --- a/example/buf.yaml +++ b/example/buf.yaml @@ -1,4 +1,7 @@ version: v2 lint: use: - - IMPORT_USED + - DEFAULT + except: + - RPC_REQUEST_STANDARD_NAME + - PACKAGE_DEFINED diff --git a/example/lint.sh b/example/lint.sh index 036d47f4..5bc21448 100755 --- a/example/lint.sh +++ b/example/lint.sh @@ -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.*'" ) diff --git a/example/src/file.proto b/example/src/file.proto index c185cacb..a6ec999f 100644 --- a/example/src/file.proto +++ b/example/src/file.proto @@ -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) {} +} diff --git a/example/test/lint_test.bats b/example/test/lint_test.bats old mode 100644 new mode 100755 index f10fc0e2..f879d82d --- a/example/test/lint_test.bats +++ b/example/test/lint_test.bats @@ -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 diff --git a/lint/buf.bzl b/lint/buf.bzl index ae1deb38..faed644b 100644 --- a/lint/buf.bzl +++ b/lint/buf.bzl @@ -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")