-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.js
94 lines (81 loc) · 4.16 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
module.exports = {
'root': true,
'plugins': [ '@typescript-eslint' ],
'env': {
'es6': true,
'browser': true,
'commonjs': true
},
'parser': '@typescript-eslint/parser',
'parserOptions': {
'sourceType': 'module',
'ecmaVersion': 2017
},
'extends': [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime'
],
'globals': {
'process': true // since gulp has envify
},
'rules': {
// basics
'indent': [ 'error', 2, { // indentation should be 2 spaces
'flatTernaryExpressions': true, // ternary should be performed in flat
'MemberExpression': 0 // member chain 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', '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': [ 'error' ], // imports have to be ordered
'eol-last': [ 'error', 'always' ], // eof newline is cool
// variables
'@typescript-eslint/no-unused-vars': [ 'warn' ], // draw yellow line under unused vars
'no-undef': [ 'warn' ], // draws yellow line under undefined 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': [ 'warn' ], // nope
'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-member-accessibility': [ 'error' ], // `public` / `private` for members and methods are required
'@typescript-eslint/no-non-null-assertion': [ 'off' ], // bang is sometimes required
'@typescript-eslint/no-empty-interface': [ 'error', { 'allowSingleExtends': true } ], // bans interface Foo {}
}
};