Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[[FIX]] Limit "Too many Errors" (E043) to errors only #3562

Merged
merged 5 commits into from
Aug 19, 2021
Merged

[[FIX]] Limit "Too many Errors" (E043) to errors only #3562

merged 5 commits into from
Aug 19, 2021

Conversation

Ashesh3
Copy link
Contributor

@Ashesh3 Ashesh3 commented Aug 18, 2021

As mentioned in #3444 , E043 is triggered with "Too many Errors" even if there are just warnings in the checked code. This happens because the condition to trigger the said E043 error is:

if (JSHINT.errors.length >= state.option.maxerr)
      quit("E043", t);

Which clearly checks for the total count of all the messages in JSHINT.errors array, The issue is that, this array not only contains errors but also warnings and informative messages. This makes the E043 run even if there are no errors but only warnings exceeding the count defined in maxerr config.

This PR will modify the condition for running into E043, by ignoring all warnings and other messages and considering only errors.

This also updates the maxerr documentation to reflect the above change.

The tests changed to accommodate for the new behavior are:

  1. core.js:testRawOnError

    "Too many errors." is no longer being thrown because "Unnecessary semicolon" is a warning (W032)

  2. core.js:insideEval
    Similar case of "Too many errors." not triggering (maxerr is set to 1 here) as "eval can be harmful." is a warning (W061)

  3. parser.js:restOperatorWithoutIdentifier
    We run into "Too many errors." at 9:22 now instead of 8:30 because the warnings in between are no longer considered.

This PR closes #3444

Makes the E043 condition trigger only for errors and not warnings

Closes #3444
This updates maxerr doc to reflect that only errors are considered
Update testRawOnError, insideEval in core and restOperatorWithoutIdentifier in parser tests to reflect maxerr no longer counting in warnings.
@Ashesh3 Ashesh3 changed the title Limit "Too many Errors" (E043) to errors only [[FIX]] Limit "Too many Errors" (E043) to errors only Aug 19, 2021
Copy link
Member

@jugglinmike jugglinmike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch!

tests/unit/core.js Show resolved Hide resolved
src/jshint.js Outdated Show resolved Hide resolved
This modifies testRawOnError to make sure maxerr constrain is applied on errors.
This adds testRawOnWarning to make sure maxerr constrain does not count warnings.
Copy link
Member

@jugglinmike jugglinmike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; thank you!

@jugglinmike jugglinmike merged commit 4a681b9 into jshint:master Aug 19, 2021
Copy link

@BillyWildHigh BillyWildHigh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh pr checkout 3562

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

showing Error (E043) on "Too many errors", when those "Errors" are only warnings
3 participants