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

Add ignore config to no-unused-fields rule #2281

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maciesielka
Copy link

Description

Changes here add a ignoredFieldSelectors configuration to the no-unused-fields rule such that some fields are allowed to be unused.

Fixes #2280

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link

changeset-bot bot commented May 3, 2024

🦋 Changeset detected

Latest commit: 0a2deaa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-eslint/eslint-plugin Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

type: 'object',
additionalProperties: false,
properties: {
ignoredFieldSelectors: {
Copy link
Author

@maciesielka maciesielka May 3, 2024

Choose a reason for hiding this comment

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

A few other names I considered here were:

  • allowedUnusedFields
  • allowedUnusedFieldSelectors
  • ignoredFields

I think ignoredFieldSelectors avoids some of the oxymoronic qualities of allowedUnused* and provides useful context that this configuration uses ESLint selectors, but am open to other options.

description: [
'Fields that will be ignored and are allowed to be unused.',
'',
'> These fields are defined by ESLint [`selectors`](https://eslint.org/docs/developer-guide/selectors). Paste or drop code into the editor in [ASTExplorer](https://astexplorer.net) and inspect the generated AST to compose your selector.',
Copy link
Author

@maciesielka maciesielka May 3, 2024

Choose a reason for hiding this comment

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

The naming-convention rule already makes use of ESLint selectors within configurations and it felt good to follow suit here. While this adds some clunkiness to the configuration (allowing an individual field looks like "FieldDefinition[name.value=field]" instead of "field"), there are benefits in that allowing fields with wildcards, based on their parent object, etc. are implicitly supported.

@maciesielka maciesielka marked this pull request as ready for review May 3, 2024 19:18
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.

Add ignore list to no-unused-fields rule
1 participant