9

I'm using create-react-app and have configured my project for eslint. Below is my .eslintrc file.

{
  "root": true,
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint",
    "react-hooks"
  ],
  "extends": [
    "plugin:prettier/recommended",
    "airbnb-typescript-prettier",
    "prettier",
    "plugin:import/typescript"
  ],
  "parserOptions": {
    "project": "./tsconfig.json"
  },
  "rules": {
    // Make prettier code formatting suggestions more verbose.
    "prettier/prettier": [
      "warn"
    ],
    "camelcase": "warn",
    "no-console": "error",
    "no-prototype-builtins": "warn",
    "arrow-body-style": "warn",
    "prefer-arrow-callback": "warn",
    "jsx-a11y/click-events-have-key-events": "warn",
    "jsx-a11y/no-noninteractive-element-interactions": "warn",
    // Disable <Fragment> => <> replacement. Feel free to change
    "react/jsx-fragments": "off",
    "react/destructuring-assignment": "warn",
    "react/no-unused-prop-types": "warn",
    //TODO: Remove this rule later
    "react/jsx-props-no-spreading": "off",
    "react/require-default-props": 0,
    "react-hooks/exhaustive-deps": "warn",
    // Disable prefer default export
    "import/prefer-default-export": "off",
    "no-underscore-dangle": "off",
    "@typescript-eslint/camelcase": 0,
    "@typescript-eslint/no-empty-function": "warn",
    "@typescript-eslint/ban-ts-comment": "warn",
    "@typescript-eslint/ban-types": "warn",
    "@typescript-eslint/naming-convention": "warn",
    "@typescript-eslint/no-empty-interface": "warn",
    "@typescript-eslint/no-inferrable-types": "warn",
    "import/no-extraneous-dependencies": [
      "error",
      {
        "devDependencies": true
      }
    ]
  }
}

Problem is, during build phase it is taking a lot of memory. Due to this I'm unable to use a docker with memory of 8Gb. Is there any way I can disable eslint only during build phase? I need these rules during development but don't want them to impact my build phase. Can somebody please help? Thanks in advance.

Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129
Mahesh
  • 1,427
  • 2
  • 19
  • 42

1 Answers1

15

You can do it by adding DISABLE_ESLINT_PLUGIN=true to the "build" in the "scripts" part in your package.json:

{
  "scripts": {
    "start": "react-scripts start",
    "build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",
    "test": "react-scripts test"
  }
}
Silidrone
  • 1,471
  • 4
  • 20
  • 35