Problem/Motivation

Part of #2924351: Fix coding standards issues with existing settings tray JavaScript. @drpal noticed that there are a number of comments in the JavaScript file that are not correctly wrapped at 80 characters.

Note that normally we would fix one coding standard rule across all of core, as explained in https://www.drupal.org/core/scope#coding-standards, but phpcs.xml.dist defines PHP standards, not JS standards. We're scoping this to only the JS code and only Settings Tray because it's an experimental module (which means it still goes through a final code review).

Proposed resolution

Update the documentation to be wrapped correctly.

Remaining tasks

  • Rewrap the comments in Settings Tray JavaScript files (core/modules/settings_tray/js/settings_tray.es6.js).
  • We don't need to re-transpile it to ES5 because there are no comments in the transpiled files.
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

xjm created an issue. See original summary.

yo30’s picture

Status: Active » Needs review
FileSize
6.33 KB

I wrapped the comments in this module to 80 character limit. Here is my patch. It remains this file SettingsTrayFormAnnotationNoneBlock.php
It is needed to rename the admin label block from "Settings Tray test block: forms[settings_tray] is not specified" to smth shorter to be on a single line.

xjm’s picture

Status: Needs review » Needs work

Thanks @yo30! Nice work on this. (Also, welcome to Drupal.org!)

A couple of points of feedback:

  1. +++ b/core/modules/settings_tray/js/settings_tray.es6.js
    @@ -50,7 +50,8 @@
    -   * Gets all items that should be toggled with class during edit mode.
    +   * Gets all items that should be toggled with class
    +   * during edit mode.
    

    This comment line was already less than 80 characters long, so we don't need to rewrap it here.

  2. For the rest of the patch, we should only adjust comments in .es6.js files inside Settings Tray (not the .php files). The reason for this is that it came up in a JavaScript maintainer's review of the new JS code in Settings Tray (which we do to mark the module stable). There are a number of other comments longer than 80 characters in settings_tray.es6.js.

Can you also provide an updated patch for that? Thanks again.

gaurav.kapoor’s picture

Did changes only settings.es6.js as per #3.

gaurav.kapoor’s picture

Status: Needs work » Needs review
yo30’s picture

FileSize
2.18 KB

Ok, I reviewed this file now. Thanks for feedback:)

xjm’s picture

Version: 8.4.x-dev » 8.5.x-dev
Status: Needs review » Needs work

Thanks @yo30. Those comments are still wrapping too early. They should go as close as possible to 80 characters without going over.

@gaurav.kapoor's patch is closer to what we need, but I noticed that it doesn't apply on 8.5.x. So let's create a patch for 8.5.x first, and then we can use #4 as a backport.

Thanks!

xjm’s picture

Issue summary: View changes

Updating the summary to explain why we have this issue scope. :)

yo30’s picture

xjm’s picture

Status: Needs work » Reviewed & tested by the community

That looks good now, thanks!

xjm’s picture

vaplas’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/settings_tray/js/settings_tray.es6.js
@@ -195,9 +195,9 @@
-     * Bind a listener to all 'Quick edit' links for blocks. Click "Edit" button
...
+     * Bind a listener to all 'Quick edit' links for blocks. Click "Edit"

Looks like in this line there are no violations of length.

Edit: But the next line can be longer

+++ b/core/modules/settings_tray/js/settings_tray.es6.js
@@ -195,9 +195,9 @@
-     * in toolbar to force Contextual Edit which starts Settings Tray edit
-     * mode also.
+     * in toolbar to force Contextual Edit which starts Settings Tray edit mode
+     * also.
vaplas’s picture

opps, my last edit in #12 goes beyond of the scope. Please, ignore it.

Also this patch contains changes only in settings_tray.es6.js. But we need to do it for settings_tray.js too. See https://www.drupal.org/node/2815083

xjm’s picture

Status: Needs work » Reviewed & tested by the community

@vaplas, as I mention above, there are no comments in the ES5 files, so the transpiled version is the same as what's in HEAD.

So this is still RTBC.

vaplas’s picture

Indeed, my bad. Sorry for this. @xjm thank you for clarifying again.

+++ b/core/modules/settings_tray/js/settings_tray.es6.js
@@ -195,9 +195,9 @@
-     * Bind a listener to all 'Quick edit' links for blocks. Click "Edit" button
-     * in toolbar to force Contextual Edit which starts Settings Tray edit
-     * mode also.
+     * Bind a listener to all 'Quick edit' links for blocks. Click "Edit"
+     * button in toolbar to force Contextual Edit which starts Settings Tray
+     * edit mode also.

But why we need these changes? There are exactly 80 characters.

xjm’s picture

Ah, so that one character is a gray area. We had a discussion about this several years ago because the interpretation of the 80 characters depends on whether you include the line ending character. Historical 80 character limits were 79 characters plus the line ending character (and that's also the point where my window settings add wrapping), but many IDEs and linting tools don't count the line ending character. So I usually accept patches either way if the line would include exactly 80 visible characters. :)

vaplas’s picture

@xjm++!
I did not even think about \n. Before I like it so much when the line fits exactly 80 visible characters. Now the world will not be the same :( Sorry for noise!

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3874554 and pushed to 8.5.x. Thanks!

  • catch committed 3874554 on 8.5.x
    Issue #2924365 by yo30, gaurav.kapoor, xjm: Wrap JS comments in Settings...

  • xjm committed c7a67c3 on 8.4.x
    Issue #2924365 by yo30, gaurav.kapoor, xjm: Wrap JS comments in Settings...
xjm’s picture

Version: 8.5.x-dev » 8.4.x-dev

I committed #4 to 8.4.x as a backport as well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.