Several different styles in error/warning messages
Is there a particular reason/need to use different styles in the messages?
-
missing ] after element list -
missing '{' before try block -
unmatched ) in regular expression. -
continue must be inside loop -
yield must be in a function. -
'try' without 'catch' or 'finally' -
Unexpected end of file -
Cannot convert null to an object.
I understand it's a matter of taste, but wouldn't it be nicer if all messages share a common shape?
One possible style guide could be:
- always start with a capitalized letter (if the first word is not a keyword)
- always delimit keywords/punctuation with single quotes
- always end with a period
What do you think?
Most of the messages came from SpiderMonkey by the way of Rhino. Here's the main file: https://hg.mozilla.org/mozilla-central/file/11506aaf7064/js/src/js.msg, and we should try to stick to it when we can.
Looking at it, some things have changed over the years (I can't find the last two messages there, and yield must be in a function. has turned into {0} not in function, for example), so a pull request which would update us with the latest changes would be nice.
But the predominant style is: lowercase, no period at the end. The quoting is indeed inconsistent.
Yes, I figured that out from the comments. Given that I do not mind which style is used but rather that it's more uniform, I do not understand what you mean when you say “we should try to stick to it”: would it be welcome a PR that uniformely uses lowercase, no period at the end, consistent quoting, or do you mean aligning js2-msg database with Rhino's js.msg literally?
do you mean aligning js2-msg database with Rhino's js.msg literally?
This, foremost. The link above is to SpiderMonkey, though. Rhino has been stagnating for a while.
a PR that uniformely uses lowercase, no period at the end, consistent quoting
And this would be fine for strings with no counterparts in SpiderMonkey (the "added by js2-mode" ones, for instance).
First approach, to merge current SM msgs with js2-mode's ones: https://gist.github.com/lelit/90b8660771cf16654473
Of course this needs further (possibly manual) tweaks, to make adjustments and probably remove several unused entries.
It requires the levenshtein package from ELPA...
Indeed. Also, the ideal patch wouldn't change the order of the statements. This shouldn't be too hard to automate either - by performing the replacements in js2-mode.el.
And levenshtein isn't enough at least in some cases, take for instance the message string I've mentioned in the first comment.