diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index df0f756..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -coverage -readme.js \ No newline at end of file diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 9d3e986..0000000 --- a/.eslintrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": ["eslint:recommended", "plugin:prettier/recommended"], - "plugins": ["prettier"], - "env": { "es6": true, "node": true }, - "parserOptions": { - "requireConfigFile": false, - "ecmaVersion": 2020, - "sourceType": "module" - } -} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ce06135..510a7cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,11 +6,12 @@ on: jobs: build: - runs-on: ubuntu-latest strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - node-version: [18.x, 20.x] + node-version: [18, 20] + runs-on: ${{ matrix.os }} + steps: - uses: actions/checkout@v4 diff --git a/.npmrc b/.npmrc index 43c97e7..0ca8d2a 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ package-lock=false +save-exact=true diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 9f74261..0000000 --- a/.prettierrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "singleQuote": false, - "trailingComma": "all", - "useTabs": true, - "printWidth": 120, - "overrides": [ - { - "files": ["*.yml"], - "options": { - "tabWidth": 2, - "useTabs": false - } - } - ] -} diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..20ae368 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,15 @@ +{ + "singleQuote": false, + "trailingComma": "all", + "useTabs": true, + "printWidth": 120, + "overrides": [ + { + "files": ["*.yml", "*.json"], + "options": { + "tabWidth": 2, + "useTabs": false + } + } + ] +} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..db789d4 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,22 @@ +import prettierConfig from "eslint-config-prettier"; +import prettierPlugin from "eslint-plugin-prettier/recommended"; +import globals from "globals"; +import js from "@eslint/js"; + +export default [ + js.configs.recommended, + prettierConfig, + prettierPlugin, + { + languageOptions: { + globals: { + ...globals.node, + ...globals.browser, + global: true, + }, + }, + }, + { + ignores: ["coverage/*", "dist/*"], + }, +]; diff --git a/lib/client.js b/lib/client.js index 81ec248..2c20f86 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,6 +1,5 @@ "use strict"; -/* eslint-disable no-underscore-dangle */ /* eslint prefer-rest-params: "off" */ const timeSpan = require("time-span"); @@ -49,7 +48,7 @@ const MetricsClient = class MetricsClient extends stream.Transform { [push](metric) { const met = metric; met.source = this.id; - // eslint-disable-next-line no-underscore-dangle + if (this._readableState.flowing) { this.push(met); return; diff --git a/package.json b/package.json index 501e26f..a248b4f 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,53 @@ { - "name": "@metrics/client", - "version": "2.5.2", - "description": "A streaming metric producer. Allows producing counters, gauges, histograms and summaries in a way that is independent of your metrics system.", - "main": "lib/client.js", - "types": "client.d.ts", - "files": [ - "lib", - "client.d.ts" - ], - "scripts": { - "bench": "node benchmark/benchmark.js", - "test": "tap test/*.js --disable-coverage --allow-empty-coverage", - "test:coverage": "tap test/*.js", - "lint": "eslint .", - "lint:fix": "eslint . --fix" - }, - "author": "Richard Walker ", - "license": "MIT", - "keywords": [ - "server-statistics", - "server-stats", - "statistics", - "metrics", - "monitoring" - ], - "dependencies": { - "@metrics/metric": "^2.3.2", - "readable-stream": "^3.4.0", - "time-span": "^4.0.0" - }, - "devDependencies": { - "@semantic-release/changelog": "6.0.3", - "@semantic-release/commit-analyzer": "11.1.0", - "@semantic-release/git": "10.0.1", - "@semantic-release/github": "9.2.6", - "@semantic-release/npm": "11.0.3", - "@semantic-release/release-notes-generator": "12.1.0", - "@sinonjs/fake-timers": "11.2.2", - "benchmark": "2.1.4", - "eslint": "8.57.0", - "eslint-config-prettier": "9.1.0", - "eslint-plugin-prettier": "5.1.3", - "prettier": "3.2.5", - "semantic-release": "23.0.2", - "tap": "18.7.1" - }, - "repository": { - "type": "git", - "url": "https://github.com/metrics-js/client.git" - } + "name": "@metrics/client", + "version": "2.5.2", + "description": "A streaming metric producer. Allows producing counters, gauges, histograms and summaries in a way that is independent of your metrics system.", + "main": "lib/client.js", + "types": "client.d.ts", + "files": [ + "lib", + "client.d.ts" + ], + "scripts": { + "bench": "node benchmark/benchmark.js", + "test": "tap test/*.js --disable-coverage --allow-empty-coverage", + "test:coverage": "tap test/*.js", + "lint": "eslint .", + "lint:fix": "eslint . --fix" + }, + "author": "Richard Walker ", + "license": "MIT", + "keywords": [ + "server-statistics", + "server-stats", + "statistics", + "metrics", + "monitoring" + ], + "dependencies": { + "@metrics/metric": "^2.3.2", + "readable-stream": "^3.4.0", + "time-span": "^4.0.0" + }, + "devDependencies": { + "@semantic-release/changelog": "6.0.3", + "@semantic-release/commit-analyzer": "11.1.0", + "@semantic-release/git": "10.0.1", + "@semantic-release/github": "9.2.6", + "@semantic-release/npm": "11.0.3", + "@semantic-release/release-notes-generator": "12.1.0", + "@sinonjs/fake-timers": "11.2.2", + "benchmark": "2.1.4", + "eslint": "9.6.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.1.3", + "globals": "15.8.0", + "prettier": "3.2.5", + "semantic-release": "23.0.2", + "tap": "18.7.1" + }, + "repository": { + "type": "git", + "url": "https://github.com/metrics-js/client.git" + } } diff --git a/test/client.js b/test/client.js index bf9af45..c78c7dc 100644 --- a/test/client.js +++ b/test/client.js @@ -1,7 +1,5 @@ "use strict"; -/* eslint-disable no-console */ - const stream = require("readable-stream"); const fakeTimers = require("@sinonjs/fake-timers"); const tap = require("tap"); @@ -170,7 +168,6 @@ tap.test("client.metric() - metrics is not piped anywhere - should not fill stre }); } - // eslint-disable-next-line no-underscore-dangle t.equal(client._readableState.buffer.length, 0); t.end(); }); @@ -185,7 +182,7 @@ tap.test("client.metric() - destination is buffering - should emit drop events", const dest = destObjectStream((result) => { t.equal(result.length, 16); t.equal(dropped.length, 4); - // eslint-disable-next-line no-underscore-dangle + t.equal(client._readableState.buffer.length, 0); t.end(); }); @@ -203,7 +200,6 @@ tap.test("client.metric() - destination is buffering - should emit drop events", }); } - // eslint-disable-next-line no-underscore-dangle t.equal(client._readableState.buffer.length, 0); setImmediate(() => { @@ -219,9 +215,9 @@ tap.test("client.pipe() - pipe streams into each other - should pipe metrics thr t.equal(result.length, 3); t.equal(result[0].name, "first"); t.equal(result[2].name, "third"); - // eslint-disable-next-line no-underscore-dangle + t.equal(clientA._readableState.buffer.length, 0); - // eslint-disable-next-line no-underscore-dangle + t.equal(clientB._readableState.buffer.length, 0); t.end(); });