Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several different styles in error/warning messages #225

Open
lelit opened this issue Mar 13, 2015 · 5 comments
Open

Several different styles in error/warning messages #225

lelit opened this issue Mar 13, 2015 · 5 comments

Comments

@lelit
Copy link
Contributor

lelit commented Mar 13, 2015

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?

@dgutov
Copy link
Collaborator

dgutov commented Mar 13, 2015

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.

@lelit
Copy link
Contributor Author

lelit commented Mar 13, 2015

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?

@dgutov
Copy link
Collaborator

dgutov commented Mar 13, 2015

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).

@lelit
Copy link
Contributor Author

lelit commented Mar 14, 2015

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...

@dgutov
Copy link
Collaborator

dgutov commented Mar 14, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants