Skip to content

Instantly share code, notes, and snippets.

@shalkam
Last active November 1, 2018 06:55
Show Gist options
  • Save shalkam/e753ffcf335cd259ed0e5e4942284f5e to your computer and use it in GitHub Desktop.
Save shalkam/e753ffcf335cd259ed0e5e4942284f5e to your computer and use it in GitHub Desktop.
Eslint setup for React
node_modules/
build
{
"extends": ["airbnb", "prettier", "prettier/react"],
"plugins": [
"import",
"react",
"prettier"
],
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"jsx-a11y/href-no-hash": "off",
"react/forbid-prop-types": "off",
"import/no-extraneous-dependencies": "off",
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"prettier/prettier": "error"
},
"settings": {
"import/resolver": {
"node": {
"moduleDirectory": ["node_modules", "src"]
}
}
}
}
{
"singleQuote": true
}

Steps

install packages

yarn add babel-eslint eslint eslint-config-airbnb eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react prettier --dev

download config files

wget https://gist.github.com/shalkam/e753ffcf335cd259ed0e5e4942284f5e/raw/4263e5750c1e74d8546d10b3bc70cba85b411cb5/.eslintignore https://gist.github.com/shalkam/e753ffcf335cd259ed0e5e4942284f5e/raw/4263e5750c1e74d8546d10b3bc70cba85b411cb5/.eslintrc https://gist.github.com/shalkam/e753ffcf335cd259ed0e5e4942284f5e/raw/4263e5750c1e74d8546d10b3bc70cba85b411cb5/.prettierrc
yarn add babel-eslint eslint eslint-config-airbnb eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react prettier --dev
"devDependencies": {
"babel-eslint": "^8.2.1",
"eslint": "^4.17.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.6.1",
"prettier": "^1.10.2"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment