eslint-plugin-graphql icon indicating copy to clipboard operation
eslint-plugin-graphql copied to clipboard

Include/Exclude files? [Multiple schemas]

Open sarink opened this issue 4 years ago • 1 comments

I am trying to use this plugin to lint multiple schemas (that is, two different graphql services, not two schemas merged into one).

Currently, I do something like this

    'graphql/template-strings': [
      'error',
      {
        tagName: 'serviceOneGql',
        schemaJson: require('./src/service-one-schema.json'),
      },
      {
        tagName: 'serviceTwoGql',
        schemaJson: require('./src/service-two-schema.json'),
      },
    ],

but this has one major drawback: because the tagName has changed, we do not get any syntax highlighting, as most tools (vscode and prettier) are hard-coded to only look for gql and graphql tags, and this is not configurable.

A simple solution would be to tell eslint-plugin-graphql to include and/or exclude certain files, something like this (not real, just my dream):

    'graphql/template-strings': [
      'error',
      {
        schemaJson: require('./src/service-one-schema.json'),
        include: './src/service-one-queries/**/*.ts'
      },
      {
        schemaJson: require('./src/service-two-schema.json'),
        include: './src/service-two-queries/**/*.ts'
      },
    ],

Is something like this possible?

sarink avatar Mar 19 '20 23:03 sarink

+1 on this - I'm facing the exact same scenario in a monorepo with multiple projects and include exclude tags would allow me to lint two separate schemas without using custom tag names

Michael-Hering avatar Oct 25 '21 16:10 Michael-Hering