-
Notifications
You must be signed in to change notification settings - Fork 38
/
eslint.config.mjs
142 lines (139 loc) · 5.43 KB
/
eslint.config.mjs
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import tsParser from '@typescript-eslint/parser'
import streamr from 'eslint-config-streamr-ts'
import importPlugin from 'eslint-plugin-import'
import globals from 'globals'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename);
export default [
{
ignores: [
'**/generated/**',
'**/dist/**',
'**/node_modules/**'
]
},
...streamr,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
{
name: 'streamr-network-typescript',
languageOptions: {
globals: globals.node,
parser: tsParser,
parserOptions: {
project: ['./tsconfig.jest.json'],
tsconfigRootDir: __dirname
}
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: [
'packages/*/tsconfig.jest.json',
'packages/browser-test-runner/tsconfig.node.json'
]
},
node: true
}
},
rules: {
'class-methods-use-this': 'error',
'default-case': 'error',
'eol-last': 'error',
'no-console': ['error', {
allow: ['warn', 'error', 'info']
}],
'no-lonely-if': 'error',
'no-multi-spaces': ['error', {
ignoreEOLComments: true
}],
'no-restricted-imports': ['error', {
patterns: ['*/dist']
}],
'no-unneeded-ternary': 'error',
'no-useless-return': 'error',
'prefer-arrow-callback': 'error',
'quotes': ['error', 'single', {
allowTemplateLiterals: true
}],
'@typescript-eslint/default-param-last': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-invalid-this': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-misused-promises': ['error', {
checksVoidReturn: false
}],
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-vars': ['error', {
vars: 'all',
args: 'all',
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}],
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
'@typescript-eslint/parameter-properties': 'error',
'@typescript-eslint/prefer-literal-enum-member': 'error',
'@typescript-eslint/restrict-template-expressions': ['error', {
allowAny: false,
allowBoolean: true,
allowNullish: true,
allowNumber: true,
allowRegExp: true,
allowNever: true,
allow: [{ from: 'lib', name: 'Error' }]
}],
'@stylistic/brace-style': ['error', '1tbs', {
allowSingleLine: true
}],
'@stylistic/comma-spacing': 'error',
'@stylistic/func-call-spacing': 'error',
'@stylistic/keyword-spacing': 'error',
'@stylistic/member-delimiter-style': ['error', {
singleline: { delimiter: 'comma' },
multiline: { delimiter: 'none' }
}],
'@stylistic/object-curly-spacing': ['error', 'always'],
'@stylistic/space-before-blocks': 'error',
'@stylistic/space-before-function-paren': ['error', {
anonymous: 'never',
named: 'never',
asyncArrow: 'always'
}],
'@stylistic/space-infix-ops': 'error',
'import/no-extraneous-dependencies': ['error', {
devDependencies: [ 'test/**/*.ts', 'test/**/*.js'],
packageDir: ['.', '../..']
}],
'promise/always-return': ['error', {
ignoreLastCallback: true
}],
'promise/no-promise-in-callback': 'error',
// TODO in follow up PRs, select which rules we should enable and fix the code. When all recommended rules
// have been enabled, consider enabling the 'strict' preset.
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off'
}
},
{
files: ['**/*.js'],
languageOptions: {
sourceType: 'commonjs'
}
}
]