Skip to content

How to lint both template strings in JavaScript files and the content of gql files #299

@harm-meijer

Description

@harm-meijer

With version 4.0.0 I try to lint deprecated field in a gql file and a template in a js file.

If I configure .eslintrc.js it with:

    'graphql/template-strings': [
      'error',
      {
        env: 'apollo',
        // validators: 'all',
        // eslint-disable-next-line global-require
        schemaJson: require('./graphql.schema.json'),
        tagName:'gql'
      },
    ],
    'graphql/no-deprecated-fields': [
      'error',
      {
        env: 'literal',
        // eslint-disable-next-line global-require
        schemaJson: require('./graphql.schema.json'),
      },
    ],

Then it will find a problem in gql files

me$ node ./node_modules/eslint/bin/eslint.js ./src/components/Cart.gql

/project/src/components/Cart.gql
  48:7  error  The field ShippingMethod.description is deprecated. Use localizedDescription  graphql/no-deprecated-fields

✖ 1 problem (1 error, 0 warnings)

But it won't detect it in javaScript files

When I configure .eslintrc.js with:

    'graphql/template-strings': [
      'error',
      {
        env: 'apollo',
        // validators: 'all',
        // eslint-disable-next-line global-require
        schemaJson: require('./graphql.schema.json'),
        tagName:'gql'
      },
    ],
    'graphql/no-deprecated-fields': [
      'error',
      {
        env: 'apollo',
        // eslint-disable-next-line global-require
        schemaJson: require('./graphql.schema.json'),
      },
    ],

It will find the error in the javaScript file but not in the gql files.

There may be some sort of combination of settings that I haven't tried yet that will do both but I am unable to find it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions