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

Breaking: set `parent` of AST nodes before rules run (fixes #9122) #10014

Merged
merged 3 commits into from Mar 22, 2018

Conversation

Projects
3 participants
@not-an-aardvark
Member

not-an-aardvark commented Feb 23, 2018

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

[x] Add something to the core

What changes did you make? (Give an overview)

This updates linter to perform a traversal before rules run in order to set the parent property, and store all the traversed nodes in a queue to invoke the listeners afterwards. (See #9122 for more information.)

This was originally merged in 1488b51, but was reverted because it broke a couple of rules. The issue was re-accepted as a breaking change.

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

Nothing in particular

@platinumazure

Left a few suggestions, but this looks good to me.

*/
function getAncestors(node) {
if (node.parent) {
const parentAncestors = getAncestors(node.parent);

This comment has been minimized.

@platinumazure

platinumazure Feb 24, 2018

Member

Does this need to be recursive? I would love an iterative approach here, if that is feasible.

return {};
});
linter.verify("foo + bar", { rules: { checker: "error" } });

This comment has been minimized.

@platinumazure

platinumazure Feb 24, 2018

Member

Any way to verify that the rule creator is called, just as a sanity check?

not-an-aardvark added some commits Feb 23, 2018

@not-an-aardvark

This comment has been minimized.

Member

not-an-aardvark commented Feb 27, 2018

Updated to follow the suggestions.

@platinumazure

LGTM, thanks for implementing my suggestions.

@ilyavolodin

This comment has been minimized.

Member

ilyavolodin commented Feb 28, 2018

@not-an-aardvark Could you get before/after perf numbers for this change? If I understand it correctly, this requires an extra traversal through AST.

@not-an-aardvark

This comment has been minimized.

Member

not-an-aardvark commented Feb 28, 2018

There are some performance measurements in #9283 (comment) (from the first time we tried to apply this change). The change does not seem to have a significant performance impact.

This change does require iterating through the list of AST nodes an extra time, but it doesn't require another traversal of the tree, because the ordered list of nodes can be stored from the first traversal.

@not-an-aardvark not-an-aardvark merged commit 4eaebe5 into master Mar 22, 2018

5 checks passed

commit-message PR title follows commit message guidelines
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
licence/cla Contributor License Agreement is signed.
Details
release-monitor No patch release is pending
Details

v5.0.0 automation moved this from Ready to merge to Done Mar 22, 2018

@not-an-aardvark not-an-aardvark deleted the set-parent-early branch Mar 22, 2018

@eslint eslint bot locked and limited conversation to collaborators Sep 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.