Last active
May 12, 2017 22:06
-
-
Save zerobias/7cbb26494eca595cf0279bf239dcd19f to your computer and use it in GitHub Desktop.
Modern eslint styleguide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"parser": "babel-eslint", | |
"parserOptions": { | |
"ecmaVersion": 8, | |
"ecmaFeatures": { | |
"experimentalObjectRestSpread": true | |
} | |
}, | |
"extends": [ | |
"eslint:recommended", | |
"plugin:flowtype/recommended" | |
], | |
"plugins": [ | |
"babel", | |
"promise", | |
"flowtype" | |
], | |
"settings": { | |
"flowtype": { | |
"onlyFilesWithFlowAnnotation": true | |
} | |
}, | |
"globals": { | |
"inject": true, | |
"setZeroTimeout": true | |
}, | |
"env": { | |
"node" : true, | |
"browser": false, | |
"worker": true, | |
"es6" : true, | |
"jasmine": false, | |
"jquery": false | |
}, | |
"rules": { | |
"flowtype/no-weak-types": "off", | |
// "strict" : "error", | |
"no-console" : "off", | |
"no-cond-assign" : "warn", | |
//Controversial rules | |
"no-unused-vars" : "warn", | |
"prefer-template" : "warn", | |
"no-nested-ternary" : "warn", | |
"no-unneeded-ternary" : "warn", | |
"no-underscore-dangle" : "warn", | |
"prefer-const" : "warn", | |
//On test | |
"no-extra-bind" : "error", | |
"no-case-declarations" : "error", | |
"no-useless-call" : "error", | |
"prefer-arrow-callback": [ | |
"error", | |
{ "allowNamedFunctions": true } | |
], | |
"object-shorthand" : [ | |
"error", | |
"always", | |
{ | |
"avoidQuotes": true, | |
"ignoreConstructors": true, | |
"avoidExplicitReturnArrows": true | |
} | |
], | |
"no-extra-parens" : "off", | |
"multiline-ternary" : "off", | |
//General | |
"arrow-body-style" : ["error", "as-needed"], | |
"no-var" : "error", | |
"no-duplicate-imports" : "off", | |
//Style rules. Freely varies according to projects | |
"quotes" : ["error", "single",{ | |
"allowTemplateLiterals": true, | |
"avoidEscape": true | |
}], | |
"max-len" : ["error", { | |
"code": 120, | |
"tabWidth":2, | |
"comments":220 //Separated max length for comments | |
}], | |
//Indents,whitespace settings | |
"key-spacing" : ["warn", { | |
"singleLine":{ | |
"beforeColon": false, | |
"afterColon": true | |
}, | |
"multiLine": { | |
"align": { | |
"beforeColon": false, | |
"afterColon": true, | |
"on": "colon", | |
"mode": "strict" | |
} | |
} | |
}], | |
"comma-spacing" : ["error", { | |
"before": false, | |
"after": true | |
}], | |
"block-spacing" : [ | |
"error", "always" | |
], | |
"object-curly-spacing" : [2, "always"], | |
"semi-spacing" : ["error", { | |
"before": false, | |
"after": true | |
}], | |
"indent" : [1,2,{ | |
"VariableDeclarator" : { | |
"var" : 2, | |
"let" : 2, | |
"const" : 3 | |
}, | |
"FunctionDeclaration": { | |
"parameters": "first" | |
}, | |
"FunctionExpression": { | |
"parameters": "first" | |
}, | |
"MemberExpression": 1, | |
"SwitchCase": 1, | |
"CallExpression": { | |
"arguments": "first" | |
}, | |
"ArrayExpression": 1, | |
"ObjectExpression": "first" | |
}], | |
"operator-linebreak": ["error", "after", { | |
"overrides": { | |
"?": "before", | |
":": "before" | |
} | |
}], | |
"newline-per-chained-call": ["error", { | |
"ignoreChainWithDepth": 2 | |
}], | |
"keyword-spacing": ["error", { "before": true }], | |
"space-unary-ops": ["error", { | |
"words": true, | |
"nonwords": false | |
}], | |
"no-whitespace-before-property": "error", | |
"generator-star-spacing": ["error", { | |
"before": false, | |
"after": true | |
}], | |
"arrow-spacing": ["error", { | |
"before": true, | |
"after": true | |
}], | |
"space-before-function-paren": ["error", "never"], | |
"rest-spread-spacing" : ["error", "never"], | |
//Strict best practices. No reason not to use this | |
"no-alert" : "error", | |
"no-bitwise" : 0, | |
"no-caller" : "error", | |
"no-global-assign" : "error", | |
"no-eval" : "error", | |
"no-implied-eval" : "error", | |
"no-proto" : "error", | |
"no-iterator" : "error", | |
"no-lone-blocks" : "error", | |
"no-self-compare" : "error", | |
"no-self-assign" : ["error", { | |
"props": true | |
}], | |
"no-invalid-regexp" : ["error", { | |
"allowConstructorFlags": ["u", "y"] | |
}], | |
"no-with" : "error", | |
"no-new-func" : "error", | |
"prefer-rest-params" : "error", | |
"prefer-spread" : "error", | |
//Unnecessary semicolon is an annoying visual clutter | |
"no-extra-semi" : "error", | |
"semi" : ["error", "never"] | |
} | |
} | |
// https://github.com/zerobias |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment