Search code examples
eslintgatsbyeslintrc

Eslint ProjectNotFoundError


I am getting following when running eslint in a Gatsby project

Oops! Something went wrong! :(

ESLint: 7.32.0

[ProjectNotFoundError: File '/home/path_to_project/somefile.ts' doesn't match any project] {
  name: 'ProjectNotFoundError',
  message: "File '/home/path_to_project/somefile.ts' doesn't match any project"
}

My .eslintrc

{
  "extends": [
    "react-app",
    "plugin:jsx-a11y/recommended",
    "prettier",
    "plugin:tailwindcss/recommended"
    // "airbnb"
  ],
  "plugins": ["jsx-a11y"],
  "rules": {
    "no-restricted-imports": [
      "error",
      {
        "patterns": ["@/features/*/*"]
      }
    ],
    "tailwindcss/classnames-order": "error",
    "tailwindcss/no-custom-classname": "error"
  },
  "settings": {
    "tailwindcss": {
      "groupByResponsive": true
    }
  },
  "overrides": [
    {
      "files": ["*.ts", "*.tsx"],
      "processor": "@graphql-eslint/graphql",
      "parser": "@typescript-eslint/parser",
      "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended"
      ],
      "env": {
        "es6": true
      }
    },
    {
      "files": ["*.graphql"],
      "parser": "@graphql-eslint/eslint-plugin",
      "plugins": ["@graphql-eslint"],
      "rules": {
        "@graphql-eslint/no-anonymous-operations": "error",
        "@graphql-eslint/naming-convention": [
          "error",
          {
            "OperationDefinition": {
              "style": "PascalCase",
              "forbiddenPrefixes": ["Query", "Mutation", "Subscription", "Get"],
              "forbiddenSuffixes": ["Query", "Mutation", "Subscription"]
            }
          }
        ]
      }
    }
  ]
}

.eslintignore

node_modules/
.cache/
public/
.idea/
yarn-error.log
.yarn/

Commenting out the following section in .eslintrc fix the issue, but I want to keep that section, things used to work fine with that section before. No clue what's wrong, since the error message provided by ESLint is pretty vague.

  {
      "files": ["*.ts", "*.tsx"],
      "processor": "@graphql-eslint/graphql",
      "parser": "@typescript-eslint/parser",
      "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended"
      ],
      "env": {
        "es6": true
      }
    },

Update

Problem seems to be due to following, since commenting it out fix the error.

"processor": "@graphql-eslint/graphql",

Solution

  • I was earlier using Gatsby's GraphQL Typegen disabled due to it buggy nature (rebuild loop and .cache errors) by commenting out graphql.config.js and removing graphqlTypegen: true, from gatsby-config.ts

    According to graphql-eslint

    If you are defining GraphQL schema or GraphQL operations in code files, you'll want to define an additional override to extend the functionality of this plugin to the schema and operations in those files.

    {
      "overrides": [
    +   {
    +     "files": ["*.js"],
    +     "processor": "@graphql-eslint/graphql"
    +   },
       ...
    }
    

    It seems, disabling GraphQL Typegen result in mentioned error in "processor": "@graphql-eslint/graphql" of eslint override.