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

Update: include ruleId in error logs of crash (fixes #15037) #15053

merged 1 commit into from Sep 21, 2021


Copy link

@AriPerkkio AriPerkkio commented Sep 12, 2021

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:

Fixes #15037.

What changes did you make? (Give an overview)

Added error handling around rule listener calls in linter.js. The error handler wrapper is added when safe-emitter listeners are created. This seemed like a good place for it since we have ruleId easily available.

When extending caught error in try-catch of runRules calls it is checked whether ruleId is available. If it's found we include it in the error.message. This seems safe and low-risk.

There were already few test cases available which nicely covered this case. I did not add any new test cases for this reason.

Example error log generated by this implementation is found from issue description.

Is there anything you'd like reviewers to focus on?

Currently the ruleId is wrapped with quotes, as in Rule: "some-plugin/some-rule" / Rule: "some-builtin-rule". I'm not sure whether quotes should be removed.

Copy link

@linux-foundation-easycla linux-foundation-easycla bot commented Sep 12, 2021

CLA Signed

The committers are authorized under a signed CLA.

Copy link

@eslint-github-bot eslint-github-bot bot commented Sep 12, 2021

Hi @AriPerkkio!, thanks for the Pull Request

The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The issue reference must be formatted as follows:

    If the pull request addresses an issue, then the issue number should be mentioned at the end. If the commit doesn't completely fix the issue, then use (refs #1234) instead of (fixes #1234).

    Here are some good commit message summary examples:

    Build: Update Travis to only test Node 0.10 (refs #734)
    Fix: Semi rule incorrectly flagging extra semicolon (fixes #840)
    Upgrade: Esprima to 1.2, switch to using comment attachment (fixes #730)

Read more about contributing to ESLint here

@AriPerkkio AriPerkkio force-pushed the feature/rule-name-in-error-logs branch from 8253b43 to de4f783 Sep 12, 2021
nzakas approved these changes Sep 16, 2021
Copy link

@nzakas nzakas left a comment

LGTM. Just one suggestion for a better comment.

lib/linter/linter.js Outdated Show resolved Hide resolved
@AriPerkkio AriPerkkio force-pushed the feature/rule-name-in-error-logs branch from de4f783 to 9328a38 Sep 16, 2021
Copy link
Contributor Author

@AriPerkkio AriPerkkio commented Sep 16, 2021

Applied suggestion related to comment rephrasing. Thanks for review.

Copy link

@mdjermanovic mdjermanovic left a comment

LGTM, thanks!

@nzakas nzakas merged commit 0a1a850 into eslint:master Sep 21, 2021
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants