From ce48b0bf52c1e438ca46d598cdf47fbc4446f441 Mon Sep 17 00:00:00 2001 From: Spencer Connaughton Date: Fri, 3 May 2024 15:54:53 -0400 Subject: [PATCH 1/9] Add comment ignores to example. --- docs/buf.md | 2 ++ example/MODULE.bazel | 1 + example/buf.yaml | 5 +++++ example/lint.sh | 3 +++ example/src/file.proto | 13 +++++++++++++ 5 files changed, 24 insertions(+) diff --git a/docs/buf.md b/docs/buf.md index 16031f1b..7b4fecdb 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. + diff --git a/example/MODULE.bazel b/example/MODULE.bazel index 1a6c9461..69c73c1d 100644 --- a/example/MODULE.bazel +++ b/example/MODULE.bazel @@ -99,6 +99,7 @@ use_repo( ) buf = use_extension("@rules_buf//buf:extensions.bzl", "buf") +buf.toolchains(version = "v1.31.0") use_repo(buf, "rules_buf_toolchains") rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") diff --git a/example/buf.yaml b/example/buf.yaml index 29fd418d..dcc895f2 100644 --- a/example/buf.yaml +++ b/example/buf.yaml @@ -1,4 +1,9 @@ version: v1 + lint: use: + - DEFAULT + allow_comment_ignores: true + except: - IMPORT_USED + - RPC_REQUEST_STANDARD_NAME diff --git a/example/lint.sh b/example/lint.sh index f4e6c199..be9fdda8 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_report" "--remote_download_regex='.*AspectRulesLint.*'" ) diff --git a/example/src/file.proto b/example/src/file.proto index c185cacb..ce51d74d 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) {} +} From b4851500051196f17cc1e81dd414a2f030f6cc8a Mon Sep 17 00:00:00 2001 From: Spencer Connaughton Date: Mon, 8 Jul 2024 14:05:31 -0400 Subject: [PATCH 2/9] Fix docs. --- docs/buf.md | 2 +- lint/buf.bzl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/buf.md b/docs/buf.md index 7b4fecdb..8a795bbb 100644 --- a/docs/buf.md +++ b/docs/buf.md @@ -12,7 +12,7 @@ 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. +**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. diff --git a/lint/buf.bzl b/lint/buf.bzl index 2d3d8f57..2446bb08 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") From 2c5a0b820111a1595c486aa77eda7e0deadd9014 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 10 Jul 2024 15:44:08 -0700 Subject: [PATCH 3/9] chore: fix //tools/format:format_test_Protocol_Buffer_with_buf Also fix integration test golden line --- example/src/file.proto | 2 +- example/test/lint_test.bats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/src/file.proto b/example/src/file.proto index ce51d74d..a6ec999f 100644 --- a/example/src/file.proto +++ b/example/src/file.proto @@ -12,5 +12,5 @@ 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) {} + rpc ReceiveMessage(HttpBody) returns (Empty) {} } diff --git a/example/test/lint_test.bats b/example/test/lint_test.bats index b09e513a..b7f6cb78 100644 --- a/example/test/lint_test.bats +++ b/example/test/lint_test.bats @@ -29,7 +29,7 @@ EOF assert_output --partial 'src/file.ts: line 2, col 7, Error - Type string trivially inferred from a string literal, remove type annotation. (@typescript-eslint/no-inferrable-types)' # 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 assert_output --partial "src/README.md:3:47:Google.We:Try to avoid using first-person plural like 'We'." From 242aa09a5e04364f92d2df7eb48ee5794a0c1385 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Thu, 11 Jul 2024 07:56:03 -0700 Subject: [PATCH 4/9] Update lint_test.bats --- example/test/lint_test.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/test/lint_test.bats b/example/test/lint_test.bats index b7f6cb78..4dc94c0d 100644 --- a/example/test/lint_test.bats +++ b/example/test/lint_test.bats @@ -29,7 +29,7 @@ EOF assert_output --partial 'src/file.ts: line 2, col 7, Error - Type string trivially inferred from a string literal, remove type annotation. (@typescript-eslint/no-inferrable-types)' # Buf - assert_output --partial 'src/file.proto:3:1:Import "src/unused.proto" is unused.' + assert_output --partial 'src/file.proto:3:1: warning: Import src/unused.proto is unused.' # Vale assert_output --partial "src/README.md:3:47:Google.We:Try to avoid using first-person plural like 'We'." From 2af9fe2691b9bb941d26a84805a074c4f64e66bb Mon Sep 17 00:00:00 2001 From: Spencer Connaughton Date: Thu, 29 Aug 2024 16:08:09 -0400 Subject: [PATCH 5/9] Update lint.sh --- example/lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/lint.sh b/example/lint.sh index a34da573..5bc21448 100755 --- a/example/lint.sh +++ b/example/lint.sh @@ -48,7 +48,7 @@ args+=( "--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" + "--experimental_proto_descriptor_sets_include_source_info" "--output_groups=rules_lint_human" "--remote_download_regex='.*AspectRulesLint.*'" ) From b05e24314a4bebb41729d683255e319f5fd3971f Mon Sep 17 00:00:00 2001 From: Spencer Connaughton Date: Thu, 29 Aug 2024 16:22:57 -0400 Subject: [PATCH 6/9] Fix integration test. --- example/test/lint_test.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 example/test/lint_test.bats diff --git a/example/test/lint_test.bats b/example/test/lint_test.bats old mode 100644 new mode 100755 index b09e513a..4dc94c0d --- a/example/test/lint_test.bats +++ b/example/test/lint_test.bats @@ -29,7 +29,7 @@ EOF assert_output --partial 'src/file.ts: line 2, col 7, Error - Type string trivially inferred from a string literal, remove type annotation. (@typescript-eslint/no-inferrable-types)' # Buf - assert_output --partial 'src/file.proto:1:1:Import "src/unused.proto" is unused.' + assert_output --partial 'src/file.proto:3:1: warning: Import src/unused.proto is unused.' # Vale assert_output --partial "src/README.md:3:47:Google.We:Try to avoid using first-person plural like 'We'." From 75ec2bdc3138085ceba60c3803bac33bbb915821 Mon Sep 17 00:00:00 2001 From: Spencer Connaughton Date: Sat, 31 Aug 2024 09:07:51 -0400 Subject: [PATCH 7/9] Remove allow_comment_ignores. --- example/buf.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/example/buf.yaml b/example/buf.yaml index b2aa7b7e..01a62389 100644 --- a/example/buf.yaml +++ b/example/buf.yaml @@ -2,7 +2,6 @@ version: v2 lint: use: - DEFAULT - allow_comment_ignores: true except: - IMPORT_USED - RPC_REQUEST_STANDARD_NAME From 169ae1f56b52ed3ee3eeae3adeda6439851ddc66 Mon Sep 17 00:00:00 2001 From: Spencer Connaughton Date: Wed, 11 Sep 2024 20:04:15 -0400 Subject: [PATCH 8/9] Update docs. --- docs/buf.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/buf.md b/docs/buf.md index 58f5d5fd..c9ac2252 100644 --- a/docs/buf.md +++ b/docs/buf.md @@ -14,7 +14,6 @@ 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 From d1bdb7e112c6d0f7af5ae41cfbcba780321e8941 Mon Sep 17 00:00:00 2001 From: Spencer Connaughton Date: Wed, 11 Sep 2024 20:24:31 -0400 Subject: [PATCH 9/9] Fix integration tests. --- example/buf.yaml | 2 +- example/test/lint_test.bats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/buf.yaml b/example/buf.yaml index 01a62389..6797fb24 100644 --- a/example/buf.yaml +++ b/example/buf.yaml @@ -3,5 +3,5 @@ lint: use: - DEFAULT except: - - IMPORT_USED - RPC_REQUEST_STANDARD_NAME + - PACKAGE_DEFINED diff --git a/example/test/lint_test.bats b/example/test/lint_test.bats index 607f7bbf..f879d82d 100755 --- 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:3:1: warning: 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