'Heroku failed to load config "google" to extend from. Referenced from: /app/.eslintrc.json

Locally, my project works without errors, but after I deployed the project on Heroku, the following error occurred:

failed to load config "google"

Again, everything is fine locally. Here is eslintrc.json:

{
  "env": {
    "browser": true,
    "es2021": true
  },
  "extends": ["eslint:recommended", "google"],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": 12,
    "sourceType": "module"
  },
  "plugins": ["react", "@typescript-eslint"],
  "rules": {
    "camelcase": "off",
    "object-curly-spacing": "off",
    "linebreak-style": 0,
    "isolatedModules": 0,
    "indent": "off",
    "require-jsdoc": "off",
    "max-len": "off",
    "no-unused-vars": "off",
    "no-invalid-this": "warn",
    "operator-linebreak": "off"
  },
  "globals": {
    "google": "readonly",
    "process": "readonly",
    "arrow-parens": "off"
  }
}


Solution 1:[1]

You usually don't need ESlint in production. It's a good practice to verify your code with a linter while in a development mode. Regarding production, in pretty much all the cases, it makes sense to disable it.

That's why even the official documentation of ESlint recommends installing it with the --dev flag (https://eslint.org/docs/user-guide/getting-started):

yarn add eslint --dev

In that case, ESlint will be added to the "devDependencies" of your package.json.

Now, let's get back to the error. I guess, you deploy your app through:

yarn install --production
yarn build

(or npm analogy of these commands)

It doesn't matter if it's run on a host or in a docker container. The point is that before running these commands, you need to set the environment variable DISABLE_ESLINT_PLUGIN to true.

Try

export DISABLE_ESLINT_PLUGIN=true
yarn install --production
yarn build

if you deploy your app right on the host.

Or do this:

ENV DISABLE_ESLINT_PLUGIN true
RUN ["yarn", "install", "--production"]
RUN ["yarn", "build"]

if your app is dockerised.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pyloolex