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

Tell grunt eslint to fail on warnings

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.7.6, 3.8.2, 3.9
    • Fix Version/s: 3.7.6, 3.8.3
    • Component/s: JavaScript
    • Labels:
    • Testing Instructions:
      Hide

      Run the following and observe output/result (numbers between parenthesis for easier reference, are not part of the command to execute):

      npm install
      grunt ignorefiles
      (1) grunt eslint # No errors and no warnings
      (2) grunt eslint --show-lint-warnings # Bunch of warnings, "Done", 0 return code
      (3) grunt eslint --max-lint-warnings=-1 # Same
      (4) grunt eslint --max-lint-warnings=0 # Bunch of warnings, "Aborted", non-zero return code
      (5) grunt eslint --max-lint-warnings=2000 # Bunch of warnings, "Done", 0 return code
      (6) grunt eslint --max-lint-warnings=100 # Bunch of warnings, "Aborted", non-zero return code
      

      In (4) and (6) it says something like "Warning: ESLint found too many warnings (maximum: 100) Use --force to continue."

      This will also work in plugins folders (in 3.9):

      pushd mod/forum
      (7) grunt eslint --max-lint-warnings=0 # Bunch of warnings, all them with forum files "Aborted", non-zero return code
      popd
      

      pushd mod/quiz
      (8) grunt eslint --max-lint-warnings=0 # Bunch of warnings, all them with quiz files "Aborted", non-zero return code
      popd
      

      This will work in 3.8:

      (9) pushd mod/forum/amd
      grunt eslint:amd --max-lint-warnings=0 # Bunch of warnings, all them with forum/amd files "Aborted", non-zero return code
      popd
      

      Show
      Run the following and observe output/result (numbers between parenthesis for easier reference, are not part of the command to execute): npm install grunt ignorefiles (1) grunt eslint # No errors and no warnings (2) grunt eslint --show-lint-warnings # Bunch of warnings, "Done", 0 return code (3) grunt eslint --max-lint-warnings=-1 # Same (4) grunt eslint --max-lint-warnings=0 # Bunch of warnings, "Aborted", non-zero return code (5) grunt eslint --max-lint-warnings=2000 # Bunch of warnings, "Done", 0 return code (6) grunt eslint --max-lint-warnings=100 # Bunch of warnings, "Aborted", non-zero return code In (4) and (6) it says something like "Warning: ESLint found too many warnings (maximum: 100) Use --force to continue." This will also work in plugins folders (in 3.9): pushd mod/forum (7) grunt eslint --max-lint-warnings=0 # Bunch of warnings, all them with forum files "Aborted", non-zero return code popd pushd mod/quiz (8) grunt eslint --max-lint-warnings=0 # Bunch of warnings, all them with quiz files "Aborted", non-zero return code popd This will work in 3.8: (9) pushd mod/forum/amd grunt eslint:amd --max-lint-warnings=0 # Bunch of warnings, all them with forum/amd files "Aborted", non-zero return code popd
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE
    • Pull 3.8 Branch:
    • Pull Master Branch:
      MDL-68323-master

      Description

      You can run

      grunt eslint --show-lint-warnings
      

      to see warnings, however it still returns 0 even if warnings are found. In moodle-plugin-ci we can parse output to count warnings but would be so much better to use grunt option "maxWarnings" https://www.npmjs.com/package/grunt-eslint

      Suggestion to add option:

      grunt eslint --max-lint-warnings=0
      

      See also discussion https://github.com/blackboard-open-source/moodle-plugin-ci/pull/89

        Attachments

          Activity

            People

            Assignee:
            marina Marina Glancy
            Reporter:
            marina Marina Glancy
            Peer reviewer:
            Paul Holden
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Janelle Barcega
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/May/20

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 45 minutes
                4h 45m