Skip to content

Commit d8efe87

Browse files
committed
Linter: update to eslint v9, and enable TS recommended rules
This eslint version brings breaking changes related to the eslint config.
1 parent 1589af6 commit d8efe87

File tree

12 files changed

+1033
-289
lines changed

12 files changed

+1033
-289
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 70 deletions
This file was deleted.

eslint.config.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// @ts-check
2+
import eslint from '@eslint/js';
3+
import { defineConfig } from 'eslint/config';
4+
import tseslint from 'typescript-eslint';
5+
import globals from 'globals';
6+
// @ts-expect-error missing declarations
7+
import pluginChaiFriendly from 'eslint-plugin-chai-friendly';
8+
import pluginImport from 'eslint-plugin-import';
9+
import pluginStylistic from '@stylistic/eslint-plugin';
10+
11+
export default defineConfig(
12+
eslint.configs.recommended,
13+
tseslint.configs.recommended,
14+
{
15+
languageOptions: {
16+
ecmaVersion: 2022,
17+
sourceType: 'module',
18+
parserOptions: {
19+
projectService: true,
20+
tsconfigRootDir: import.meta.dirname
21+
},
22+
globals: {
23+
...globals.browser,
24+
...globals.mocha
25+
}
26+
},
27+
settings: {
28+
'import/resolver': {
29+
typescript: { alwaysTryTypes: true }
30+
}
31+
},
32+
plugins: {
33+
'chai-friendly': pluginChaiFriendly,
34+
'import': pluginImport,
35+
'@stylistic': pluginStylistic
36+
},
37+
rules: {
38+
'no-unused-vars': 'off',
39+
'@typescript-eslint/no-unused-vars': ['error', { 'argsIgnorePattern': '^_', 'varsIgnorePattern': '^_' }],
40+
'no-redeclare': 'off',
41+
'@typescript-eslint/no-redeclare': 'error',
42+
'prefer-spread': 'off',
43+
'no-restricted-syntax': 'off',
44+
'consistent-return': 'off',
45+
'object-curly-newline': 'off',
46+
'prefer-template': 'off',
47+
'no-plusplus': 'off',
48+
'no-continue': 'off',
49+
'no-bitwise': 'off',
50+
'no-await-in-loop': 'off',
51+
'no-sequences': 'warn',
52+
'no-param-reassign': 'warn',
53+
'no-return-assign': 'warn',
54+
'no-else-return': ['error', { 'allowElseIf': true }],
55+
'no-shadow': 'off',
56+
'no-undef': 'error',
57+
'no-constant-condition': ['error', { 'checkLoops': 'all' }],
58+
'no-unused-expressions': 'off',
59+
'@typescript-eslint/no-unused-expressions': 'off',
60+
'chai-friendly/no-unused-expressions': [ 'error', { allowShortCircuit: true } ],
61+
'arrow-body-style': 'off',
62+
'space-before-function-paren': 'off',
63+
'operator-linebreak': 'off',
64+
'implicit-arrow-linebreak': 'off',
65+
'no-underscore-dangle': 'off',
66+
'import/prefer-default-export': 'off',
67+
'import/no-extraneous-dependencies': 'off',
68+
'import/no-unassigned-import': 'error',
69+
'import/named': 'error',
70+
'max-len': ['error', {
71+
'ignoreComments': true,
72+
'code': 130,
73+
'ignoreStrings': true,
74+
'ignoreTemplateLiterals': true,
75+
'ignoreRegExpLiterals': true
76+
}],
77+
'no-multiple-empty-lines': ['error'],
78+
'no-trailing-spaces': ['error'],
79+
'eol-last': ['error'],
80+
'padded-blocks': 'off',
81+
'max-classes-per-file': 'off',
82+
'no-empty': 'off',
83+
'@stylistic/semi': 'error',
84+
'@stylistic/indent': ['error', 2],
85+
'@stylistic/quotes': ['error', 'single', { 'avoidEscape': true }],
86+
'@typescript-eslint/no-explicit-any': 'off'
87+
}
88+
}
89+
);

lib/reader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function Reader(input) {
5151
if (doneReading) {
5252
try {
5353
doneReadingSet.add(input);
54-
} catch(e) {}
54+
} catch {}
5555
}
5656
};
5757
}

lib/streams.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ function concat(list) {
6666
* @returns {ReadableStream} Concatenated list
6767
*/
6868
function concatStream(list) {
69-
list = list.map(toStream);
69+
const streamedList = list.map(toStream);
7070
const transform = transformWithCancel(async function(reason) {
7171
await Promise.all(transforms.map(stream => cancel(stream, reason)));
7272
});
7373
let prev = Promise.resolve();
74-
const transforms = list.map((stream, i) => transformPair(stream, (readable, writable) => {
74+
const transforms = streamedList.map((stream, i) => transformPair(stream, (readable, _writable) => {
7575
prev = prev.then(() => pipe(readable, transform.writable, {
76-
preventClose: i !== list.length - 1
76+
preventClose: i !== streamedList.length - 1
7777
}));
7878
return prev;
7979
}));
@@ -126,7 +126,7 @@ async function pipe(input, target, {
126126
preventAbort,
127127
preventCancel
128128
});
129-
} catch(e) {}
129+
} catch {}
130130
return;
131131
}
132132
if (!isStream(input)) {
@@ -452,11 +452,11 @@ function passiveClone(input) {
452452
await writer.ready;
453453
const { done, value } = await reader.read();
454454
if (done) {
455-
try { controller.close(); } catch(e) {}
455+
try { controller.close(); } catch {}
456456
await writer.close();
457457
return;
458458
}
459-
try { controller.enqueue(value); } catch(e) {}
459+
try { controller.enqueue(value); } catch {}
460460
await writer.write(value);
461461
}
462462
} catch(e) {
@@ -561,7 +561,7 @@ function slice(input, begin=0, end=Infinity) {
561561
lastBytes = slice(returnValue, end);
562562
return slice(returnValue, begin, end);
563563
}
564-
lastBytes = returnValue;
564+
lastBytes = returnValue;
565565
});
566566
}
567567
console.warn(`stream.slice(input, ${begin}, ${end}) not implemented efficiently.`);

0 commit comments

Comments
 (0)