You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it's worth considering some revisions to the JS coding standards as there are a few things about them at the moment that stand out to me as a little funny. I know people sometimes get overly sensitive about this kind of stuff but, let's face it, much of any coding standard is just arbitrary. Considering that, a coding standard should be as easy for the developer to follow properly as possible.
In PHP, we have PHPCS which can find and explain any CS errors you may have. If you have a decent IDE, you may even be able to hook it up to show your CS errors in real time. This kind of thing makes it really easy to write properly formatted code the first time and avoid going back over your code just to clean up the style.
For Javascript, we don't have such a thing (that I know of) but we do have jsbeautifier which will clean up your code automatically. Whatever the standard is, it would be best if it can be defined as jsbeautifier settings without exceptions. That way:
Cleaning up any file (old or new) is just a single command instead of a bunch of manual checks
The developer doesn't have to care too much about all details of the standard while coding
A test can easily be set up to determine if the code in a PR adheres to the standard
This mostly works today except for a few parts of the Joomla JS standard which should probably change:
The exceptions for spacing around function arguments
Maybe the rule about chained function calls
That's all. Change that and correct js formatting can just be automatic.
There's at least one more change that would really help which is unrelated to jsbeautifier. In PHP, our multiline comments are like:
/** * Start with twoasterisks. * Oneasteriskoneachsubsequent line. */
But in JS, it's like:
/*** Start with one asterisk.** Two on each subsequent line.*/
A good ide can help a lot with writing comments and especially docblocks but it may be difficult or troublesome to configure different styles for different languages. Why should we have such a different standard for something that doesn't matter at all? Let's just keep this part the same between Javascript and PHP.
The text was updated successfully, but these errors were encountered:
I'd start with deciding whether we use tabs or spaces, because current CS allows both (Tabs, 4 spaces), and actually both styles are being used in core-uncompressed.js.
By the way: I'd prefer having core.js and core.min.js.
A good tool for javascript code styling is JSCS, available in for many editors and as gulp/ grunt task. plugin.
Alternatively JHint may give little hints while editing with a .jshintrc placed in project root.
I think it's worth considering some revisions to the JS coding standards as there are a few things about them at the moment that stand out to me as a little funny. I know people sometimes get overly sensitive about this kind of stuff but, let's face it, much of any coding standard is just arbitrary. Considering that, a coding standard should be as easy for the developer to follow properly as possible.
In PHP, we have PHPCS which can find and explain any CS errors you may have. If you have a decent IDE, you may even be able to hook it up to show your CS errors in real time. This kind of thing makes it really easy to write properly formatted code the first time and avoid going back over your code just to clean up the style.
For Javascript, we don't have such a thing (that I know of) but we do have jsbeautifier which will clean up your code automatically. Whatever the standard is, it would be best if it can be defined as jsbeautifier settings without exceptions. That way:
This mostly works today except for a few parts of the Joomla JS standard which should probably change:
That's all. Change that and correct js formatting can just be automatic.
There's at least one more change that would really help which is unrelated to jsbeautifier. In PHP, our multiline comments are like:
But in JS, it's like:
A good ide can help a lot with writing comments and especially docblocks but it may be difficult or troublesome to configure different styles for different languages. Why should we have such a different standard for something that doesn't matter at all? Let's just keep this part the same between Javascript and PHP.
The text was updated successfully, but these errors were encountered: