From 15d35f4cad0c65d7a95072493e2b8fa7a069e2c2 Mon Sep 17 00:00:00 2001 From: "jeff.orrok" Date: Thu, 25 Mar 2021 09:13:24 -0600 Subject: [PATCH 1/3] allow for an optional semicolon where there is an optional comma in parseOptionValue --- src/parse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parse.js b/src/parse.js index 918d7c2eb..336644c54 100644 --- a/src/parse.js +++ b/src/parse.js @@ -586,7 +586,7 @@ function parse(source, root, options) { if (prevValue) value = [].concat(prevValue).concat(value); result[propName] = value; - skip(",", true); + skip(",", true) || skip(";", true); } return result; } From 776347e91a9c9d2cc3e2d6f8723182b8dce1bab5 Mon Sep 17 00:00:00 2001 From: "jeff.orrok" Date: Thu, 25 Mar 2021 09:41:00 -0600 Subject: [PATCH 2/3] set allowShortCircuit to true to prevent no-unused-expressions error --- config/eslint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/eslint.json b/config/eslint.json index 191a44180..2800db370 100644 --- a/config/eslint.json +++ b/config/eslint.json @@ -72,7 +72,7 @@ "no-self-compare": 1, "no-throw-literal": 1, "no-unmodified-loop-condition": 1, - "no-unused-expressions": 1, + "no-unused-expressions": ["error", { "allowShortCircuit": true }], "no-useless-call": 1, "no-useless-concat": 1, "no-useless-escape": 1, From 10b2b6e0f91fb965f974375f1c443dc75aa33a53 Mon Sep 17 00:00:00 2001 From: "jeff.orrok" Date: Thu, 25 Mar 2021 10:02:01 -0600 Subject: [PATCH 3/3] add test for semicolon --- tests/comp_options-textformat.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/comp_options-textformat.js b/tests/comp_options-textformat.js index b7788e48f..325aaa958 100644 --- a/tests/comp_options-textformat.js +++ b/tests/comp_options-textformat.js @@ -15,6 +15,7 @@ message Test {\ string value = 1 [(my_options) = { a: \"foo\" b: \"bar\" }];\ string value2 = 2 [(my_options) = { a: \"foo\" b { c: \"bar\" } }];\ string value3 = 3 [(my_options) = { a: \"foo\", b: \"bar\" }];\ + string value4 = 4 [(my_options) = { a: \"foo\"; b: \"bar\" }];\ }"; tape.test("options in textformat", function(test) { @@ -23,5 +24,6 @@ tape.test("options in textformat", function(test) { test.same(Test.fields.value.options, { "(my_options).a": "foo", "(my_options).b": "bar" }, "should parse correctly"); test.same(Test.fields.value2.options, { "(my_options).a": "foo", "(my_options).b.c": "bar" }, "should parse correctly when nested"); test.same(Test.fields.value3.options, { "(my_options).a": "foo", "(my_options).b": "bar" }, "should parse correctly when comma-separated"); + test.same(Test.fields.value4.options, { "(my_options).a": "foo", "(my_options).b": "bar" }, "should parse correctly when semicolon-separated"); test.end(); });