dimaMachina / graphql-eslint

ESLint parser, plugin and set rules for GraphQL (for schema and operations). Easily customizable with custom rules. Integrates with IDEs and modern GraphQL tools.
https://the-guild.dev/graphql/eslint
MIT License
779 stars 101 forks source link

require-id-when-available - options not being passed through correctly #2410

Open Stephen2 opened 1 week ago

Stephen2 commented 1 week ago

Issue workflow progress

Progress of the issue based on the Contributor Workflow


Describe the bug

The rule @graphql-eslint/require-id-when-available doesn't seem to receive it's options when passed in

To Reproduce Steps to reproduce the behavior:

Setup a rule like: '@graphql-eslint/require-id-when-available': ['error', { fieldName: 'foo' }],

The field looked for and reported on is still only id.

I got more logging by editing the minified dist file cjs/rules/require-id-when-available.js:

    const { fieldName = DEFAULT_ID_FIELD_NAME } = context.options[0] || {};

    console.log("options", {
      o: context.options,
      c: JSON.stringify(context),
    })

Which produces:

options {
  o: [],
  c: '{"id":"@graphql-eslint/require-id-when-available","options":[]}'
}

Options aren't passed through, so I can't specify alternative names than id to look for

Expected behavior

I can pass options through to the rule.

Environment:

Additional context