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

unused-fields: fake positive on different scopes #150

Open
caiotoon opened this issue Jul 23, 2024 · 0 comments
Open

unused-fields: fake positive on different scopes #150

caiotoon opened this issue Jul 23, 2024 · 0 comments

Comments

@caiotoon
Copy link

The rule is currently matching any occurrences in the entire file, even when usage is in different functions. The following invalid test fails:

    {
      code: `
        function method1() {
          graphql\`fragment Test2 on SomeEntity {
            unused1
          }\`;
          const { unused1 } = node;
          return unused1;
        }
        function method2() {
          graphql\`fragment Test on Page {
            unused1
            used1
          }\`;
          var { used1 } = node;
        }
      `,
      errors: [
        {
          message: unusedFieldsWarning('unused1'),
          line: 7
        }
      ]
    }

The message is currently clear and matches the behaviour, so I believe this might have been intentional given the difficulty of trying to maintain scope and context for the validation.

[...] this file does not seem to use it directly. [...]

Opening this one to track the possibility of adding a new rule to validate considering the scope.

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

No branches or pull requests

1 participant