Skip to content

feat: Add JSONLanguage#visitorKeys#4

Merged
mdjermanovic merged 2 commits intomainfrom
visitor-keys
Jul 4, 2024
Merged

feat: Add JSONLanguage#visitorKeys#4
mdjermanovic merged 2 commits intomainfrom
visitor-keys

Conversation

@nzakas
Copy link
Copy Markdown
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


import { parse } from "@humanwhocodes/momoa";
import { JSONSourceCode } from "./json-source-code.js";
import { visitorKeys } from "@humanwhocodes/momoa";
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

It's probably because we have this setting:

image

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

image

@nzakas
Copy link
Copy Markdown
Member Author

nzakas commented Jul 4, 2024

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

@mdjermanovic
Copy link
Copy Markdown
Member

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

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