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

Ignoring a literal file with eslint-disable

Open pleunv opened this issue 7 years ago • 5 comments
trafficstars

Hey guys, thanks for this plugin! Probably going to make our life a lot easier :)

I'm having a couple problematic queries that I cannot immediately change in order to be validated (mostly unions with field type conflicts behind the same alias - query executes, but the validator is not a big fan), and I noticed that # eslint-disable does not seem to have any effect right now. Would it be feasible to add support for this, or is there currently a workaround?

pleunv avatar Jan 16 '18 10:01 pleunv

It would also be useful to do this on a per-line basis. Would this be difficult?

const query = gql`
  {
    whatever {
       field # eslint-disable-line
    }
  }
`

bdrobinson avatar Jul 15 '19 10:07 bdrobinson

In case it helps to unblock anyone, I just tested the following locally on [email protected].

This does not work:

// eslint-disable-next-line graphql/no-deprecated-fields
const query = gql`
  {
    whatever {
       deprecatedField
    }
  }
`;

This works:

/* eslint-disable graphql/no-deprecated-fields */
const query = gql`
  {
    whatever {
       deprecatedField
    }
  }
`;
/* eslint-enable graphql/no-deprecated-fields */

Unfortunately this means that until one can migrate away from the deprecated field, any other fields within this query which are subsequently deprecated will not be caught by the linter.

arkwright avatar Aug 24 '19 17:08 arkwright

Running into the same issue with # import and fragments. Specifically, the graphql/template-strings rule is complaining about unused variables. The variables are used in the fragments.

#import "./serverOnlyFragment.graphql"
#import "./sharedFragment.graphql"

# eslint-disable graphql/template-strings
# eslint-disable-next-line graphql/template-strings
query HomePageServer(    # eslint-disable-line graphql/template-strings
    # eslint-disable-next-line graphql/template-strings
    $isAuthenticated: Boolean!     # eslint-disable-line graphql/template-strings
    $gpid: Long!    # eslint-disable-line graphql/template-strings
    $latitude: Float!    # eslint-disable-line graphql/template-strings
    $longitude: Float!    # eslint-disable-line graphql/template-strings
    $tld: String!    # eslint-disable-line graphql/template-strings
) {
    ...ServerOnlyFragment
    ...SharedFragment
}

Expected # eslint-disable graphql/template-strings, # eslint-disable-line graphql/template-strings, or # eslint-disable-next-line graphql/template-strings to disable the rule, but it doesn't.

Would be stoked to get support for eslint-disable functionality, or of exhaustive checking of imports for rules

cosmonot1 avatar Dec 12 '19 17:12 cosmonot1

Also having the same is as @cosmonot1

paul-vd avatar Nov 05 '21 13:11 paul-vd

+1 for per-line disabling

margintop5px avatar May 23 '24 14:05 margintop5px