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

Check Moodle JS coding style with eslint

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Repeated on all platforms (Linux, Mac and Windows)

      1. Run npm install to ensure dependencies and up to date
      2. Run grunt and ensure no errors are reported
      3. Run grunt watch
        1. Edit an amd js file e.g. admin/tool/lp/amd/src/actionselector.js and introduce a eslint error e.g. add console.log('error'); save the file.
        2. VERIFY the watch task runs eslint:amd and reports a failure
        3. VERIFY once you've removed the error it runs again and reports success
        4. Edit a YUI js file e.g. lib/editor/atto/plugins/managefiles/yui/src/usedfiles/js/usedfiles.js and introduce an eslint error e.g. remove semi colon. Save the file.
        5. VERIFY the watch task runs eslint:yui and reports a failure
        6. VERIFY once you've removed the error it runs again and reports success and runs shifter
      4. On Linux and Mac run grunt in the directory lib/amd/, on windows run grunt with --root lib/amd/
        1. Ensure it only runs AMD tasks (eslint:amd, jshint:amd, uglify:amd)
        2. Run with argument --show-lint-warnings and verify it shows lint warnings about the files only in lib/amd/
      5. Run grunt --show-lint-warnings in the root directory and ensure it shows lint warnings about amd/yui src files in whole project
      Show
      Repeated on all platforms (Linux, Mac and Windows) Run npm install to ensure dependencies and up to date Run grunt and ensure no errors are reported Run grunt watch Edit an amd js file e.g. admin/tool/lp/amd/src/actionselector.js and introduce a eslint error e.g. add console.log('error'); save the file. VERIFY the watch task runs eslint:amd and reports a failure VERIFY once you've removed the error it runs again and reports success Edit a YUI js file e.g. lib/editor/atto/plugins/managefiles/yui/src/usedfiles/js/usedfiles.js and introduce an eslint error e.g. remove semi colon. Save the file. VERIFY the watch task runs eslint:yui and reports a failure VERIFY once you've removed the error it runs again and reports success and runs shifter On Linux and Mac run grunt in the directory lib/amd/, on windows run grunt with --root lib/amd/ Ensure it only runs AMD tasks (eslint:amd, jshint:amd, uglify:amd) Run with argument --show-lint-warnings and verify it shows lint warnings about the files only in lib/amd/ Run grunt --show-lint-warnings in the root directory and ensure it shows lint warnings about amd/yui src files in whole project
    • Affected Branches:
      MOODLE_30_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull Master Branch:
      MDL-52127-master

      Description

      Is the JS coding style described here valid?

      https://docs.moodle.org/dev/Javascript/Coding_style

      If so is there any existing tools to check this automatically?

      There's a tool called jscs that could do so if a configuration file was created. It should also be able to semi-interactively create one if pointed at some examples of good practice.

        Attachments

        1. entire-codebase.html
          3.35 MB
          Dan Poltawski
        2. eslint-style.html
          301 kB
          Dan Poltawski
        3. eslint-without-jsdoc.html
          92 kB
          Dan Poltawski

          Issue Links

            Activity

              People

              • Votes:
                4 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  5/Dec/16