[unused-fields] Add ignore fields option #94
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
I'm trying to enable this rule in my codebase but a few patterns provide a lot of false positives. An example is when using from React Native, it expects nodes to have an id prop but this is only accessed internally in the FlatList code and not in the current module. Although it is probably possible to use fragments here I think adding more flexibility to the rule by specifying ignored fields can help adopting it.
I was wondering if we should include
__typename
as part of the default ignoredFields and remove the hardcoded check or keep it like this. The only difference it would make is if you specify ignoreFields and relied on__typename
being ignored then you'd have to add it in yourignoreFields
list.Test plan
Tested on a large relay codebase and added tests.