-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Change Request: Deprecate and remove CodePath#currentSegments
#17457
Comments
CodePath#currentSegments
CodePath#currentSegments
I don't fully understand the problem. Do you have an implementation of
I believe this won't work for rules that need to know whether the currently traversed code is reachable, because |
I just pushed the updated code.
Good point. That seems easily solvable, though. We could introduce |
Thanks! I believe I understand the problem now, and I support the proposal to deprecate and remove
Sounds good to me. We could introduce |
Working on this. |
Here's an initial draft PR: To start, I just updated |
Oops! It looks like we lost track of this issue. What do we want to do here? This issue will auto-close in 7 days without an update. |
* feat!: Remove CodePath#currentSegments fixes #17457 * update migration guide * update related issue link --------- Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
ESLint version
HEAD
What problem do you want to solve?
Currently, the
CodePath
objects produced viaonCodePathStart
andonCodePathEnd
contain a mix of data and state. The most glaring example isCodePath#currentSegments
, which is actually a live array that is updated asCodePathAnalyzer
traverses the AST. (CodePath#currentSegments
actually is a passthrough to an underlyingCodePathState#currentSegments
property.)This is problematic with respect to the language plugins
SourceCode#traverse()
, which allows for a traversal to happen at any point and returns an array of steps to complete the traversal. The data available at each step should be the same as when there's an active traversal, but that doesn't happen with code path analysis due to theCodePath
objects exposing state information.So, exposing state information on
CodePath
objects is a blocker for the language plugins proposal.What do you think is the correct solution?
As best I can tell, the only problematic property is
CodePath#currentSegments
, which I think we should deprecate in the v8 timeframe and see if we can remove it in either v9 or v10. From a search through the codebase it seems that this is the primary property we are using off ofCodePath
objects, and it doesn't appear that other state information that changes during traversal is being exposed.Further, I doubt that there are many people using
CodePath#currentSegments
in the wild, so I think we can be pretty aggressive with removing it. I searched through some of the popular plugins and found zero instances of code path usage.The
currentSegments
property is easily duplicated inside of rules using this code:I'd argue that this is the most appropriate way to track current traversal state (from within a rule rather than inside of the core).
Participation
Additional comments
No response
The text was updated successfully, but these errors were encountered: