Skip to content

Commit 0a3b281

Browse files
gino-mrfontanarosa
andauthored
Support nx lint fix --all for proto/ dir (#2400)
Co-authored-by: Roberto Fontanarosa <robertofontanarosa@gmail.com>
1 parent 112fabe commit 0a3b281

File tree

5 files changed

+48
-8
lines changed

5 files changed

+48
-8
lines changed

proto/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"files": ["dist"],
1111
"scripts": {
1212
"clean": "rm -rf dist",
13-
"lint": "buf lint",
13+
"lint": "node scripts/lint.js",
1414
"format": "buf format --write",
1515
"build": "npm run generate:pbjs && npm run generate:pbjson && npm run generate:pbts",
1616
"postbuild": "cp src/index.* dist/",

proto/scripts/lint.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright 2026 The Ground Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
const { execSync } = require('child_process');
18+
19+
const args = process.argv.slice(2);
20+
const fixIndex = args.indexOf('--fix');
21+
const shouldFix = fixIndex !== -1;
22+
23+
const extraArgs = [...args];
24+
if (shouldFix) {
25+
extraArgs.splice(fixIndex, 1);
26+
}
27+
28+
const argsStr = extraArgs.join(' ');
29+
30+
try {
31+
if (shouldFix) {
32+
console.log('Running buf format...');
33+
// buf format -w writes changes to files
34+
execSync(`npx buf format -w ${argsStr}`, { stdio: 'inherit' });
35+
}
36+
37+
console.log('Running buf lint...');
38+
execSync(`npx buf lint ${argsStr}`, { stdio: 'inherit' });
39+
} catch (error) {
40+
process.exit(1);
41+
}

proto/src/ground/v1beta1/geometry.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ message Geometry {
3232

3333
// A polygon geometry.
3434
Polygon polygon = 2;
35-
35+
3636
// A multi-polygon geometry.
3737
MultiPolygon multi_polygon = 3;
3838
}

proto/src/ground/v1beta1/job.proto

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ message Task {
151151
FLOAT = 1;
152152
}
153153
// Required. The type of number question.
154-
Type type = 1;
155-
}
154+
Type type = 1;
155+
}
156156

157157
// A question whose response is entered manually as a data and/or time.
158158
message DateTimeQuestion {
@@ -214,7 +214,7 @@ message Task {
214214
DROP_PIN = 1;
215215
DRAW_AREA = 2;
216216
}
217-
// Required. One or more methods which the user may use to complete the
217+
// Required. One or more methods which the user may use to complete the
218218
// geometry task. If multiple methods are specified, data collectors are
219219
// prompted which method should be used.
220220
repeated Method allowed_methods = 1;
@@ -231,7 +231,6 @@ message Task {
231231
// Optional. The minimum accuracy, in meters, required when "location lock"
232232
// is enabled. When unset (`0`), a default of 15m is used.
233233
float min_accuracy_meters = 3;
234-
235234
}
236235

237236
// A task in which the user must capture their current device location.
@@ -252,7 +251,7 @@ message Task {
252251
// Required. The maximum compass heading, in degrees, at which the photo may
253252
// be captured. Use 360 with min. 0 to disable this constraint.
254253
uint32 max_heading_degrees = 2;
255-
}
254+
}
256255

257256
// Defines a single condition used to determine whether a task should be
258257
// shown.

proto/src/ground/v1beta1/submission.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ syntax = "proto3";
1818

1919
package ground.v1beta1;
2020

21+
import "google/protobuf/timestamp.proto";
2122
import "ground/v1beta1/audit_info.proto";
2223
import "ground/v1beta1/geometry.proto";
23-
import "google/protobuf/timestamp.proto";
2424

2525
option java_multiple_files = true;
2626
option java_package = "org.groundplatform.android.proto";

0 commit comments

Comments
 (0)