Get eslint test to pass and then require it to pass

Created on 23 March 2024, 9 months ago
Updated 16 June 2024, 6 months ago

ESLint tests failed when we used the GitLab CI template: https://git.drupalcode.org/project/token_filter/-/jobs/1136149

  1. Enable ESLint tests
  2. Make the tests pass

Notes:

  • Fix issues rather than ignoring them wherever possible.
  • If you must ignore a problem do it line-by-line except for compiled code.
šŸ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

šŸ‡¦šŸ‡ŗAustralia darvanen Sydney, Australia

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

Merge Requests

Comments & Activities

  • Issue created by @darvanen
  • First commit to issue fork.
  • Merge request !16enable eslint ā†’ (Merged) created by ptmkenny
  • Pipeline finished with Success
    7 months ago
    Total: 165s
    #184148
  • Pipeline finished with Success
    7 months ago
    Total: 204s
    #184154
  • šŸ‡ÆšŸ‡µJapan ptmkenny

    Many of the issues are with js/build/tokenBrowser.js, but this file probably doesn't need to be linted because it is already built and not meant to be user-editable.

  • Pipeline finished with Success
    7 months ago
    Total: 198s
    #184158
  • Pipeline finished with Success
    7 months ago
    Total: 198s
    #184161
  • Pipeline finished with Success
    7 months ago
    Total: 142s
    #184168
  • šŸ‡¦šŸ‡ŗAustralia darvanen Sydney, Australia

    @ptmkenny I've merged the changes from šŸ“Œ Require composer-lint, cspell, phpcs, and stylelint to pass Fixed , you may wish to rebase this branch.

    Yes please to ignoring compiled files.

  • Pipeline finished with Success
    7 months ago
    Total: 150s
    #184170
  • Pipeline finished with Success
    7 months ago
    Total: 154s
    #184178
  • Pipeline finished with Failed
    7 months ago
    Total: 154s
    #184183
  • šŸ‡ÆšŸ‡µJapan ptmkenny

    @darvanen Thanks for the quick merge! Updated and requiring eslint to pass as part of this issue.

  • Pipeline finished with Failed
    7 months ago
    Total: 167s
    #184202
  • Status changed to Needs work 7 months ago
  • šŸ‡ÆšŸ‡µJapan ptmkenny

    Ok, here are the remaining issues:

    /builds/issue/token_filter-3433142/web/modules/custom/token_filter-3433142/js/ckeditor5_plugins/tokenBrowser/src/token-browser-command.js
      1:25  error  Unable to resolve path to module 'ckeditor5/src/core'  import/no-unresolved
    /builds/issue/token_filter-3433142/web/modules/custom/token_filter-3433142/js/ckeditor5_plugins/tokenBrowser/src/token-browser-editing.js
      1:24  error  Unable to resolve path to module 'ckeditor5/src/core'  import/no-unresolved
    /builds/issue/token_filter-3433142/web/modules/custom/token_filter-3433142/js/ckeditor5_plugins/tokenBrowser/src/token-browser-ui.js
      1:24  error  Unable to resolve path to module 'ckeditor5/src/core'  import/no-unresolved
      2:28  error  Unable to resolve path to module 'ckeditor5/src/ui'    import/no-unresolved
    /builds/issue/token_filter-3433142/web/modules/custom/token_filter-3433142/js/ckeditor5_plugins/tokenBrowser/src/token-browser.js
      1:24  error  Unable to resolve path to module 'ckeditor5/src/core'  import/no-unresolved
    /builds/issue/token_filter-3433142/web/modules/custom/token_filter-3433142/js/plugins/tokenbrowser/plugin.js
      62:20  error  'CKEDITOR' is not defined  no-undef
    /builds/issue/token_filter-3433142/web/modules/custom/token_filter-3433142/webpack.config.js
      3:25  error  Unable to resolve path to module 'webpack'                import/no-unresolved
      4:30  error  Unable to resolve path to module 'terser-webpack-plugin'  import/no-unresolved
    āœ– 8 problems (8 errors, 0 warnings)
    

    7 of the issues are a result of ckeditor5/webpack not being installed.

    As for how to solve this, in Drupal Slack #gitlab, @fjgarlin stated:

    this is what core does https://git.drupalcode.org/project/drupal/-/blob/11.x/.gitlab-ci.yml?ref_type=heads#L359
    maybe you need to run that somehow. maybe in the composer:after_script because we run yarn in the composer job: https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.main.yml#L350
    
    or ignore
    
  • Pipeline finished with Failed
    7 months ago
    Total: 167s
    #184217
  • Pipeline finished with Failed
    7 months ago
    #184234
  • Pipeline finished with Failed
    7 months ago
    #184235
  • Pipeline finished with Failed
    7 months ago
    Total: 229s
    #184230
  • Pipeline finished with Failed
    7 months ago
    #184238
  • Pipeline finished with Failed
    7 months ago
    #184240
  • Pipeline finished with Failed
    7 months ago
    Total: 176s
    #184242
  • Pipeline finished with Failed
    7 months ago
    Total: 180s
    #184247
  • Pipeline finished with Failed
    7 months ago
    Total: 244s
    #184260
  • Pipeline finished with Success
    7 months ago
    Total: 174s
    #184264
  • Status changed to Needs review 7 months ago
  • šŸ‡ÆšŸ‡µJapan ptmkenny

    So there was one final error I wasn't sure about:

    /builds/issue/token_filter-3433142/web/modules/custom/token_filter-3433142/js/plugins/tokenbrowser/plugin.js
      62:20  error  'CKEDITOR' is not defined  no-undef
    āœ– 1 problem (1 error, 0 warnings)
    

    The code appears to be based off of Entity Embed module's CKEditor plugin, but that has the same eslint issue.

    So, I just ignored this line, since CKEDITOR should always be defined, right?

    If not, hopefully someone else can fix this.

    The only other thing I ignored was the build output, but that should be ignored because build artifacts don't need to be linted.

    I did NOT manually test this because I don't use CKEditor on my site, so I would appreciate if someone who is using the plugin can test this and confirm everything still works.

  • šŸ‡¦šŸ‡ŗAustralia darvanen Sydney, Australia

    Nice one! Gonna do the manual testing now. One question for my ongoing education: what purpose does making ckeditor5 a dependency instead of a dev-dependency serve?

  • Status changed to Needs work 7 months ago
  • šŸ‡¦šŸ‡ŗAustralia darvanen Sydney, Australia

    Alrighty, everything worked until I rebuilt the code with the altered JS then the CKEditor instance failed to initialise and the browser reported this:

    CKEditorError: plugincollection-plugin-not-found {"plugin":null}
    Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-plugincollection-plugin-not-found
        at ckeditor5-dll.js?v=40.2.0:5:110188
        at ckeditor5-dll.js?v=40.2.0:5:110247
        at Array.forEach (<anonymous>)
        at u (ckeditor5-dll.js?v=40.2.0:5:110049)
        at l.init (ckeditor5-dll.js?v=40.2.0:5:108537)
        at D.initPlugins (ckeditor5-dll.js?v=40.2.0:5:115287)
        at js_SiUtCm46YLOYMNhHO4sPUmdx9_ZqVt-kXQc_l3wcO6E.js?scope=footer&delta=2&language=en&theme=claro&include=eJyNU9tuwyAM_SGaPO0DNql9mrRPiBziJKyAKZhu7dcPktAurVTlJfHl-GDsgyTL-MsRdN356EBX8hbZaWWPQUjyWFvyBrS6opAaPNWDpjYhAl8SaJgxCwFIVmecihewpQ53fWIQ2Sq4bK8KJWkNLqyDEJkkGaeRUTjgsSSynZDGoOU7w-SK9IlNVCW8uCvewMAYRK80oy_B2RPyiJ1i8m-1SrPwNmXKASWzBVOhcSMEFTaBRzZ6bwdlcRNcGRiWSd2DeVh5zsCPmVaTPJ4i8VPNvKfHWHhicBAYD57MV98r-UQTKHqJ--RNethwA5n2_5Hb2oRmaPXToSN5dU16Bf05zW2d9WjojId5HkxHtM2y7tlpPf2EtO4s96KAbGdR4D9JLMS33r5PEf2lmgQ9C7woGs671GcQITXGMt5Yi5-6IN1CbmD6ixju4st2pdLzy0_uxasstdAZZZsHxoo94otUGtk5X_khhUGCw_dcJlo1NE45rIvxBxRnl5Y:5:9630
        at new Promise (<anonymous>)
        at D.create (js_SiUtCm46YLOYMNhHO4sPUmdx9_ZqVt-kXQc_l3wcO6E.js?scope=footer&delta=2&language=en&theme=claro&include=eJyNU9tuwyAM_SGaPO0DNql9mrRPiBziJKyAKZhu7dcPktAurVTlJfHl-GDsgyTL-MsRdN356EBX8hbZaWWPQUjyWFvyBrS6opAaPNWDpjYhAl8SaJgxCwFIVmecihewpQ53fWIQ2Sq4bK8KJWkNLqyDEJkkGaeRUTjgsSSynZDGoOU7w-SK9IlNVCW8uCvewMAYRK80oy_B2RPyiJ1i8m-1SrPwNmXKASWzBVOhcSMEFTaBRzZ6bwdlcRNcGRiWSd2DeVh5zsCPmVaTPJ4i8VPNvKfHWHhicBAYD57MV98r-UQTKHqJ--RNethwA5n2_5Hb2oRmaPXToSN5dU16Bf05zW2d9WjojId5HkxHtM2y7tlpPf2EtO4s96KAbGdR4D9JLMS33r5PEf2lmgQ9C7woGs671GcQITXGMt5Yi5-6IN1CbmD6ixju4st2pdLzy0_uxasstdAZZZsHxoo94otUGtk5X_khhUGCw_dcJlo1NE45rIvxBxRnl5Y:5:9587)
        at Object.attach (js_SiUtCm46YLOYMNhHO4sPUmdx9_ZqVt-kXQc_l3wcO6E.js?scope=footer&delta=2&language=en&theme=claro&include=eJyNU9tuwyAM_SGaPO0DNql9mrRPiBziJKyAKZhu7dcPktAurVTlJfHl-GDsgyTL-MsRdN356EBX8hbZaWWPQUjyWFvyBrS6opAaPNWDpjYhAl8SaJgxCwFIVmecihewpQ53fWIQ2Sq4bK8KJWkNLqyDEJkkGaeRUTjgsSSynZDGoOU7w-SK9IlNVCW8uCvewMAYRK80oy_B2RPyiJ1i8m-1SrPwNmXKASWzBVOhcSMEFTaBRzZ6bwdlcRNcGRiWSd2DeVh5zsCPmVaTPJ4i8VPNvKfHWHhicBAYD57MV98r-UQTKHqJ--RNethwA5n2_5Hb2oRmaPXToSN5dU16Bf05zW2d9WjojId5HkxHtM2y7tlpPf2EtO4s96KAbGdR4D9JLMS33r5PEf2lmgQ9C7woGs671GcQITXGMt5Yi5-6IN1CbmD6ixju4st2pdLzy0_uxasstdAZZZsHxoo94otUGtk5X_khhUGCw_dcJlo1NE45rIvxBxRnl5Y:22:3962)
  • Pipeline finished with Failed
    7 months ago
    Total: 175s
    #185247
  • šŸ‡ÆšŸ‡µJapan ptmkenny

    Hmm, maybe CKEditor requires the plugins not to be exported by default? Just a guess.

    what purpose does making ckeditor5 a dependency instead of a dev-dependency serve?

    This is just a standard eslint error. Eslint requires anything that is imported in the build to be in dependencies instead of devDependencies. I am not an expert on this, but usually I don't think it matters either way. However, there may be cases where webpack, vite, and other build tools can make mistakes because they will strip devDependencies, so if a real dependency that gets imported is in dev, what should the build tool do, strip it or keep it? To avoid this kind of confusion, eslint says make it a dependency.

  • Status changed to RTBC 7 months ago
  • šŸ‡¦šŸ‡ŗAustralia darvanen Sydney, Australia

    Looks like we just needed to compile the JS code. Manual testing passes now.

  • Pipeline finished with Skipped
    7 months ago
    #189368
  • Status changed to Fixed 7 months ago
  • šŸ‡¦šŸ‡ŗAustralia darvanen Sydney, Australia

    Brilliant work mate, thank you.

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

Production build 0.71.5 2024