@bufbuild/protoc-gen-es 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoc-gen-es",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Protocol Buffers code generator for ECMAScript",
6
6
  "keywords": [
@@ -30,11 +30,11 @@
30
30
  },
31
31
  "preferUnplugged": true,
32
32
  "dependencies": {
33
- "@bufbuild/protobuf": "^2.2.0",
34
- "@bufbuild/protoplugin": "2.2.0"
33
+ "@bufbuild/protobuf": "^2.2.2",
34
+ "@bufbuild/protoplugin": "2.2.2"
35
35
  },
36
36
  "peerDependencies": {
37
- "@bufbuild/protobuf": "2.2.0"
37
+ "@bufbuild/protobuf": "2.2.2"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@bufbuild/protobuf": {
@@ -447,19 +447,16 @@ function generateMessageJsonShape(f, message, target) {
447
447
  else {
448
448
  f.print(exp, " = {");
449
449
  for (const field of message.fields) {
450
- switch (field.kind) {
451
- default:
452
- f.print(f.jsDoc(field, " "));
453
- // eslint-disable-next-line no-case-declarations
454
- let jsonName = field.jsonName;
455
- if (jsonName === ""
456
- || /^[0-9]/.test(jsonName)
457
- || jsonName.indexOf("@") > -1) {
458
- jsonName = f.string(jsonName);
459
- }
460
- f.print(" ", jsonName, "?: ", (0, util_1.fieldJsonType)(field), ";");
461
- break;
450
+ f.print(f.jsDoc(field, " "));
451
+ let jsonName = field.jsonName;
452
+ const startWithNumber = /^[0-9]/;
453
+ const containsSpecialChar = /[^a-zA-Z0-9_$]/;
454
+ if (jsonName === ""
455
+ || startWithNumber.test(jsonName)
456
+ || containsSpecialChar.test(jsonName)) {
457
+ jsonName = f.string(jsonName);
462
458
  }
459
+ f.print(" ", jsonName, "?: ", (0, util_1.fieldJsonType)(field), ";");
463
460
  if (message.fields.indexOf(field) < message.fields.length - 1) {
464
461
  f.print();
465
462
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoc-gen-es",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Protocol Buffers code generator for ECMAScript",
6
6
  "keywords": [
@@ -30,11 +30,11 @@
30
30
  },
31
31
  "preferUnplugged": true,
32
32
  "dependencies": {
33
- "@bufbuild/protobuf": "^2.2.0",
34
- "@bufbuild/protoplugin": "2.2.0"
33
+ "@bufbuild/protobuf": "^2.2.2",
34
+ "@bufbuild/protoplugin": "2.2.2"
35
35
  },
36
36
  "peerDependencies": {
37
- "@bufbuild/protobuf": "2.2.0"
37
+ "@bufbuild/protobuf": "2.2.2"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@bufbuild/protobuf": {