-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat: add JSXSpreadChild
and tool to build keys out of AST definitions
#36
Conversation
I'm not clear on why the CLA is failing as GitHub shows my user next to the commit. |
Double check that the email associated with the commit is one associated with your GitHub user account. |
Also: 1. Removes `ExperimentalRestProperty`, `ExperimentalSpreadProperty` 2. Adds `JSXSpreadChild`
ba5237d
to
8739546
Compare
Ah, had had an ESLint error and ESLint Jenkins had been the actual author. Thanks! |
Ok, so to break down the next question of my OP perhaps a little more digestibly: Based on the previous pattern of our keys, I understand that we do not want I didn't settle definitively on one or the other. I can go solely with either of a few approaches of determining how these properties should be ignored and would like to know which one or ones you all think is best for me to use:
Currently, the results would be the same. but it seems, all things being equal, that it may be more conceptually appealing to use one consistent approach. No. 1 and 2 seems they would be riskier if these names might legitimately need traversal in some new interface. Although no. 3 seems the most satisfying to me personally as it confines the exclusions not by property name but by interfaces considered not to be traversed, no. 2 seems most consistent with our current approach, given that But even if choosing no. 3, I wonder whether no. 2 should be implemented so that our |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks! Just want another set of eyes before merging.
Oops, forgot this was a WIP. Whenever you’re ready, feel free to submit for approval. |
@nzakas The PR is indeed close to being ready (mostly just need some tests), but really feel I need a decision on #36 (comment) first. To summarize that admittedly long comment, we need to decide between the approaches to:
I supported a mix of algorithms in the event we needed them, but I think as per that comment, we probably only want one (I guess the second one). Once I know which algorithm to use, I can adapt the code and add tests. |
I think the second one makes sense 👍 |
Also: - test: improve coverage
Ok, it should now be ready. |
How should we tag this change? It shouldn't be just a
|
Might the |
This is a separate package, so it might be correct to do a major version bump when a change seems potentially breaking for packages that depend on it even if the change isn't breaking for ESLint. As for ESLint, I think everything related to comments can be classified as a fix. They're objects with a
|
Ah, there's the missing ingredient, thanks! I had been so focused on the AST, I neglected to dig into the traversal routine to discover the exact specification of the items to be iterated.
Ok, in that case, and based on the information above, whether or not we add the excluded keys later to My existing routine should help, but will take some time to add this detection.
Ok. I guess we need a new issue then, especially since I don't actually need to add to
Yeah, I was wondering that re:
Ok, sure. As per the above, I should be able to get the algorithm to detect the non-traversability of |
b54590d
to
5a92ab0
Compare
Ok, the detection should now be ready without any breaking changes. But |
@mdjermanovic can you take a look? |
lib/index.js
Outdated
|
||
// "type", | ||
|
||
// `BaseNodeWithoutComments` | ||
// "range", | ||
|
||
// `SourceLocation` | ||
// "loc", | ||
|
||
// `Comment` | ||
// "comments", | ||
// "innerComments", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove these lines? We usually avoid having commented-out code in the codebase unless it is associated with a TODO action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I had thought these were going to be removed in a future version, so should I add a comment to do so? File an issue? Is there any particular approach for planning ahead with to-dos to occur before breaking changes?
eslint-plugin-unicorn
has a truly excellent expiring-todo-comments
rule which can be tied to version or dependency changes which will cause linting to fail unless applied. I might recommend unicorn for eslint-config-eslint
anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best to discuss this in an issue first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I had thought these were going to be removed in a future version, so should I add a comment to do so? File an issue? Is there any particular approach for planning ahead with to-dos to occur before breaking changes?
We are using GitHub issues to track planned features and bug fixes. We are rarely using TODO comments, mostly for code parts that we think should be refactored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for the feedback. Added #38 and removed the comments.
And FWIW, re: Unicorn, I filed eslint/eslint#15731 . Even when not heavily using to-dos in code, having those conditional to-dos can really help ensure that version-dependent to-dos don't get lost.
JSXSpreadChild
and tool to build keys out of AST definitions
Co-authored-by: Milos Djermanovic <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for all the work on this.
Refiling with modifications from original PR #35.
This PR adds:
type
rather than name), the following are currently still changed:Breaking Change: RemovesExperimentalRestProperty
,ExperimentalSpreadProperty
JSXSpreadChild
Here are the items on which I think I in particular still need feedback or action:
Whether to force-add the
Experimental*
properties or just let them be dropped as per the above (and confirm thatJSXSpreadChild
should indeed be added).I currently allow two approaches in the builder toward restricting output: suppressing by a given key name or by making an interface non-traverseable. For example,
loc
,comments
,innerComments
, andoperator
are currently added to the properties suppressed bygetKeys
(parent
,leadingComments
, andtrailingComments
) in order to ensure they continue not to appear in the listing. (This also raises another question. See next item.) I could alternatively suppress theSourceLocation
,Comment
, and*Operator
types from being treated as traverseable (and thus properties of these types would not be added as keys). But even if it doesn't matter the approach, I still need to know if my suppressing those properties was suitable.Besides the impact on keys, the Nodes that are added are affected. I'm currently not including
SourceLocation
(it is not listed as an exportable interface, doesn't have a type, and was not included previously), nor am I includingLine
andBlock
type comment Nodes despite their having exportable AST available, as this had not previously been included (and they don't seem to be accepted by ESTree), though I can do so if desired. See also discussion below on comments.getKeys
needs to suppress the above-mentioned keys also, and also suppresstype
since the Node argument supplied by the user presumably may have atype
on it.While it would seem to me from my limited perspective that it would be better to err on the side of including the comment info, as I imagine people might have a desire to traverse or query this separately, if that were to be the case, it raises the ESTree question for me of why non-block nodes could not have comment properties; in TypeScript, for example, such inline comments are often used for casting. Similarly, I would think it would be ideal to have a standard for JSDoc-block attachment even if as a mere optional extension to the standard, e.g., an optional
jsdoc
property associated withJSDocBlock
,JSDocTag
, the various types, etc. (as we do with https://github.com/es-joy/jsdoccomment/blob/main/src/commentParserToESTree.js#L237-L242 and https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/blob/34bd2a6e72af6b16b47e4e1a4391142035917e89/src/visitorKeys.ts#L7-L35 or as it appears TypeScript may be doing: https://github.com/typescript-eslint/typescript-eslint/blob/550b61ee1096113b234bf035dd267ba385809961/packages/typescript-estree/src/ts-estree/ts-nodes.ts#L184-L208 ). I could file this at ESTree, but mentioning here as the PR raises the question.