Created on 27 May 2024, about 1 year ago

Problem/Motivation

GitLab CI is reporting several eslint errors. Let's fix these.

*****************************************************************************************************************************
These are the current ESLINT errors and warnings 
*****************************************************************************************************************************
$ $CI_PROJECT_DIR/$_WEB_ROOT/core/node_modules/.bin/eslint --no-error-on-unmatched-pattern --ignore-pattern="*.es6.js" --resolve-plugins-relative-to=$CI_PROJECT_DIR/$_WEB_ROOT/core --ext=.js,.yml $_ESLINT_EXTRA . || true
/builds/project/json_field/web/modules/custom/json_field/assets/js/json_field.js
   7:3   error  'use strict' is unnecessary inside of modules  strict
   9:3   error  Unexpected var, use let or const instead       no-var
   9:26  error  Insert `โŽยทยทยทยท`                                 prettier/prettier
  13:42  error  Insert `,`                                     prettier/prettier
  14:8   error  Insert `,`                                     prettier/prettier
  15:6   error  Insert `,`                                     prettier/prettier
  24:5   error  Expected method shorthand                      object-shorthand
  27:35  error  Prefer textContent to $.text                   jquery/no-text
  29:6   error  Insert `,`                                     prettier/prettier
  30:5   error  Delete `โŽ`                                     prettier/prettier
/builds/project/json_field/web/modules/custom/json_field/modules/json_field_widget/assets/js/json_widget.js
   7:3   error  'use strict' is unnecessary inside of modules                                                                                                                                                                                                         strict
  12:6   error  Delete `โŽยทยทยท`                                                                                                                                                                                                                                         prettier/prettier
  25:60  error  Insert `.each(`                                                                                                                                                                                                                                       prettier/prettier
  26:9   error  Delete `.each(`                                                                                                                                                                                                                                       prettier/prettier
  27:11  error  Unexpected var, use let or const instead                                                                                                                                                                                                              no-var
  28:11  error  Unexpected var, use let or const instead                                                                                                                                                                                                              no-var
  29:11  error  Unexpected var, use let or const instead                                                                                                                                                                                                              no-var
  30:11  error  Unexpected var, use let or const instead                                                                                                                                                                                                              no-var
  30:22  error  Prefer value to $.val                                                                                                                                                                                                                                 jquery/no-val
  31:11  error  Unexpected var, use let or const instead                                                                                                                                                                                                              no-var
  34:13  error  All 'var' declarations must be at the top of the function scope                                                                                                                                                                                       vars-on-top
  34:13  error  Unexpected var, use let or const instead                                                                                                                                                                                                              no-var
  34:29  error  Replace `Drupal.theme('jsonEditorWrapper',ยท'json-editor-'ยท+ยท$textarea.attr('name'))` with `โŽยทยทยทยทยทยทยทยทยทยทยทยทยทยทDrupal.theme(โŽยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท'jsonEditorWrapper',โŽยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท'json-editor-'ยท+ยท$textarea.attr('name'),โŽยทยทยทยทยทยทยทยทยทยทยทยทยทยท),โŽยทยทยทยทยทยทยทยทยทยทยทยท`  prettier/prettier
  34:63  error  Unexpected string concatenation                                                                                                                                                                                                                       prefer-template
  38:13  error  All 'var' declarations must be at the top of the function scope                                                                                                                                                                                       vars-on-top
  38:13  error  Unexpected var, use let or const instead                                                                                                                                                                                                              no-var
  41:15  error  Expected method shorthand                                                                                                                                                                                                                             object-shorthand
  42:17  error  Prefer textContent to $.text                                                                                                                                                                                                                          jquery/no-text
  42:32  error  'jsonEditor' was used before it was defined                                                                                                                                                                                                           no-use-before-define
  43:16  error  Insert `,`                                                                                                                                                                                                                                            prettier/prettier
  49:13  error  All 'var' declarations must be at the top of the function scope                                                                                                                                                                                       vars-on-top
  49:13  error  Unexpected var, use let or const instead                                                                                                                                                                                                              no-var
  49:34  error  'JSONEditor' is not defined                                                                                                                                                                                                                           no-undef
  49:45  error  Replace `$editor[0],ยทObject.assign({},ยทoptions,ยทinstanceOptions)` with `โŽยทยทยทยทยทยทยทยทยทยทยทยทยทยท$editor[0],โŽยทยทยทยทยทยทยทยทยทยทยทยทยทยทObject.assign({},ยทoptions,ยทinstanceOptions),โŽยทยทยทยทยทยทยทยทยทยทยทยท`                                                                           prettier/prettier
  49:57  error  Use an object spread instead of `Object.assign` eg: `{ ...foo }`                                                                                                                                                                                      prefer-object-spread
  52:14  error  Delete `โŽยทยทยทยทยทยทยทยทยทยทยท`                                                                                                                                                                                                                                 prettier/prettier
  57:10  error  Insert `,โŽยทยทยทยทยทยท`                                                                                                                                                                                                                                     prettier/prettier
  58:6   error  Insert `,`                                                                                                                                                                                                                                            prettier/prettier
  62:12  error  Unexpected string concatenation                                                                                                                                                                                                                       prefer-template
  63:4   error  Replace `โŽ` with `;`                                                                                                                                                                                                                                  prettier/prettier
โœ– 40 problems (40 errors, 0 warnings)
๐Ÿ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ptmkenny
  • Merge request !29fix eslint test โ†’ (Open) created by ptmkenny
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    Thank you.

  • Pipeline finished with Success
    about 1 year ago
    Total: 222s
    #183315
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Pipeline finished with Success
    about 1 year ago
    Total: 179s
    #183320
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

    Ok, four problems remain:

      26:35  error  Prefer textContent to $.text  jquery/no-text
    /builds/issue/json_field-3450116/web/modules/custom/json_field-3450116/modules/json_field_widget/assets/js/json_widget.js
      44:17  error  Prefer textContent to $.text                 jquery/no-text
      44:32  error  'jsonEditor' was used before it was defined  no-use-before-define
      51:36  error  'JSONEditor' is not defined                  no-undef
    โœ– 4 problems (4 errors, 0 warnings)
    

    I don't know how to fix these.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    I wonder if listing jsonEditor and JSONEditor in the open and closing parts of the wrapper function would help?

  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

    Honestly I never really worked with JQuery so I don't understand what's going on here. All my work recently has been in React/TypeScript, so I'm lost about how to fix these issues.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    Build Successful
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    I wonder if we could load the JS library as a dev dependency via bowser or something?

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    We're now down to these:

    /builds/project/json_field/web/modules/custom/json_field/assets/js/json_field.js
      30:9  error  Insert `ยทยท`  prettier/prettier
      31:1  error  Insert `ยทยท`  prettier/prettier
    /builds/project/json_field/web/modules/custom/json_field/modules/json_field_widget/assets/js/json_widget.js
      47:41  error  'jsonEditor' was used before it was defined  no-use-before-define
      75:36  error  'jsonEditor' is not defined                  no-undef
      75:48  error  'JSONEditor' is not defined                  no-undef
    โœ– 5 problems (5 errors, 0 warnings)
    

    I don't know what the first two mean? I've never written JS like that.

  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

    Prettier just does some basic automatic formatting; it wants you to add whitespace even though it shows the dots.

    These kind of fixes can be annoying to do manually, but you can download the patch generated in the build artifacts for the eslint job and apply that, which will automatically fix the things flagged by prettier in most cases.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    Oh, I thought that meant to add a prefix of ".." in front of a line, not to just indent it. Thanks for the tip of checking the eslint artifacts, I applied the patch, will see what difference it makes.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    Ok, down to one error left:

    /builds/project/json_field/web/modules/custom/json_field/modules/json_field_widget/assets/js/json_widget.js
      49:41  error  'jsonEditor' was used before it was defined  no-use-before-define
    โœ– 1 problem (1 error, 0 warnings)
    
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    The tests now pass! Need to manually test it to make sure it still works properly.

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    15 pass
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    In local testing this isn't working anymore - the onChange() callback isn't being called. I also had to revert one of the commits to make the editor load in the first place, so clearly the changes were going in the wrong direction.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    This was shared via Slack, it might be helpful: https://brianperry.dev/posts/2024/matching-drupal-eslint/

  • First commit to issue fork.
  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    I've fixed the last esllint issue, the problem was that onChange was being declared as a function, rather than a property with an anonymous function. That should be the last issue, although I don't know how to manually test all those changes I'm happy to do so to get this merged and unblock 8.x-1.4 (which blocks a stable D11 release)

  • Pipeline finished with Failed
    11 months ago
    Total: 334s
    #253297
  • Pipeline finished with Success
    11 months ago
    Total: 297s
    #253309
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    It still didn't like that... so instead what if we just pass the options directly into the constructor.

  • Status changed to Needs work 11 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    I pulled this down to test and I get the following error in the console:

    Uncaught ReferenceError: jsonEditor is not defined.

    ) (jQuery, Drupal, drupalSettings, jsonEditor, JSONEditor);

  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

    @nicxvan Could you please provide the steps you took to get that error?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    Install dev
    Apply the patch
    Change the form mode setting to the editor
    Edit a page that has the json field
    Check Console

    I'm on my phone so I can't check the editor name.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    Do we really need this to block a stable release? If the module works on D11 it'd be great to get a stable release out ASAP and work on CI tweaks afterwards.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    I'm ok with this not blocking d11, I don't actually use that feature of the module, but to be clear the code editor display doesn't work.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    @nicxvan I mean this issue is just about fixing CSS/JS linting errors. Are you saying that the editor doesn't work even without these changes?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    I don't think the code editor works period. I only tested this issue because it seems to be blocking the d11 release and I saw that bit of js changed.

    I think the code editor is a separate issue and would make sense as a follow up.

    If you all agree I'm happy to rtbc based on my review let me know.

  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

    If the code editor doesn't currently work, that needs to be opened as a separate issue, and this issue should be made dependent on that one. I don't think it makes sense to commit a code cleanup if the underlying code is broken.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    There is no reason to make this dependent, if this gets in, then eslint will enforce the fix is formatted properly anyway.

    Unless the maintainers feel differently.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    I just came back to this, the changes do fix the eslint and I confirmed the issues I found are pre-existing.

    RTBC and I'll open an issue for the other issue.

  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

    I don't think this can be RTBC when the code that is "fixed" by this isn't working, because there's no way to test if these fixes are valid. Postponing on ๐Ÿ› JSON Specific WYSIWYG editor widget does not seem to work. Active

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    Why would you postpone this, the code editor is broken even without these changes applied.

    It has nothing to do with linting so this should be good to merge.

    You can test that these "fixes" are valid by reviewing what they are aiming to fix, eslint.

    Gonna put this back in rtbc so the maintainers can weigh in.

  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

    @nicxvan My point is that for automated tests like eslint to "pass", it is not enough for the GitLab CI scan to show no errors. There should be some manual testing where we confirm that behaviors of the module influenced by the code work as expected.

    It isn't possible to do such testing when the underlying behavior (the code editor) is broken, so I think this issue should be "postponed"-- otherwise you're committing changes to code that is still broken, and what's the point of that?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    The other tests cover the functionality, and as I mentioned I confirmed the bug exists even without these changes.

    You commit this one so it unblocks the issues that were depending on it and you resolve the bug in a dedicated issue.

    If you merge this in then the issue resolving the code editor bug will also have eslint enforced.

    You do not want to introduce new bugs or regressions in an issue, but that is not what is happening here the bug was not introduced with these changes.

  • ๐Ÿ‡ฏ๐Ÿ‡ตJapan ptmkenny

    Ok, I'll just agree to disagree here.

    In any case, it seems you want this committed for a stable D11 release, but if this issue is a release blocker, then almost certainly ๐Ÿ› JSON Specific WYSIWYG editor widget does not seem to work. Active is also a release blocker because a core feature of the module is broken.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    I'm happy to chat further on slack, I'm not sure this issue is where to have the discussion.

    It's up to the maintainers to decide if it's a blocker to 1.4 release.

    However, even core doesn't delay releasing a feature or bug fix because an unrelated bug was discovered.

    The feature is broken in the current release, nothing is lost by releasing other features like d11 support. If it were a regression it would be different, but it's not a regression. It's an unrelated bug I discovered and opened an issue for.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    Thank you for the discussion and for opening the separate issue. Now that we have a good point to work from with the included JS, let's work to fix the other issue as part of this release - people who desperately need the D11 support will have to use the dev release for a little while longer.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States damienmckenna NH, USA

    Committed. Thank you.

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

  • Status changed to Fixed 5 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan
Production build 0.71.5 2024