Skip to content

Instantly share code, notes, and snippets.

@40thieves
Last active December 18, 2016 23:52
Show Gist options
  • Save 40thieves/8787486bdfc013578742 to your computer and use it in GitHub Desktop.
Save 40thieves/8787486bdfc013578742 to your computer and use it in GitHub Desktop.
{
"extends": "airbnb",
"parser": "babel-eslint",
"plugins": [
"babel"
],
"rules": {
// Tabs, just because
"indent": [2, "tab"],
// Semi colons will not save you from ASI!
"semi": [2, "never"],
// Allow var
"no-var": 0,
// Allow vars wherever (I know how hoisting works)
"vars-on-top": 0,
// Allow multiple var/let/const declarations in a function/block
"one-var": 0,
// Allow == (I know how coersion works)
"eqeqeq": 0,
// Enforce else on next line
"brace-style": [2, "stroustrup", {"allowSingleLine": true}],
// Allow returning in an else, stupid rule, would rather ENFORCE it not block it!
"no-else-return": 0,
// No using variables before defined; functions are exempt
"no-use-before-define": [2, "nofunc"],
// Turn off checking of commas at the end of arrays/objects
"comma-dangle": 0,
// Disable checking of spacing within object curly braces
"object-curly-spacing": 0,
// Enforce + at end of line (instead of start) when breaking over multiple lines
"operator-linebreak": [2, "after"],
// No more than 5 nested callbacks
"max-nested-callbacks": [2, 5],
// Enforce using `setState()` to mutate state
"react/no-direct-mutation-state": 2,
// Sorting of methods in component classes (
// Same as AirBnB config, except I prefer sub-render methods after main render
"react/sort-comp": [1, {
"order": [
"static-methods",
"lifecycle",
"/^on.+$/",
"/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/",
"everything-else",
"render",
"/^render.+$/"
],
"groups": {
"rendering": [
"render",
"/^render.+$/"
]
}
}]
},
"env": {
"browser": true,
"node": true,
},
}

eslint config

My preferred eslint config

Setup

  1. Set up eslint: npm install --save-dev eslint eslint-config-airbnb eslint-plugin-react
  2. Paste "lint": "eslint src test; exit 0" into package.json scripts (exit 0; prevents failures creating npm debug files)

Note: If React plugin is not required, change the "extends": "airbnb" to "extends": "airbnb/base"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment