Skip to content

GraphQL ESLint integration with Typescript ESLint plugins #241

@ajotaos

Description

@ajotaos

I get an error when using my Typescript project already using @typescript-eslint when I try introducing the graphql-eslint steps from the README. This is in response to this request #215 (comment) @dotansimha

package.json

{
  "name": "graphql-eslint-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "apollo-server": "2.19.0",
    "graphql": "15.4.0"
  },
  "devDependencies": {
    "@graphql-eslint/eslint-plugin": "0.6.0",
    "@tsconfig/node14": "1.0.0",
    "@typescript-eslint/eslint-plugin": "4.11.0",
    "@typescript-eslint/parser": "4.11.0",
    "eslint": "7.16.0",
    "graphql-cli": "4.1.0",
    "graphql-config": "3.2.0",
    "typescript": "4.1.3"
  }
}

tsconfig.json

{
  "extends": "@tsconfig/node14/tsconfig.json",
  "compilerOptions": {
    "incremental": true,
    "rootDir": "src",
    "outDir": "dist",
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}

.graphqlrc.yml

---
schema: ./src/type-defs.ts
documents: null

.eslintrc.yml

---
root: true
env:
  es2020: true
  node: true
extends:
  - eslint:recommended
  - plugin:@typescript-eslint/recommended
parser: '@typescript-eslint/parser'
parserOptions:
  ecmaVersion: 11
  sourceType: module
  project: ./tsconfig.json
plugins:
  - '@typescript-eslint'
rules: {}
overrides:
  - files:
      - '*.tsx'
      - '*.ts'
      - '*.jsx'
      - '*.js'
    processor: '@graphql-eslint/graphql'
  - files:
      - '*.graphql'
    parser: '@graphql-eslint/eslint-plugin'
    plugins:
      - '@graphql-eslint'
    rules: {}

And the schema file src/type-defs.ts
Screen Shot 2020-12-21 at 3 44 09 PM

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions