Skip to content

Conversation

@constgen
Copy link

We don't need to analyze strings that play a role of property names

index.js Outdated
const { value } = node;
const { value, parent } = node;
const nodeIsIdentifier = parent.type === 'JSONProperty' && parent.key === node
if (nodeIsIdentifier) return;

Choose a reason for hiding this comment

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

If you want to exclude the JavaScript property name from the check as well, you'll need to make the same changes to the JavaScript check method.

Copy link
Owner

Choose a reason for hiding this comment

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

Thank you for the help @ota-meshi! @constgen if you'd like to include that check in the PR, let me know.

Copy link
Author

Choose a reason for hiding this comment

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

Now I realized. These two JS expressions produce different AST nodes:

  1. { name: 'value' } - name is Identifier type
  2. { 'name': 'value' } - 'name' is Literal type

So I am going to add additional checks for JS too

Copy link
Author

Choose a reason for hiding this comment

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

Excluded property names from parsing and added a test for this. But tests are not run automatically on any CI/CD

@nickdeis
Copy link
Owner

nickdeis commented Mar 15, 2021

Thank you @constgen for making this PR. I think I might later on refactor this so that I can use this in conjunction with ignoreIdentifiers. Let me know if you need any help with testing.

@constgen
Copy link
Author

ignorePropertyNames will be more suitable option name for this feature. If you have no time may be I can add it if we really need it. What should be its default value?

@nickdeis
Copy link
Owner

Hey @constgen,
Since identifiers and property names are different, I think there is room for both. Do you want to implement that in a separate PR or this one? Either way, fantastic work and thank you so much! Please let me know if you want to merge this and I'll be sure to publish it this weekend.
Best,
Nick

@constgen
Copy link
Author

I am going to do this in this PR. Just give me your opinion on the description of the options names and default values

@nickdeis
Copy link
Owner

Hey @constgen ,
Let's create a separate option called ignoreProperties and give it the default value of an empty array. I want to keep things as backward compatible as possible, and creating a new property allows us to do that. Let me know if you need any help with implementing this. I'll keep this PR open until you are ready to merge. Thank you so much for all the work you are putting into this, it means quite a lot!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants