Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-76528

Disallow variable declarations from shadowing variables declared in the outer scope (JS eslint)

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Minor
    • None
    • 4.2
    • JavaScript
    • MOODLE_402_STABLE

    Description

      This is a continuation of refinement of our eslint config, from MDL-76491 - as an improvement, targetting master only

      As discussed in the original issue by dobedobedoh, we can use the 'no-shadow' rule to detect and disallow cases where we are re-defining browser APIs

      (See eslint-no-shadow.log for full log)

      $ ./node_modules/.bin/grunt amd
      Running "ignorefiles" task
       
      Running "eslint:amd" (eslint) task
      Browserslist: caniuse-lite is outdated. Please run:
        npx browserslist@latest --update-db
        Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
       
      /mnt/export/moodle/master/src/admin/tool/analytics/amd/src/log_info.js
        23:106  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/analytics/amd/src/model.js
        24:27  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/componentlibrary/amd/src/mustache.js
        29:8   error  'Notification' is already a global variable  no-shadow
        71:15  error  'name' is already a global variable          no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/componentlibrary/amd/src/search.js
        27:8   error  'Notification' is already a global variable  no-shadow
        28:16  error  'escape' is already a global variable        no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/add_category.js
        36:5  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/add_purpose.js
        36:5  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/categoriesactions.js
        30:19  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/contactdpo.js
        25:8   error  'Notification' is already a global variable                          no-shadow
        39:46  error  'event' is already a global variable                                 no-shadow
        52:69  error  'event' is already declared in the upper scope on line 39 column 46  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/data_deletion.js
        30:19  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/data_registry.js
        25:28  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/data_request_modal.js
        25:17  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/defaultsactions.js
         31:19  error  'Notification' is already a global variable                              no-shadow
        253:21  error  'activity' is already declared in the upper scope on line 199 column 76  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/myrequestactions.js
        25:8   error  'Notification' is already a global variable  no-shadow
        37:40  error  'event' is already a global variable         no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/purposesactions.js
        30:19  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/request_filter.js
        23:110  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/dataprivacy/amd/src/requestactions.js
         33:19  error  'Notification' is already a global variable                           no-shadow
        141:25  error  'params' is already declared in the upper scope on line 93 column 17  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/langimport/amd/src/search.js
        42:35  error  'event' is already a global variable  no-shadow
        80:55  error  'event' is already a global variable  no-shadow
        87:53  error  'event' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/licensemanager/amd/src/delete_license.js
        24:49  error  'String' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/actionselector.js
         34:21  error  'Notification' is already a global variable  no-shadow
         46:60  error  'confirm' is already a global variable       no-shadow
         47:13  error  'self' is already a global variable          no-shadow
         82:13  error  'self' is already a global variable          no-shadow
        117:13  error  'self' is already a global variable          no-shadow
        129:13  error  'self' is already a global variable          no-shadow
        158:13  error  'self' is already a global variable          no-shadow
        173:13  error  'self' is already a global variable          no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/competencies.js
        124:13  error  'self' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/competency_outcomes.js
        47:17  error  'self' is already a global variable  no-shadow
        71:17  error  'self' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/competency_rule_points.js
        114:13  error  'self' is already a global variable                                   no-shadow
        148:54  error  'index' is already declared in the upper scope on line 139 column 35  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/competencyactions.js
         39:87  error  'menubar' is already a global variable                                  no-shadow
         69:13  error  'parent' is already a global variable                                   no-shadow
        208:42  error  'parent' is already a global variable                                   no-shadow
        685:80  error  'str' is already declared in the upper scope on line 39 column 46       no-shadow
        686:21  error  'name' is already a global variable                                     no-shadow
        705:26  error  'context' is already declared in the upper scope on line 675 column 13  no-shadow
        717:26  error  'context' is already declared in the upper scope on line 675 column 13  no-shadow
        787:50  error  'str' is already declared in the upper scope on line 39 column 46       no-shadow
        792:48  error  'str' is already declared in the upper scope on line 39 column 46       no-shadow
        853:17  error  'top' is already a global variable                                      no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/competencypicker.js
         37:21  error  'Notification' is already a global variable                                  no-shadow
         47:13  error  'self' is already a global variable                                          no-shadow
         94:13  error  'self' is already a global variable                                          no-shadow
        199:13  error  'self' is already a global variable                                          no-shadow
        211:13  error  'self' is already a global variable                                          no-shadow
        232:13  error  'self' is already a global variable                                          no-shadow
        244:44  error  'parent' is already a global variable                                        no-shadow
        244:52  error  'competencies' is already declared in the upper scope on line 239 column 29  no-shadow
        321:13  error  'self' is already a global variable                                          no-shadow
        370:13  error  'self' is already a global variable                                          no-shadow
        393:13  error  'self' is already a global variable                                          no-shadow
        408:13  error  'self' is already a global variable                                          no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/competencypicker_user_plans.js
         37:21  error  'Notification' is already a global variable  no-shadow
         74:13  error  'self' is already a global variable          no-shadow
         96:13  error  'self' is already a global variable          no-shadow
        158:13  error  'self' is already a global variable          no-shadow
        193:13  error  'self' is already a global variable          no-shadow
        216:13  error  'self' is already a global variable          no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/competencyruleconfig.js
         30:21  error  'Notification' is already a global variable  no-shadow
        109:13  error  'self' is already a global variable          no-shadow
        163:13  error  'self' is already a global variable          no-shadow
        201:13  error  'self' is already a global variable          no-shadow
        223:13  error  'self' is already a global variable          no-shadow
        297:13  error  'self' is already a global variable          no-shadow
        298:13  error  'name' is already a global variable          no-shadow
        316:13  error  'self' is already a global variable          no-shadow
        331:13  error  'self' is already a global variable          no-shadow
        411:13  error  'self' is already a global variable          no-shadow
        439:13  error  'self' is already a global variable          no-shadow
        453:13  error  'self' is already a global variable          no-shadow
        490:13  error  'self' is already a global variable          no-shadow
        514:13  error  'self' is already a global variable          no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/competencytree.js
        50:32  error  'parent' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/dialogue.js
        24:31  error  'Y' is already a global variable       no-shadow
        41:13  error  'parent' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/dragdrop-reorder.js
        23:48  error  'Y' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/evidence_delete.js
        29:21  error  'Notification' is already a global variable  no-shadow
        45:17  error  'parent' is already a global variable        no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/form-user-selector.js
        62:109  error  'i' is already declared in the upper scope on line 56 column 21  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/form_competency_element.js
        24:35  error  'Notification' is already a global variable                      no-shadow
        52:17  error  'i' is already declared in the upper scope on line 39 column 13  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/frameworks_datasource.js
        26:72  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/grade_dialogue.js
        30:21  error  'Notification' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/grade_user_competency_inline.js
         96:13  error  'self' is already a global variable                                    no-shadow
        116:24  error  'options' is already declared in the upper scope on line 95 column 13  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/menubar.js
        279:13  error  'top' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/parentcompetency_form.js
         24:47  error  'Notification' is already a global variable                         no-shadow
         67:13  error  'self' is already a global variable                                 no-shadow
         94:13  error  'self' is already a global variable                                 no-shadow
        104:21  error  'self' is already declared in the upper scope on line 94 column 13  no-shadow
        119:40  error  'e' is already declared in the upper scope on line 97 column 53     no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/planactions.js
         79:13  error  'self' is already a global variable    no-shadow
        115:13  error  'self' is already a global variable    no-shadow
        137:13  error  'self' is already a global variable    no-shadow
        160:13  error  'self' is already a global variable    no-shadow
        174:13  error  'self' is already a global variable    no-shadow
        209:13  error  'self' is already a global variable    no-shadow
        223:13  error  'self' is already a global variable    no-shadow
        256:13  error  'self' is already a global variable    no-shadow
        270:13  error  'self' is already a global variable    no-shadow
        302:13  error  'self' is already a global variable    no-shadow
        316:13  error  'self' is already a global variable    no-shadow
        547:13  error  'parent' is already a global variable  no-shadow
       
      /mnt/export/moodle/master/src/admin/tool/lp/amd/src/scaleconfig.js
        64:13  error  'self' is already a global variable  no-shadow
       
      // ... Chop off to within Jira limits - see attachment.
       
      ✖ 688 problems (688 errors, 0 warnings)
       
      Warning: Task "eslint:amd" failed. Use --force to continue.
       
      Aborted due to warnings
      

       
      We may need to fine tune this rule, as it currently catches a lot of errors

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              pholden Paul Holden
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Clockify

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.