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

feat: Add JSONLanguage#visitorKeys #4

Merged
merged 2 commits into from
Jul 4, 2024
Merged

feat: Add JSONLanguage#visitorKeys #4

merged 2 commits into from
Jul 4, 2024

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Jul 3, 2024

Prerequisites checklist

What is the purpose of this pull request?

Added JSONLanguage#visitorKeys.

What changes did you make? (Give an overview)

  • Added JSONLanguage#visitorKeys
  • Added tests to ensure that JSONLanguage#visitorKeys is properly created

Related Issues

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

Please double check that the following line is included in the merge commit body to ensure we reset the package version number:

Release-As: 0.1.0

@@ -9,6 +9,7 @@

import { parse } from "@humanwhocodes/momoa";
import { JSONSourceCode } from "./json-source-code.js";
import { visitorKeys } from "@humanwhocodes/momoa";
Copy link
Member

Choose a reason for hiding this comment

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

We should update the dependency to ^3.1.1 in package.json.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is so weird. I know I updated this locally and tested, and this is the second time you've pointed out that the version hasn't been updated in package.json. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, it is updated in package.json but for some reason git isn't included it in the branch.

Copy link
Member

Choose a reason for hiding this comment

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

It works if 3.1.1 is locally installed, which in most cases would be the case after doing npm install since it's the latest in-range version, but to be sure it should be set in package.json.

@mdjermanovic
Copy link
Member

When I tested this, it turned out that things for which this matters don't actually work (e.g., selectors like Element + Element) since ESLint is always passing an empty ancestry to esquery because nodes don't have a parent property which NodeEventGenerator expects here. I'll investigate further how this can be fixed in ESLint.

@nzakas
Copy link
Member Author

nzakas commented Jul 4, 2024

Ah interesting. Yeah, I don't think we can assume every AST type will have a parent property, so we probably need to use the SourceCode#getAncestry() method.

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
Copy link
Member

Please double check that the following line is included in the merge commit body to ensure we reset the package version number:

Release-As: 0.1.0

For some reason, in this repo GitHub doesn't pull anything from the commits into the default commit body.

image

@mdjermanovic
Copy link
Member

It's probably because we have this setting:

image

Was it intentional? In other repos, we have this:

image

@nzakas
Copy link
Member Author

nzakas commented Jul 4, 2024

Not intentional. Need to add that to the new repo template.

@mdjermanovic
Copy link
Member

Merging now as this change is correct for this package. I am working on fixing NodeEventGenerator in eslint/eslint#18653.

@mdjermanovic mdjermanovic merged commit d8afca4 into main Jul 4, 2024
12 checks passed
@mdjermanovic mdjermanovic deleted the visitor-keys branch July 4, 2024 20:52
@github-actions github-actions bot mentioned this pull request Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants