diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 6cb772b..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -tmp 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/release.yml b/.github/workflows/release.yml index 90a96b5..6c3e157 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,42 +1,42 @@ name: Release on main permissions: - contents: write # to be able to publish a GitHub release - issues: write # to be able to comment on released issues - pull-requests: write # to be able to comment on released pull requests - id-token: write # to enable use of OIDC for npm provenance + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance on: - push: - branches: - - main + push: + branches: + - main # Cancel previous workflows which might still be running concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - - name: Install dependencies - run: npm install - - - name: Run all tests - run: npm test - - - name: Release and publish - run: npx semantic-release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install dependencies + run: npm install + + - name: Run all tests + run: npm test + + - name: Release and publish + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a88a6e..510a7cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,29 +1,30 @@ name: Run Lint and Tests on: - pull_request: - branches: [main] + pull_request: + branches: [main] jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - node-version: [18.x, 20.x] - steps: - - uses: actions/checkout@v4 + build: + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + node-version: [18, 20] + runs-on: ${{ matrix.os }} - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} + steps: + - uses: actions/checkout@v4 - - name: Install dependencies - run: npm install + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} - - name: Lint - run: npm run lint + - name: Install dependencies + run: npm install - - name: Run tests - run: npm test + - name: Lint + run: npm run lint + + - name: Run tests + run: npm test 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 df892e4..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/guard.js b/lib/guard.js index 55c17cc..34d1a6b 100644 --- a/lib/guard.js +++ b/lib/guard.js @@ -68,7 +68,7 @@ const MetricsGuard = class MetricsGuard 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 4c9ccb6..598c961 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,53 @@ { - "name": "@metrics/guard", - "version": "1.0.2", - "description": "Module to guard against excessive metric permutation creation in a metric stream", - "main": "lib/guard.js", - "types": "guard.d.ts", - "files": [ - "lib", - "guard.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": "Trygve Lie ", - "license": "MIT", - "keywords": [ - "server-statistics", - "server-stats", - "statistics", - "metrics", - "monitoring", - "guard" - ], - "dependencies": { - "readable-stream": "^3.4.0" - }, - "devDependencies": { - "@metrics/client": "2.5.2", - "@metrics/metric": "2.3.3", - "@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", - "eslint": "8.57.0", - "eslint-config-prettier": "9.1.0", - "eslint-plugin-prettier": "5.1.3", - "fastbench": "1.0.1", - "prettier": "3.3.0", - "semantic-release": "23.0.2", - "tap": "18.7.1" - }, - "repository": { - "type": "git", - "url": "https://github.com/metrics-js/client.git" - } + "name": "@metrics/guard", + "version": "1.0.2", + "description": "Module to guard against excessive metric permutation creation in a metric stream", + "main": "lib/guard.js", + "types": "guard.d.ts", + "files": [ + "lib", + "guard.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": "Trygve Lie ", + "license": "MIT", + "keywords": [ + "server-statistics", + "server-stats", + "statistics", + "metrics", + "monitoring", + "guard" + ], + "dependencies": { + "readable-stream": "^3.4.0" + }, + "devDependencies": { + "@metrics/client": "2.5.2", + "@metrics/metric": "2.3.3", + "@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", + "eslint": "9.6.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.1.3", + "fastbench": "1.0.1", + "globals": "15.8.0", + "prettier": "3.3.0", + "semantic-release": "23.0.2", + "tap": "18.7.1" + }, + "repository": { + "type": "git", + "url": "https://github.com/metrics-js/client.git" + } }