This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
90 lines (79 loc) · 4.21 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
module.exports = {
"root": true,
"plugins": [
"sort-imports-es6-autofix",
"@typescript-eslint",
],
"env": {
"browser": true,
"es6": true
},
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
],
"rules": {
// basics
"indent": [ "error", 2, { // indentation should be 2 spaces
"flatTernaryExpressions": true, // ternary should be performed in flat
} ], // it forces 2 spaces indentation
"linebreak-style": [ "error", "unix" ], // fuck you, CRLF
"quotes": [ "error", "single" ], // quotes must be single
"eqeqeq": [ "error", "always", { "null": "ignore" } ], // 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": "^_",
"destructuredArrayIgnorePattern": "^_",
},
], // draw yellow line under unused vars
"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", { "markers": [ "/", "!" ] } ], // 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": [ "error" ], // I don't think we're going to use the eval
"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-this-alias": [ "off" ], // we want to substitute `this` to variables for size
"@typescript-eslint/no-explicit-any": [ "off" ], // Three.js sometimes forces us to deal with anys
"@typescript-eslint/no-non-null-assertion": [ "off" ], // Three.js sometimes forces us to deal with bangs
"@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
}
};