Skip to content

Instantly share code, notes, and snippets.

@pedrouid
Last active December 14, 2018 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrouid/f56984df96740799483b93e69ff1841d to your computer and use it in GitHub Desktop.
Save pedrouid/f56984df96740799483b93e69ff1841d to your computer and use it in GitHub Desktop.
Basic Eslint Config for React, React-Native and Node

ESLINT-CONFIG-REACT-APP (react.js)

  1. Install All Dev Dependencies
yarn add -D babel-eslint eslint eslint-config-react-app eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react

# OR

npm install --save-dev babel-eslint eslint eslint-config-react-app eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react
  1. Create .eslintrc file
{
  "extends": ["react-app"],
  "rules": {
    "jsx-a11y/href-no-hash": "off",
    "array-callback-return": "off"
  },
  "globals": {
    "document": true,
    "window": true,
  }
}

ESLINT-CONFIG-STANDARD (node.js)

  1. Install All Dev Dependencies
yarn add -D eslint eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard

# OR

npm install --save-dev eslint eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard
  1. Create .eslintrc file
{
  "extends": "standard"
}

ESLINT-CONFIG-AIRBNB-REACT-NATIVE (react-native.js)

  1. Install All Dev Dependencies
yarn add -D eslint babel-eslint eslint-config-airbnb-base eslint-plugin-react eslint-plugin-react-native eslint-plugin-import

# OR

npm install --save-dev eslint babel-eslint eslint-config-airbnb-base eslint-plugin-react eslint-plugin-react-native eslint-plugin-import
  1. Create .eslintrc file
{
  "parser": "babel-eslint",
  "plugins": [
    "react",
    "react-native"
  ],
  "parserOptions": {
    "ecmaFeatures": {
        "jsx": true,
        "modules": true
    }
  },
  "extends" : [
    "eslint:recommended",
    "plugin:react/recommended",
    "airbnb-base"
  ],
  "rules" : {
    "arrow-body-style": "warn",
    "class-methods-use-this": "off",
    "no-console": "off",
    "max-len": "off"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment