-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
82 lines (82 loc) · 3.28 KB
/
index.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
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: [
'standard',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: '2020'
},
plugins: ['react', '@typescript-eslint'],
rules: {
'import/order': 'error',
'space-before-function-paren': 'off',
// the behaviour of ternary operators is often more clear than using '||', '&&' or '??'
'no-unneeded-ternary': 'off',
// This rule has a small problem: when using jsx it is pretty common to wrap the (true / false) expressions in parentheses and have the "?" or ":" on the same line.
// This isn't allowed with this rule as it would require an additional newline for "?" and ":".
// As the rule doesn't really enforce anything useful (a lot of bad styles are still allowed, but some good ones as well; no real way to filter further) disabling it doesn't hurt.
'multiline-ternary': 'off',
'no-use-before-define': 'off',
'quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
// this rule is utter trash
'n/no-callback-literal': 'off',
// This highly depends on the situation even when the same operators are used.
// For ternaries it should always be 'before' but override doesn't work with 'off'
// therefore turning it off altogether
'operator-linebreak': ['off'],
// basically allow dangling commas in situations where they might be useful
// for quickly lists of *things* (e.g. exports, arrays, objects) but disallow
// for unnecessary things (functions and imports)
'comma-dangle': ['error', {
functions: 'never',
imports: 'never',
exports: 'only-multiline',
arrays: 'only-multiline',
objects: 'only-multiline',
}],
// if a single key requires quotes better quote all keys
// it would be great if this was also optional additionally, meaning that
// if one key requires quotes all other keys *can* optionally be quoted as well
// but never otherwise
'quote-props': ['warn', 'consistent-as-needed'],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
// use commas in typescript types as they are closely related to object literals
'@typescript-eslint/member-delimiter-style': [
'warn',
{
multiline: {
delimiter: 'comma',
requireLast: false
},
singleline: {
delimiter: 'comma',
requireLast: false
}
}
],
'jsx-quotes': ['error', 'prefer-double'],
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'ignore', propElementValues: 'always' }],
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'react/jsx-wrap-multilines': ['error', {
declaration: 'parens-new-line',
assignment: 'parens-new-line',
return: 'parens-new-line',
arrow: 'parens-new-line',
condition: 'parens-new-line',
logical: 'parens-new-line',
prop: 'parens-new-line'
}],
},
settings: {
react: {
version: 'detect'
}
}
}