Opened 9 years ago
Closed 9 years ago
#38752 closed defect (bug) (fixed)
Twenty Seventeen: JavaScript coding standards
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | Bundled Theme | Keywords: | has-patch |
Focuses: | javascript | Cc: |
Description
All the Twenty Seventeen JavaScript files, excluding third party files, should be checked for proper coding standards.
A few things noticed so far:
- proper indentation
- mixed tabs and spaces
- missing space between
if
and brace (one occurrence) - double spaces
Details, but I guess it's important to show best practices and enforce the usage of coding standards.
Attachments (4)
Change History (11)
#2
@
9 years ago
- Keywords has-patch added; needs-patch removed
Not sure if html5.js
is third party file or it should be changed too
#3
@
9 years ago
Expanding on @sstoqnov patch, I'd avoid code refactoring and just apply some coding standards.
Worth noting couple things, even if they're outside the scope of this ticket:
- some ternary and if/else seem not necessary to me, especially when setting attributes, maybe code could be simplified a bit
- in
global.js
andnavigation.js
, maybe the functions called on window resize could benefit from abstracting the function that sets the resize timer and use a custom event, as 'wp-window-resized' does in the admin, seewp-admin/js/common.js
#4
@
9 years ago
- Focuses javascript added
- Owner set to afercia
- Status changed from new to assigned
Refreshed patch, see:
Spacing for Arrays and Function Calls (Exceptions)
Chained Method Calls
Applied changes where it seemed reasonable to me, any feedback welcome.
#5
follow-up:
↓ 6
@
9 years ago
@afercia This looks good to me. Thank you for going through the files and making them better!
I would be open to the changes you noted in 3, but it's probably best in another ticket. These things may also be able to be changed later since they shouldn't change the functionality.
I can work on committing this tomorrow as long as you're good with everything.
#6
in reply to:
↑ 5
@
9 years ago
Replying to davidakennedy:
I can work on committing this tomorrow as long as you're good with everything.
@davidakennedy thanks, sure :)
Also, not sure there's the need for jscs comments like
// jscs:disable
or// jscs:enable
, unless I'm missing something.