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

Tell grunt eslint to fail on warnings

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.7.6, 3.8.2, 3.9
    • 3.7.6, 3.8.3
    • JavaScript
    • MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • MDL-68323-master
    • 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

    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

            marina Marina Glancy
            marina Marina Glancy
            Paul Holden Paul Holden
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Janelle Barcega Janelle Barcega
            David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              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