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
795 stars 103 forks source link

`naming-convention` rule `FieldDefinition.ignorePattern` config still checking underscores `_` #1719

Open DanielEscorciaOrtiz opened 1 year ago

DanielEscorciaOrtiz commented 1 year ago

Issue workflow progress

Progress of the issue based on the Contributor Workflow


Describe the bug

To Reproduce

With a schema like this:

# src/schema.graphql

type SomeType {
  _someField_: Boolean!
}

type Query {
  someType: SomeType
}

type Mutation {
  mutType: SomeType
}

And a .eslintrc like this:

module.exports = {
   [...]
    parserOptions: {
        schema: "src/schema.graphql"
    },
    rules: {
        '@graphql-eslint/naming-convention': [
            'error', {
                'FieldDefinition[parent.name.value=SomeType]': {
                    ignorePattern: ".*someField.*"
                }
            }
        ],
    }
}

I'm still receiving this errors:

<dir>/src/schema.graphql
  4:3  error  Leading underscores are not allowed   @graphql-eslint/naming-convention
  4:3  error  Trailing underscores are not allowed  @graphql-eslint/naming-convention

Expected behavior

It should ignore underscores if it matches the pattern, as described in the docs

Environment:

Additional context

dimaMachina commented 1 year ago

this is tricky to fix because allowLeadingUnderscore and allowLeadingUnderscore are global options that match Name nodes https://github.com/B2o5T/graphql-eslint/blob/819c046c2a459d2e601a7c58823b3fc4862ece0e/packages/plugin/src/rules/naming-convention.ts#L426-L435