Skip to content

Commit

Permalink
chore: update pkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
meabed committed Jan 8, 2025
1 parent 996a7ac commit dda1fb9
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 51 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

34 changes: 0 additions & 34 deletions .eslintrc

This file was deleted.

3 changes: 1 addition & 2 deletions __tests__/graphqlUploadKoa.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { graphqlUploadKoa } from '../src';
import { processRequest } from '../src';
import { graphqlUploadKoa, processRequest } from '../src';
import { listen } from './utils/listen';
import { deepStrictEqual, ok, strictEqual } from 'assert';
import FormData from 'form-data';
Expand Down
7 changes: 3 additions & 4 deletions __tests__/processRequest.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { deepStrictEqual, notStrictEqual, ok, rejects, strictEqual, throws } from 'node:assert';
import { createServer } from 'node:http';
import { text } from 'node:stream/consumers';
import { processRequest, Upload } from '../src';
import { processRequest, ReadStream, Upload } from '../src';
import { listen } from './utils/listen';
import { ReadStream } from '../src/fs-capacitor';
import { abortingMultipartRequest } from './utils/abortingMultipartRequest';
import { Deferred } from './utils/defered';

Expand Down Expand Up @@ -57,7 +56,7 @@ describe('processRequest', () => {

ok(stream instanceof ReadStream);
strictEqual(stream.readableEncoding, null);
strictEqual(stream.readableHighWaterMark, 16384);
strictEqual(stream.readableHighWaterMark, 65536);
strictEqual(await text(stream), 'a');
} catch (error) {
serverError = error;
Expand Down Expand Up @@ -104,7 +103,7 @@ describe('processRequest', () => {

ok(stream instanceof ReadStream);
strictEqual(stream.readableEncoding, null);
strictEqual(stream.readableHighWaterMark, 16384);
strictEqual(stream.readableHighWaterMark, 65536);
strictEqual(await text(stream), 'a');
} catch (error) {
serverError = error;
Expand Down
5 changes: 4 additions & 1 deletion __tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"extends": "./../tsconfig.json",
"include": ["../src", "./"]
"include": [
"../src",
"./"
]
}
2 changes: 1 addition & 1 deletion __tests__/utils/abortingMultipartRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function abortingMultipartRequest(
requestReceived: Promise<any>,
) {
const abortController = new AbortController();
const encoder = new FormDataEncoder(formData);
const encoder = new FormDataEncoder(formData as FormDataLike);

try {
await fetch(url, {
Expand Down
46 changes: 46 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ['**/dist', '**/node_modules', '**/.vscode', '**/e2e', '**/.git'],
},
...compat.extends('plugin:@typescript-eslint/recommended', 'prettier', 'plugin:prettier/recommended'),
{
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
},
},
rules: {
'space-before-function-paren': 'off',
'no-unreachable-loop': 'off',
'no-unreachable': 'off',
semi: 'off',
'comma-dangle': 'off',
'no-prototype-builtins': 0,
'handle-callback-err': 'off',
'node/handle-callback-err': 'off',
'no-var': 'off',
'array-callback-return': 'off',
'multiline-ternary': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'prefer-spread': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-unused-vars': 'off',
},
},
];
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"@types/koa": "2.15.0",
"@types/object-path": "0.11.4",
"@typescript-eslint/eslint-plugin": "8.19.1",
"@typescript-eslint/parser": "8.19.1",
"eslint": "9.17.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
Expand Down
6 changes: 5 additions & 1 deletion src/processRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ export async function processRequest<T = any>(
if (map) for (const upload of map.values()) if (!upload.file) upload.reject(exitError);

// If the error came from the parser, don’t cause it to be emitted again.
isParserError ? parser.destroy() : parser.destroy(exitError);
if (isParserError) {
parser.destroy();
} else {
parser.destroy(exitError);
}

request.unpipe(parser);

Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"outDir": "./dist",
"target": "es2019",
"module": "commonjs",
"module": "es6",
"target": "es5",
"moduleResolution": "node",
"allowJs": true,
"checkJs": true,
Expand Down

0 comments on commit dda1fb9

Please sign in to comment.