Skip to content

Commit efc24de

Browse files
authored
chore: Eslint v9 (#24)
## Changes Converted the configuration file to flat config and unified to config file style. Otherwise same rules are earlier, but some new rules disabled (see "Future improvements"). The `bin` directory is also now included as a source directory and therefore `eslint` checks also those files. Also small changes to code to fix some `eslint` warnings. These modifications don't change any functionality. ## Future improvements - Avoid using `any` type, i.e. enable these rules: - `@typescript-eslint/no-unsafe-argument` - `@typescript-eslint/no-unsafe-assignment` - `@typescript-eslint/no-unsafe-call` - `@typescript-eslint/no-unsafe-member-access` - `@typescript-eslint/no-unsafe-return` - Implement safer promise handling, i.e. enable these rules: - `@typescript-eslint/no-floating-promises` - `@typescript-eslint/no-misused-promises` - `@typescript-eslint/require-await`
1 parent fd05681 commit efc24de

15 files changed

+500
-414
lines changed

.eslintignore

-2
This file was deleted.

.eslintrc.js

-63
This file was deleted.

eslint.config.mjs

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import streamr from 'eslint-config-streamr-ts'
2+
3+
export default [
4+
{
5+
ignores: [
6+
'node_modules/**',
7+
'dist/**'
8+
]
9+
},
10+
...streamr,
11+
{
12+
rules: {
13+
'class-methods-use-this': 'error',
14+
'eol-last': 'error',
15+
'no-console': ['error', {
16+
allow: ['warn', 'error', 'info']
17+
}],
18+
'no-restricted-imports': ['error', {
19+
patterns: ["*/dist"]
20+
}],
21+
'no-unused-vars': 'off',
22+
'prefer-arrow-callback': 'error',
23+
'@typescript-eslint/consistent-indexed-object-style': 'error',
24+
'@typescript-eslint/consistent-type-assertions': 'error',
25+
'@typescript-eslint/consistent-type-definitions': 'error',
26+
'@typescript-eslint/default-param-last': 'error',
27+
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
28+
'@typescript-eslint/no-duplicate-enum-values': 'error',
29+
'@typescript-eslint/no-empty-function': 'error',
30+
'@typescript-eslint/no-extraneous-class': 'error',
31+
'@typescript-eslint/no-inferrable-types': 'off',
32+
'@typescript-eslint/no-invalid-this': 'error',
33+
'@typescript-eslint/no-invalid-void-type': 'error',
34+
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
35+
'@typescript-eslint/no-require-imports': 'error',
36+
'@typescript-eslint/no-unused-expressions': 'error',
37+
'@typescript-eslint/no-unused-vars': ['error', {
38+
vars: 'all',
39+
args: 'all',
40+
argsIgnorePattern: '^_',
41+
varsIgnorePattern: '^_',
42+
caughtErrorsIgnorePattern: '^_'
43+
}],
44+
'@typescript-eslint/no-useless-constructor': 'error',
45+
'@typescript-eslint/no-useless-empty-export': 'error',
46+
'@typescript-eslint/prefer-for-of': 'error',
47+
'@typescript-eslint/prefer-function-type': 'error',
48+
'@typescript-eslint/prefer-literal-enum-member': 'error',
49+
'@stylistic/brace-style': ['error', '1tbs', {
50+
allowSingleLine: true
51+
}],
52+
'@stylistic/comma-spacing': 'error',
53+
'@stylistic/func-call-spacing': 'error',
54+
'@stylistic/keyword-spacing': 'error',
55+
'@stylistic/member-delimiter-style': ['error', {
56+
singleline: { delimiter: 'comma' },
57+
multiline: { delimiter: 'none' }
58+
}],
59+
'@stylistic/object-curly-spacing': ['error', 'always'],
60+
'@typescript-eslint/restrict-template-expressions': ['error', {
61+
allowAny: false,
62+
allowBoolean: true,
63+
allowNullish: true,
64+
allowNumber: true,
65+
allowRegExp: true,
66+
allowNever: true,
67+
allow: [{ from: 'lib', name: ['Error'] }]
68+
}],
69+
'@stylistic/space-before-blocks': 'error',
70+
'@stylistic/space-before-function-paren': ['error', {
71+
anonymous: 'never',
72+
named: 'never',
73+
asyncArrow: 'always'
74+
}],
75+
'@stylistic/space-infix-ops': 'error',
76+
'promise/no-promise-in-callback': 'error',
77+
78+
// TODO maybe we could enable some of these
79+
'@typescript-eslint/no-floating-promises': 'off',
80+
'@typescript-eslint/no-misused-promises': 'off',
81+
'@typescript-eslint/no-unsafe-argument': 'off',
82+
'@typescript-eslint/no-unsafe-assignment': 'off',
83+
'@typescript-eslint/no-unsafe-call': 'off',
84+
'@typescript-eslint/no-unsafe-member-access': 'off',
85+
'@typescript-eslint/no-unsafe-return': 'off',
86+
'@typescript-eslint/require-await': 'off'
87+
}
88+
}
89+
]

0 commit comments

Comments
 (0)