Skip to content

Commit

Permalink
Make wording of syntax error msgs more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
molsonkiko committed Jul 18, 2024
1 parent 9670003 commit 90d0f56
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 115 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed

1. Rename `Choose schemas to automatically validate filename patterns` to [`Validate files with JSON schema if name matches pattern`](/docs/README.md#automatic-validation-of-json-against-json-schema), in the hopes that the new name will be less confusing.
2. Changed the wording of many JSON syntax error messages to be more consistent, per [conky77's suggestion here](https://github.com/molsonkiko/JsonToolsNppPlugin/issues/70#issuecomment-2234114308).

### Fixed

Expand Down
32 changes: 16 additions & 16 deletions JsonToolsNppPlugin/JSONTools/JsonParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,35 +136,35 @@ public string TranslateMessageIfDesired(bool translated)
// OK messages
case JsonLintType.OK_CONTROL_CHAR: return Translator.TranslateLintMessage(translated, lintType, "Control characters (ASCII code less than 0x20) are disallowed inside strings under the strict JSON specification");
// NAN_INF messages
case JsonLintType.NAN_INF_Infinity: return Translator.TranslateLintMessage(translated, lintType, "Infinity is not part of the original JSON specification");
case JsonLintType.NAN_INF_NaN: return Translator.TranslateLintMessage(translated, lintType, "NaN is not part of the original JSON specification");
case JsonLintType.NAN_INF_Infinity: return Translator.TranslateLintMessage(translated, lintType, "Infinity is not allowed in the original JSON specification");
case JsonLintType.NAN_INF_NaN: return Translator.TranslateLintMessage(translated, lintType, "NaN is not allowed in the original JSON specification");
// JSONC messages
case JsonLintType.JSONC_JAVASCRIPT_COMMENT: return Translator.TranslateLintMessage(translated, lintType, "JavaScript comments are not part of the original JSON specification");
case JsonLintType.JSONC_JAVASCRIPT_COMMENT: return Translator.TranslateLintMessage(translated, lintType, "JavaScript comments are not allowed in the original JSON specification");
// JSON5 messages
case JsonLintType.JSON5_WHITESPACE_CHAR: return Translator.TranslateLintMessage(translated, lintType, "Whitespace characters other than ' ', '\\t', '\\r', and '\\n' are only allowed in JSON5");
case JsonLintType.JSON5_SINGLEQUOTED_STRING: return Translator.TranslateLintMessage(translated, lintType, "Singlequoted strings are only allowed in JSON5");
case JsonLintType.JSON5_ESCAPED_NEWLINE: return Translator.TranslateLintMessage(translated, lintType, "Escaped newline characters are only allowed in JSON5");
case JsonLintType.JSON5_X_ESCAPE: return Translator.TranslateLintMessage(translated, lintType, "\\x escapes are only allowed in JSON5");
case JsonLintType.JSON5_ESCAPED_CHAR: return TryTranslateWithOneParam(translated, lintType, "Escaped char '{0}' is only valid in JSON5", param1);
case JsonLintType.JSON5_UNQUOTED_KEY: return Translator.TranslateLintMessage(translated, lintType, "Unquoted keys are only supported in JSON5");
case JsonLintType.JSON5_NUM_LEADING_PLUS: return Translator.TranslateLintMessage(translated, lintType, "Leading + signs in numbers are not allowed except in JSON5");
case JsonLintType.JSON5_HEX_NUM: return Translator.TranslateLintMessage(translated, lintType, "Hexadecimal numbers are only part of JSON5");
case JsonLintType.JSON5_NUM_LEADING_DECIMAL_POINT: return Translator.TranslateLintMessage(translated, lintType, "Numbers with a leading decimal point are only part of JSON5");
case JsonLintType.JSON5_ESCAPED_CHAR: return TryTranslateWithOneParam(translated, lintType, "Escaped char '{0}' is only allowed in JSON5", param1);
case JsonLintType.JSON5_UNQUOTED_KEY: return Translator.TranslateLintMessage(translated, lintType, "Unquoted keys are only allowed in JSON5");
case JsonLintType.JSON5_NUM_LEADING_PLUS: return Translator.TranslateLintMessage(translated, lintType, "Leading + signs in numbers are only allowed in JSON5");
case JsonLintType.JSON5_HEX_NUM: return Translator.TranslateLintMessage(translated, lintType, "Hexadecimal numbers are only allowed in JSON5");
case JsonLintType.JSON5_NUM_LEADING_DECIMAL_POINT: return Translator.TranslateLintMessage(translated, lintType, "Numbers with a leading decimal point are only allowed in JSON5");
case JsonLintType.JSON5_COMMA_AFTER_LAST_ELEMENT_ARRAY: return Translator.TranslateLintMessage(translated, lintType, "Comma after last element of array");
case JsonLintType.JSON5_COMMA_AFTER_LAST_ELEMENT_OBJECT: return Translator.TranslateLintMessage(translated, lintType, "Comma after last key-value pair of object");
case JsonLintType.JSON5_NUM_TRAILING_DECIMAL_POINT: return Translator.TranslateLintMessage(translated, lintType, "Numbers with a trailing decimal point are only allowed in JSON5");
// BAD messages
case JsonLintType.JSON5_NUM_TRAILING_DECIMAL_POINT: return Translator.TranslateLintMessage(translated, lintType, "Numbers with a trailing decimal point are only part of JSON5");
case JsonLintType.BAD_UNTERMINATED_MULTILINE_COMMENT: return Translator.TranslateLintMessage(translated, lintType, "Unterminated multi-line comment");
case JsonLintType.BAD_PYTHON_COMMENT: return Translator.TranslateLintMessage(translated, lintType, "Python-style '#' comments are not part of any well-accepted JSON specification");
case JsonLintType.BAD_PYTHON_COMMENT: return Translator.TranslateLintMessage(translated, lintType, "Python-style '#' comments are not allowed in any well-accepted JSON specification");
case JsonLintType.BAD_STRING_CONTAINS_NEWLINE: return Translator.TranslateLintMessage(translated, lintType, "String literal contains newline");
case JsonLintType.BAD_KEY_CONTAINS_NEWLINE: return Translator.TranslateLintMessage(translated, lintType, "Object key contains newline");
case JsonLintType.BAD_UNTERMINATED_STRING: return TryTranslateWithOneParam(translated, lintType, "Unterminated string literal starting at position {0}", param1);
case JsonLintType.BAD_INVALID_UNQUOTED_KEY: return TryTranslateWithOneParam(translated, lintType, "No valid unquoted key beginning at {0}", param1);
case JsonLintType.BAD_PYTHON_nan: return Translator.TranslateLintMessage(translated, lintType, "nan is not a valid representation of Not a Number in JSON");
case JsonLintType.BAD_PYTHON_None: return Translator.TranslateLintMessage(translated, lintType, "None is not an accepted part of any JSON specification");
case JsonLintType.BAD_PYTHON_None: return Translator.TranslateLintMessage(translated, lintType, "None is not allowed in any JSON specification");
case JsonLintType.BAD_PYTHON_inf: return Translator.TranslateLintMessage(translated, lintType, "inf is not the correct representation of Infinity in JSON");
case JsonLintType.BAD_UNNECESSARY_LEADING_0: return Translator.TranslateLintMessage(translated, lintType, "Numbers with an unnecessary leading 0 (like \"01\") are not part of any JSON specification");
case JsonLintType.BAD_SLASH_FRACTION: return Translator.TranslateLintMessage(translated, lintType, "Fractions of the form 1/3 are not part of any JSON specification");
case JsonLintType.BAD_UNNECESSARY_LEADING_0: return Translator.TranslateLintMessage(translated, lintType, "Numbers with an unnecessary leading 0 (like \"01\") are not allowed in any JSON specification");
case JsonLintType.BAD_SLASH_FRACTION: return Translator.TranslateLintMessage(translated, lintType, "Fractions of the form 1/3 are not allowed in any JSON specification");
case JsonLintType.BAD_NUMBER_INVALID_FORMAT: return TryTranslateWithOneParam(translated, lintType, "Number string {0} had bad format", param1);
case JsonLintType.BAD_TWO_CONSECUTIVE_COMMAS_ARRAY: return TryTranslateWithOneParam(translated, lintType, "Two consecutive commas after element {0} of array", param1);
case JsonLintType.BAD_COMMA_BEFORE_FIRST_ELEMENT_ARRAY: return Translator.TranslateLintMessage(translated, lintType, "Comma before first value in array");
Expand All @@ -181,9 +181,9 @@ public string TranslateMessageIfDesired(bool translated)
case JsonLintType.BAD_CHAR_WHERE_COLON_EXPECTED: return TryTranslateWithTwoParams(translated, lintType, "Found '{0}' after key {1} when colon expected", param1, param2);
case JsonLintType.BAD_NO_COLON_BETWEEN_OBJECT_KEY_VALUE: return TryTranslateWithOneParam(translated, lintType, "No ':' between key {0} and value {0} of object", param1);
case JsonLintType.BAD_DUPLICATE_KEY: return TryTranslateWithOneParam(translated, lintType, "Object has multiple of key \"{0}\"", param1);
case JsonLintType.BAD_PYTHON_True: return Translator.TranslateLintMessage(translated, lintType, "True is not an accepted part of any JSON specification");
case JsonLintType.BAD_PYTHON_False: return Translator.TranslateLintMessage(translated, lintType, "False is not an accepted part of any JSON specification");
case JsonLintType.BAD_JAVASCRIPT_undefined: return Translator.TranslateLintMessage(translated, lintType, "undefined is not part of any JSON specification");
case JsonLintType.BAD_PYTHON_True: return Translator.TranslateLintMessage(translated, lintType, "True is not allowed in any JSON specification");
case JsonLintType.BAD_PYTHON_False: return Translator.TranslateLintMessage(translated, lintType, "False is not allowed in any JSON specification");
case JsonLintType.BAD_JAVASCRIPT_undefined: return Translator.TranslateLintMessage(translated, lintType, "undefined is not allowed in any JSON specification");
case JsonLintType.BAD_CHAR_INSTEAD_OF_EOF: return TryTranslateWithOneParam(translated, lintType, "At end of valid JSON document, got {0} instead of EOF", param1);
// FATAL messages
case JsonLintType.FATAL_EXPECTED_JAVASCRIPT_COMMENT: return Translator.TranslateLintMessage(translated, lintType, "Expected JavaScript comment after '/'");
Expand Down
4 changes: 2 additions & 2 deletions JsonToolsNppPlugin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("8.0.0.8")]
[assembly: AssemblyFileVersion("8.0.0.8")]
[assembly: AssemblyVersion("8.0.0.9")]
[assembly: AssemblyFileVersion("8.0.0.9")]
Loading

0 comments on commit 90d0f56

Please sign in to comment.