From 636c430a5bf8f78537eba44ed2e17f94d06376e3 Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Sat, 13 May 2023 14:39:23 +0200 Subject: [PATCH] eslint, sonarcloud, node 16 --- .eslintrc.js | 1 + .github/workflows/ci.yml | 29 ++++++----------------------- README.md | 8 ++++---- package.json | 26 +++++++++++++++----------- src/message-factory.ts | 7 ++++--- tests/message-factory.test.ts | 5 +++-- 6 files changed, 33 insertions(+), 43 deletions(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..144ae5c --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require('@chubbyts/chubbyts-eslint/dist/eslintrc').default; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58e10c4..d59e48c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,29 +3,15 @@ name: CI on: push: pull_request: + branches: + - master schedule: - cron: '0 0 * * *' jobs: - node14: - name: Node 14 - runs-on: ubuntu-20.04 - steps: - - name: checkout - uses: actions/checkout@v3 - - name: checkout node - uses: actions/setup-node@v3 - with: - node-version: '14' - - run: npm install - - run: npm run cs - - run: npm test -- --coverage --no-cache - - run: npm run infection - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} node16: name: Node 16 - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: checkout uses: actions/checkout@v3 @@ -34,14 +20,10 @@ jobs: with: node-version: '16' - run: npm install - - run: npm run cs - - run: npm test -- --coverage --no-cache - - run: npm run infection - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + - run: npm test node18: name: Node 18 - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: checkout uses: actions/checkout@v3 @@ -50,6 +32,7 @@ jobs: with: node-version: '18' - run: npm install + - run: npm run lint - run: npm run cs - run: npm test -- --coverage --no-cache - run: npm run infection diff --git a/README.md b/README.md index 80e230c..211ad09 100644 --- a/README.md +++ b/README.md @@ -23,16 +23,16 @@ Http Request/Response with middleware and handler, [PSR-15][2] inspired. ## Requirements - * node: 14 - * [chubbyts/chubbyts-http-types][3]: ^1.0.0 - * [qs][4]: ^6.11.0 + * node: 16 + * [chubbyts/chubbyts-http-types][3]: ^1.1.0 + * [qs][4]: ^6.11.1 ## Installation Through [NPM](https://www.npmjs.com) as [@chubbyts/chubbyts-http][1]. ```ts -npm i @chubbyts/chubbyts-http@^1.0.2 +npm i @chubbyts/chubbyts-http@^1.1.0 ``` ## Copyright diff --git a/package.json b/package.json index d1ed9b7..4c29642 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chubbyts/chubbyts-http", - "version": "1.0.2", + "version": "1.1.0", "description": "Http Request/Response with middleware and handler, PSR-15 inspired.", "keywords": [ "chubbyts", @@ -17,6 +17,8 @@ "scripts": { "cs-fix": "prettier --write src tests", "cs": "prettier --check src tests", + "lint-fix": "eslint src tests --fix", + "lint": "eslint src tests", "test": "jest", "infection": "stryker run", "build": "rm -Rf dist && tsc", @@ -44,22 +46,24 @@ "dist" ], "engines": { - "node": ">=14" + "node": ">=16" }, "dependencies": { - "@chubbyts/chubbyts-http-types": "^1.0.0", - "qs": "^6.11.0" + "@chubbyts/chubbyts-eslint": "^1.1.1", + "@chubbyts/chubbyts-http-types": "^1.1.0", + "qs": "^6.11.1" }, "devDependencies": { - "@stryker-mutator/core": "^6.4.1", - "@stryker-mutator/jest-runner": "^6.4.1", - "@types/jest": "^29.5.0", - "@types/node": "^18.15.3", + "@chubbyts/chubbyts-eslint": "^1.1.1", + "@stryker-mutator/core": "^6.4.2", + "@stryker-mutator/jest-runner": "^6.4.2", + "@types/jest": "^29.5.1", + "@types/node": "^20.1.3", "@types/qs": "^6.9.7", "jest": "^29.5.0", - "prettier": "^2.8.4", - "ts-jest": "^29.0.5", - "typescript": "^4.9.5" + "prettier": "^2.8.8", + "ts-jest": "^29.1.0", + "typescript": "^5.0.4" }, "publishConfig": { "access": "public" diff --git a/src/message-factory.ts b/src/message-factory.ts index b8d337d..5fb8b91 100644 --- a/src/message-factory.ts +++ b/src/message-factory.ts @@ -1,7 +1,8 @@ import { createReadStream, existsSync } from 'fs'; -import { Duplex, PassThrough, Stream } from 'stream'; -import { Method, Query, Request, Response, ServerRequest, Uri } from '@chubbyts/chubbyts-http-types/dist/message'; -import { +import type { Duplex, Stream } from 'stream'; +import { PassThrough } from 'stream'; +import type { Method, Query, Request, Response, ServerRequest, Uri } from '@chubbyts/chubbyts-http-types/dist/message'; +import type { RequestFactory, ResponseFactory, ServerRequestFactory, diff --git a/tests/message-factory.test.ts b/tests/message-factory.test.ts index f017548..56b31a4 100644 --- a/tests/message-factory.test.ts +++ b/tests/message-factory.test.ts @@ -1,8 +1,9 @@ -import { describe, expect, test } from '@jest/globals'; import { randomBytes } from 'crypto'; import { createReadStream, unlinkSync, writeFileSync } from 'fs'; import { tmpdir } from 'os'; import { PassThrough, Stream } from 'stream'; +import { describe, expect, test } from '@jest/globals'; +import { Method } from '@chubbyts/chubbyts-http-types/dist/message'; import { createUriFactory, createStreamFactory, @@ -13,10 +14,10 @@ import { createResponseFactory, statusCodeMap, } from '../src/message-factory'; -import { Method } from '@chubbyts/chubbyts-http-types/dist/message'; const readStream = async (stream: Stream) => { return new Promise((resolve, reject) => { + // eslint-disable-next-line functional/no-let let data = ''; stream.on('data', (chunk) => (data += chunk));