Skip to content

Instantly share code, notes, and snippets.

@anthify
Last active May 3, 2019 08:11
Show Gist options
  • Save anthify/5f687a7ffd05111b9795493b2ffaea11 to your computer and use it in GitHub Desktop.
Save anthify/5f687a7ffd05111b9795493b2ffaea11 to your computer and use it in GitHub Desktop.
React web app lint setup
{
"extends": ["airbnb", "prettier", "prettier/react"],
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": true
},
"env": {
"browser": true,
"node": true,
"jest": true
},
"rules": {
"import/no-unresolved": "error",
"import/no-extraneous-dependencies": "off",
"react/jsx-filename-extension": [
"error",
{ "extensions": [".js", ".jsx"] }
]
},
"plugins": ["react"],
"settings": {
"import/resolver": {
"node": {
"moduleDirectory": ["node_modules", "src"]
}
}
}
}
yarn add eslint-config-airbnb eslint-config-prettier eslint-import-resolver-webpack eslint-plugin-import eslint-plugin-jest eslint-plugin-jsx-a11y eslint-plugin-react husky lint-staged prettier --dev
// Add to your exsiting package.json as this alone is invalid.
// Also add eslint to your devDependencies if not already installed
{
"devDependencies": {
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.2.0",
"eslint-formatter-pretty": "^2.1.1",
"eslint-import-resolver-webpack": "^0.11.1",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-jest": "^22.5.1",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"husky": "^2.2.0",
"lint-staged": "^8.1.5",
"prettier": "^1.17.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,md,css,html}": [
"eslint --cache --format=node_modules/eslint-formatter-pretty",
"prettier --trailing-comma es5 --single-quote --write",
"git add"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment