-
Notifications
You must be signed in to change notification settings - Fork 12
/
.eslintrc.js
98 lines (85 loc) · 4.86 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
module.exports = {
"root": true,
"plugins": [
"sort-imports-es6-autofix",
"@typescript-eslint",
"jest"
],
"env": {
"es6": true,
"commonjs": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2017
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"globals": {
"process": true // since gulp has envify
},
"rules": {
// basics
"@typescript-eslint/indent": [ "error", 2, { // indentation should be 2 spaces
"flatTernaryExpressions": true, // ternary should be performed in flat
"MemberExpression": 1 // member chain should be performed with an indent
} ], // it forces 2 spaces indentation
"linebreak-style": [ "error", "unix" ], // fuck you, CRLF
"quotes": [ "error", "single" ], // quotes must be single
"eqeqeq": [ "error", "smart" ], // fuck you, `==`
"max-len": [ "error", { // don't be too long, code
"code": 100,
"ignoreComments": true, // comments are okay
"ignoreStrings": true, // strings are okay
"ignoreTemplateLiterals": true, // templates are also okay
"ignoreRegExpLiterals": true, // regexs are also okay too
} ],
"sort-imports-es6-autofix/sort-imports-es6": [ "error" ], // imports have to be ordered
"eol-last": [ "error", "always" ], // eof newline is cool
// variables
"@typescript-eslint/no-unused-vars": [ "warn", { "argsIgnorePattern": "^_" } ], // draw yellow line under unused vars
// "no-undef": [ "warn" ], // draws yellow line under undefined vars // it doesn't work on typescript sometimes
"no-var": [ "error" ], // fuck you, var
"prefer-const": [ "error" ], // const is better than let
// omittables
"semi": [ "error", "always" ], // semicolon is required
"curly": [ "error" ], // it kills `if (foo) bar++;`
"arrow-parens": [ "error", "always" ], // it kills `arg => { func(); }`
// force spacing (I prefer super sparse code!)
"array-bracket-spacing": [ "error", "always" ], // it kills `[val1, val2]`
"arrow-spacing": [ "error", { "before": true, "after": true } ], // it kills `( arg )=>{ func(); }`
"block-spacing": [ "error", "always" ], // it kills `if ( cond ) {func();}`
"comma-spacing": [ "error", { "before": false, "after": true } ], // it kills `func( arg1,arg2 )`
"computed-property-spacing": [ "error", "always" ], // it kills `arr[i]`
"key-spacing": [ "error", { "beforeColon": false, "afterColon": true } ], // it kills `{ key:val }`
"keyword-spacing": [ "error", { "before": true, "after": true } ], // it kills `}else{`
"object-curly-spacing": [ "error", "always" ], // it kills `{key: val}`
"semi-spacing": [ "error", { "before": false, "after": true } ], // it kills `func1();func2();`
"space-before-blocks": [ "error", "always" ], // it kills `if (cond){`
"space-in-parens": [ "error", "always" ], // it kills `func (arg)`
"space-infix-ops": [ "error" ], // it kills val1+val2
"space-unary-ops": [ "error", { "words": true, "nonwords": false, "overrides": { "++": true, "--": true } } ], // it kills `val++`
"spaced-comment": [ "error", "always" ], // it kills `//this is comment`
// ban spacing
"func-call-spacing": [ "error", "never" ], // no-trailing-spaces. yea.
"no-trailing-spaces": [ "error" ], // no-trailing-spaces. yea.
"no-whitespace-before-property": [ "error" ], // it kills `obj .key`
"space-before-function-paren": [ "error", { "anonymous": "never", "named": "never", "asyncArrow": "always" } ], // it kills `func ()`
// others
"no-eval": [ "off" ], // we need to go the evil way
"no-implied-eval": [ "warn" ], // ok don't
"no-console": [ "error", { allow: [ "info", "warn", "error" ] } ], // don't forget to remove `console.log` !
// typescript-specifics
"@typescript-eslint/no-explicit-any": [ "off" ], // yea
"@typescript-eslint/explicit-module-boundary-types": [ "off" ], // We are using explicit any on purpose because it's explicit, be permissive
"@typescript-eslint/no-inferrable-types": [ "off" ], // it's ok
"@typescript-eslint/no-non-null-assertion": [ "off" ], // bang is sometimes required
"@typescript-eslint/no-empty-interface": [ "off" ], // we need to perform mixins
"@typescript-eslint/explicit-function-return-type": [ "error", { "allowExpressions": true } ], // return type is required
"@typescript-eslint/explicit-member-accessibility": [ "error" ], // `public` / `private` for members and methods are required
}
};