-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
117 lines (117 loc) · 4.12 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
plugins: ['@typescript-eslint', 'import'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:unicorn/recommended',
'plugin:import/warnings',
'plugin:import/typescript',
'prettier',
'prettier/@typescript-eslint',
'prettier/unicorn',
],
rules: {
'import/default': 'off', // doesn't play nice with commonjs modules
'no-console': 'off',
'prefer-const': 'error',
'unicorn/filename-case': [
'error',
{
cases: {
// for classes
pascalCase: true,
// for everything else
kebabCase: true,
},
},
],
'unicorn/catch-error-name': 'error',
'unicorn/prevent-abbreviations': 'off',
'unicorn/prefer-includes': 'error',
'unicorn/expiring-todo-comments': 'warn',
'unicorn/consistent-function-scoping': 'error',
'unicorn/no-nested-ternary': 'warn',
'unicorn/regex-shorthand': 'warn',
'unicorn/prefer-number-properties': 'off',
'unicorn/no-null': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/better-regex': 'off',
'unicorn/no-array-reduce': 'off',
'unicorn/no-process-exit': 'off', // lots of command line programs here!
'unicorn/prefer-ternary': 'off',
'block-scoped-var': 'error', // I think this is mostly handled by no-undef
'no-eval': 'error',
'valid-typeof': ['error', { requireStringLiterals: true }],
'require-atomic-updates': 'off', // really doesn't work well with Koa ctx
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
'import/no-named-as-default-member': 'off',
'import/no-named-as-default': 'off',
// we probably should enable these, as they error on real issues (mostly related to the any type)
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/restrict-template-expressions': 'off', // this probably doesn't hide mistakes
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '([iI]gnored|^_.*)',
argsIgnorePattern: '([iI]gnored|^_.*)',
},
],
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
},
},
{
files: ['*.ts'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'unicorn/no-nested-ternary': 'error',
'prefer-const': 'error',
},
},
{
// tests sometimes do things very explicitly, requiring looser lint rules
files: ['tests/**/*', '*.test.ts', 'test.ts'],
rules: {
'@typescript-eslint/no-empty-function': 'off', // sometimes we just need a no-op
'prefer-const': 'off', // not going to clean up old tests that use let
'unicorn/no-useless-undefined': 'off', // sometimes more explicit
'unicorn/no-zero-fractions': 'off', // ditto
'unicorn/consistent-function-scoping': 'off',
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/no-explicit-any': 'off', // casting to any makes mocking a *lot* easier
},
},
],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
// use <root>/tsconfig.json
typescript: {},
configurable: {
src: './src/',
},
},
},
};