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

Chore: refactor reporting logic (refs #9161) #9168

Merged
merged 5 commits into from Aug 30, 2017

Conversation

not-an-aardvark
Copy link
Member

@not-an-aardvark not-an-aardvark commented Aug 27, 2017

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

[x] Other, please explain:

What changes did you make? (Give an overview)

This refactors some of the logic around RuleContext, as described in #9161.

  • Rule contexts no longer have access to the current Linter instance, and the rule ID and severity are added to the report object from a closure. This avoids a circular dependency between modules. It also prevents rules from impersonating or tampering with other rules by using something like context._linter.report("some-other-rule", 2, node, "some message").
  • The conversion from context.report arguments to Linter problem descriptors now happens in one place (report-translator). Previously, the logic was spread out between RuleContext and various places in Linter, which made it confusing to follow and has caused some bugs in the past. That logic has been refactored now and should be easier to follow.
  • Linter#report is no longer accessible from the public API, because it no longer exists.

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

Should this be considered a breaking change? I'm pretty sure it doesn't break any documented APIs, but it will break anyone who was relying on undocumented behavior, e.g. calling Linter#report directly for some reason. We have a very explicit warning that only the documented APIs are public, so I personally don't think this is breaking.

@not-an-aardvark not-an-aardvark added the chore This change is not user-facing label Aug 27, 2017
@eslintbot
Copy link

LGTM

@mention-bot
Copy link

@not-an-aardvark, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nzakas, @platinumazure and @mysticatea to be potential reviewers.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

Left a few comments where I couldn't quite follow what I was going on. At first glance they seem like mistakes, but I might be missing something.

loc: location,
message,
*fix() {
yield { range: [1, 2], text: "foo" };
Copy link
Member

Choose a reason for hiding this comment

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

Confused about this test. Seems like it might be using the same setup as the previous test, but the title of this test implies there should only be one fix.

const reportDescriptor = {
node,
message,
fix: () => [{ range: [-1, 3], text: "\uFEFFfoo" }, { range: [4, 5], text: "x" }]
Copy link
Member

Choose a reason for hiding this comment

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

Confused about this test. The title mentions removing the BOM, but I see the BOM being preserved (I think).

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

Copy link
Member

@platinumazure platinumazure 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 fixing and for doing this awesome refactor. LGTM!

While investigating the performance impact of this change, I tried modifying the `createReportTranslator` API, but I forgot to change the JSDoc comment back after reverting that modification.
@eslintbot
Copy link

LGTM

@not-an-aardvark
Copy link
Member Author

Thanks for reviewing!

@not-an-aardvark not-an-aardvark merged commit d672aef into master Aug 30, 2017
@not-an-aardvark not-an-aardvark deleted the reporting-refactor branch August 30, 2017 02:02
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 27, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion chore This change is not user-facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants