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
merged 1 commit into from Sep 21, 2021

Conversation

AriPerkkio
Copy link
Contributor

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.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 12, 2021

CLA Signed

The committers are authorized under a signed CLA.

@eslint-github-bot eslint-github-bot bot added the triage An ESLint team member will look at this issue soon label Sep 12, 2021
@eslint-github-bot
Copy link

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 Compare September 12, 2021 08:06
@nzakas nzakas added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint and removed triage An ESLint team member will look at this issue soon labels Sep 16, 2021
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

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 Compare September 16, 2021 15:57
@AriPerkkio
Copy link
Contributor Author

Applied suggestion related to comment rephrasing. Thanks for review.

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic added the accepted There is consensus among the team that this change meets the criteria for inclusion label Sep 20, 2021
@nzakas nzakas merged commit 0a1a850 into eslint:master Sep 21, 2021
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Mar 21, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change Request: Include ruleId in error message of crash
3 participants