From d8464eb7e455b8dbdeb1019b32e35f48a7712633 Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:03:43 +0900 Subject: [PATCH 01/10] add node24 to ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 939a092..e26aaa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: - '18' - '20' - '22' + - '24' steps: - uses: actions/checkout@v4 - name: Setup Node.js ${{ matrix.node-version }} From 66315201a3300b46cb7f473ce69f2077eac5d40b Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:06:33 +0900 Subject: [PATCH 02/10] update fuzz.yml --- .github/workflows/fuzz.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 0bcacca..79f9e5c 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -14,12 +14,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: cache: npm - node-version: "18" + node-version: "20" # npm@9 may fail with https://github.com/npm/cli/issues/6723 # npm@10 may fail with "GitFetcher requires an Arborist constructor to pack a tarball" From a0c6a988316b961a4b1bef980ee8247a20b83aa1 Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:07:48 +0900 Subject: [PATCH 03/10] use import type to import TS types --- src/Encoder.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Encoder.ts b/src/Encoder.ts index ffb4f6b..43fcd8f 100644 --- a/src/Encoder.ts +++ b/src/Encoder.ts @@ -1,9 +1,10 @@ import { utf8Count, utf8Encode } from "./utils/utf8.ts"; -import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec.ts"; +import { ExtensionCodec } from "./ExtensionCodec.ts"; import { setInt64, setUint64 } from "./utils/int.ts"; import { ensureUint8Array } from "./utils/typedArrays.ts"; import type { ExtData } from "./ExtData.ts"; import type { ContextOf } from "./context.ts"; +import type { ExtensionCodecType } from "./ExtensionCodec.ts"; export const DEFAULT_MAX_DEPTH = 100; export const DEFAULT_INITIAL_BUFFER_SIZE = 2048; From 35b294a289eb007e5fa80b09cf45391bce5f7e8c Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:11:19 +0900 Subject: [PATCH 04/10] do not send coverage report to codecova (operation timed out) --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e26aaa9..eb4dd7c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,10 +27,6 @@ jobs: - run: npm install -g nyc - run: npm ci - run: npm run test:cover - - uses: codecov/codecov-action@v5 - with: - files: coverage/coverage-final.json - token: ${{ secrets.CODECOV_TOKEN }} browser: runs-on: ubuntu-latest From 6aed81b871c412acad356f7678ece677fcae5069 Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:12:12 +0900 Subject: [PATCH 05/10] hide codecov badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f7c36cc..830d75c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MessagePack for ECMA-262/JavaScript/TypeScript -[![npm version](https://img.shields.io/npm/v/@msgpack/msgpack.svg)](https://www.npmjs.com/package/@msgpack/msgpack) ![CI](https://github.com/msgpack/msgpack-javascript/workflows/CI/badge.svg) [![codecov](https://codecov.io/gh/msgpack/msgpack-javascript/branch/master/graphs/badge.svg)](https://codecov.io/gh/msgpack/msgpack-javascript) [![minzip](https://badgen.net/bundlephobia/minzip/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack) [![tree-shaking](https://badgen.net/bundlephobia/tree-shaking/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack) +[![npm version](https://img.shields.io/npm/v/@msgpack/msgpack.svg)](https://www.npmjs.com/package/@msgpack/msgpack) ![CI](https://github.com/msgpack/msgpack-javascript/workflows/CI/badge.svg) [![minzip](https://badgen.net/bundlephobia/minzip/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack) [![tree-shaking](https://badgen.net/bundlephobia/tree-shaking/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack) This library is an implementation of **MessagePack** for TypeScript and JavaScript, providing a compact and efficient binary serialization format. Learn more about MessagePack at: From 3b40330dd107507881c689049d0836d5b786417e Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:15:11 +0900 Subject: [PATCH 06/10] fix --- .github/workflows/codeql.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 406131c..578c615 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/package.json b/package.json index e67d3fd..a9cdd12 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test:bun": "bun test test/bun.spec.ts", "test:fuzz": "npm exec --yes -- jsfuzz@git+https://gitlab.com/gitlab-org/security-products/analyzers/fuzzers/jsfuzz.git#39e6cf16613a0e30c7a7953f62e64292dbd5d3f3 --fuzzTime 60 --no-versifier test/decode.jsfuzz.js corpus", "cover:clean": "rimraf .nyc_output coverage/", - "cover:report": "npx nyc report --reporter=text-summary --reporter=html --reporter=json", + "cover:report": "npx nyc report --reporter=text-summary", "test:browser": "karma start --single-run", "test:browser:firefox": "karma start --single-run --browsers FirefoxHeadless", "test:browser:chrome": "karma start --single-run --browsers ChromeHeadless", From 9c52717572d85199cd0e9e28fd9f33921bdbfa8f Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:15:43 +0900 Subject: [PATCH 07/10] fix imports --- src/Decoder.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Decoder.ts b/src/Decoder.ts index 9239dd1..83b68a1 100644 --- a/src/Decoder.ts +++ b/src/Decoder.ts @@ -1,11 +1,12 @@ import { prettyByte } from "./utils/prettyByte.ts"; -import { ExtensionCodec, ExtensionCodecType } from "./ExtensionCodec.ts"; +import { ExtensionCodec } from "./ExtensionCodec.ts"; import { getInt64, getUint64, UINT32_MAX } from "./utils/int.ts"; import { utf8Decode } from "./utils/utf8.ts"; import { ensureUint8Array } from "./utils/typedArrays.ts"; import { CachedKeyDecoder, KeyDecoder } from "./CachedKeyDecoder.ts"; import { DecodeError } from "./DecodeError.ts"; import type { ContextOf } from "./context.ts"; +import type { ExtensionCodecType } from "./ExtensionCodec.ts"; export type DecoderOptions = Readonly< Partial<{ @@ -70,7 +71,7 @@ export type DecoderOptions = Readonly< /** * A function to convert decoded map key to a valid JS key type. - * + * * Defaults to a function that throws an error if the key is not a string or a number. */ mapKeyConverter: (key: unknown) => MapKeyType; From fb92347d140e7c790053289cdcdbccfc32bc12bd Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:19:30 +0900 Subject: [PATCH 08/10] fix --- eslint.config.mjs | 203 +++++++++++++++++++++++----------------- src/CachedKeyDecoder.ts | 4 +- src/Decoder.ts | 3 +- 3 files changed, 120 insertions(+), 90 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 3d5529e..0af8fa6 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -11,112 +11,141 @@ 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 + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, }); -export default [{ +export default [ + { ignores: ["**/*.js", "test/deno*", "test/bun*"], -}, ...fixupConfigRules(compat.extends( - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - "prettier", -)), { + }, + ...fixupConfigRules( + compat.extends( + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:import/recommended", + "plugin:import/typescript", + "prettier", + ), + ), + { plugins: { - "@typescript-eslint": fixupPluginRules(typescriptEslintEslintPlugin), - tsdoc, + "@typescript-eslint": fixupPluginRules(typescriptEslintEslintPlugin), + tsdoc, }, languageOptions: { - parser: tsParser, - ecmaVersion: 5, - sourceType: "script", + parser: tsParser, + ecmaVersion: 5, + sourceType: "script", - parserOptions: { - project: "./tsconfig.json", - }, + parserOptions: { + project: "./tsconfig.json", + }, }, settings: {}, rules: { - "no-constant-condition": ["warn", { - checkLoops: false, - }], + "no-constant-condition": [ + "warn", + { + checkLoops: false, + }, + ], - "no-useless-escape": "warn", - "no-console": "warn", - "no-var": "warn", - "no-return-await": "warn", - "prefer-const": "warn", - "guard-for-in": "warn", - curly: "warn", - "no-param-reassign": "warn", - "prefer-spread": "warn", - "import/no-unresolved": "off", - "import/no-cycle": "error", - "import/no-default-export": "warn", - "tsdoc/syntax": "warn", - "@typescript-eslint/await-thenable": "warn", + "no-useless-escape": "warn", + "no-console": "warn", + "no-var": "warn", + "no-return-await": "warn", + "prefer-const": "warn", + "guard-for-in": "warn", + curly: "warn", + "no-param-reassign": "warn", + "prefer-spread": "warn", + "import/no-unresolved": "off", + "import/no-cycle": "error", + "import/no-default-export": "warn", + "tsdoc/syntax": "warn", + "@typescript-eslint/await-thenable": "warn", - "@typescript-eslint/array-type": ["warn", { - default: "generic", - }], + "@typescript-eslint/array-type": [ + "warn", + { + default: "generic", + }, + ], - "@typescript-eslint/naming-convention": ["warn", { - selector: "default", - format: ["camelCase", "UPPER_CASE", "PascalCase"], - leadingUnderscore: "allow", - }, { - selector: "typeLike", - format: ["PascalCase"], - leadingUnderscore: "allow", - }], + "@typescript-eslint/naming-convention": [ + "warn", + { + selector: "default", + format: ["camelCase", "UPPER_CASE", "PascalCase"], + leadingUnderscore: "allow", + }, + { + selector: "typeLike", + format: ["PascalCase"], + leadingUnderscore: "allow", + }, + ], - "@typescript-eslint/restrict-plus-operands": "warn", - //"@typescript-eslint/no-throw-literal": "warn", - "@typescript-eslint/unbound-method": "warn", - "@typescript-eslint/explicit-module-boundary-types": "warn", - //"@typescript-eslint/no-extra-semi": "warn", - "@typescript-eslint/no-extra-non-null-assertion": "warn", + "@typescript-eslint/restrict-plus-operands": "warn", + //"@typescript-eslint/no-throw-literal": "warn", + "@typescript-eslint/unbound-method": "warn", + "@typescript-eslint/explicit-module-boundary-types": "warn", + //"@typescript-eslint/no-extra-semi": "warn", + "@typescript-eslint/no-extra-non-null-assertion": "warn", - "@typescript-eslint/no-unused-vars": ["warn", { - argsIgnorePattern: "^_", - }], + "@typescript-eslint/no-unused-vars": [ + "warn", + { + argsIgnorePattern: "^_", + }, + ], - "@typescript-eslint/no-use-before-define": "warn", - "@typescript-eslint/no-for-in-array": "warn", - "@typescript-eslint/no-unsafe-argument": "warn", - "@typescript-eslint/no-unsafe-call": "warn", + "@typescript-eslint/no-use-before-define": "warn", + "@typescript-eslint/no-for-in-array": "warn", + "@typescript-eslint/no-unsafe-argument": "warn", + "@typescript-eslint/no-unsafe-call": "warn", - "@typescript-eslint/no-unnecessary-condition": ["warn", { - allowConstantLoopConditions: true, - }], + "@typescript-eslint/no-unnecessary-condition": [ + "warn", + { + allowConstantLoopConditions: true, + }, + ], - "@typescript-eslint/no-unnecessary-type-constraint": "warn", - "@typescript-eslint/no-implied-eval": "warn", - "@typescript-eslint/no-non-null-asserted-optional-chain": "warn", - "@typescript-eslint/no-invalid-void-type": "warn", - "@typescript-eslint/no-loss-of-precision": "warn", - "@typescript-eslint/no-confusing-void-expression": "warn", - "@typescript-eslint/no-redundant-type-constituents": "warn", - "@typescript-eslint/prefer-for-of": "warn", - "@typescript-eslint/prefer-includes": "warn", - "@typescript-eslint/prefer-string-starts-ends-with": "warn", - "@typescript-eslint/prefer-readonly": "warn", - "@typescript-eslint/prefer-regexp-exec": "warn", - "@typescript-eslint/prefer-nullish-coalescing": "warn", - "@typescript-eslint/prefer-optional-chain": "warn", - "@typescript-eslint/prefer-ts-expect-error": "warn", - "@typescript-eslint/indent": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-empty-interface": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-var-requires": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-unnecessary-type-constraint": "warn", + "@typescript-eslint/no-implied-eval": "warn", + "@typescript-eslint/no-non-null-asserted-optional-chain": "warn", + "@typescript-eslint/no-invalid-void-type": "warn", + "@typescript-eslint/no-loss-of-precision": "warn", + "@typescript-eslint/no-confusing-void-expression": "warn", + "@typescript-eslint/no-redundant-type-constituents": "warn", + "@typescript-eslint/prefer-for-of": "warn", + "@typescript-eslint/prefer-includes": "warn", + "@typescript-eslint/prefer-string-starts-ends-with": "warn", + "@typescript-eslint/prefer-readonly": "warn", + "@typescript-eslint/prefer-regexp-exec": "warn", + "@typescript-eslint/prefer-nullish-coalescing": "warn", + "@typescript-eslint/prefer-optional-chain": "warn", + "@typescript-eslint/prefer-ts-expect-error": "warn", + "@typescript-eslint/consistent-type-imports": [ + "error", + { + prefer: "type-imports", + disallowTypeAnnotations: false, + }, + ], + "@typescript-eslint/indent": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-empty-interface": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/ban-ts-comment": "off", }, -}]; + }, +]; diff --git a/src/CachedKeyDecoder.ts b/src/CachedKeyDecoder.ts index 73524f0..0de4a7d 100644 --- a/src/CachedKeyDecoder.ts +++ b/src/CachedKeyDecoder.ts @@ -16,8 +16,8 @@ export class CachedKeyDecoder implements KeyDecoder { hit = 0; miss = 0; private readonly caches: Array>; - private readonly maxKeyLength: number; - private readonly maxLengthPerKey: number; + readonly maxKeyLength: number; + readonly maxLengthPerKey: number; constructor(maxKeyLength = DEFAULT_MAX_KEY_LENGTH, maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY) { this.maxKeyLength = maxKeyLength; diff --git a/src/Decoder.ts b/src/Decoder.ts index 83b68a1..bba8804 100644 --- a/src/Decoder.ts +++ b/src/Decoder.ts @@ -3,10 +3,11 @@ import { ExtensionCodec } from "./ExtensionCodec.ts"; import { getInt64, getUint64, UINT32_MAX } from "./utils/int.ts"; import { utf8Decode } from "./utils/utf8.ts"; import { ensureUint8Array } from "./utils/typedArrays.ts"; -import { CachedKeyDecoder, KeyDecoder } from "./CachedKeyDecoder.ts"; +import { CachedKeyDecoder } from "./CachedKeyDecoder.ts"; import { DecodeError } from "./DecodeError.ts"; import type { ContextOf } from "./context.ts"; import type { ExtensionCodecType } from "./ExtensionCodec.ts"; +import type { KeyDecoder } from "./CachedKeyDecoder.ts"; export type DecoderOptions = Readonly< Partial<{ From 502575308b2d9d5457919a5f8f236fc81cf965e0 Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:23:56 +0900 Subject: [PATCH 09/10] revert hiding coverage reports --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 830d75c..f7c36cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MessagePack for ECMA-262/JavaScript/TypeScript -[![npm version](https://img.shields.io/npm/v/@msgpack/msgpack.svg)](https://www.npmjs.com/package/@msgpack/msgpack) ![CI](https://github.com/msgpack/msgpack-javascript/workflows/CI/badge.svg) [![minzip](https://badgen.net/bundlephobia/minzip/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack) [![tree-shaking](https://badgen.net/bundlephobia/tree-shaking/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack) +[![npm version](https://img.shields.io/npm/v/@msgpack/msgpack.svg)](https://www.npmjs.com/package/@msgpack/msgpack) ![CI](https://github.com/msgpack/msgpack-javascript/workflows/CI/badge.svg) [![codecov](https://codecov.io/gh/msgpack/msgpack-javascript/branch/master/graphs/badge.svg)](https://codecov.io/gh/msgpack/msgpack-javascript) [![minzip](https://badgen.net/bundlephobia/minzip/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack) [![tree-shaking](https://badgen.net/bundlephobia/tree-shaking/@msgpack/msgpack)](https://bundlephobia.com/result?p=@msgpack/msgpack) This library is an implementation of **MessagePack** for TypeScript and JavaScript, providing a compact and efficient binary serialization format. Learn more about MessagePack at: diff --git a/package.json b/package.json index a9cdd12..e67d3fd 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test:bun": "bun test test/bun.spec.ts", "test:fuzz": "npm exec --yes -- jsfuzz@git+https://gitlab.com/gitlab-org/security-products/analyzers/fuzzers/jsfuzz.git#39e6cf16613a0e30c7a7953f62e64292dbd5d3f3 --fuzzTime 60 --no-versifier test/decode.jsfuzz.js corpus", "cover:clean": "rimraf .nyc_output coverage/", - "cover:report": "npx nyc report --reporter=text-summary", + "cover:report": "npx nyc report --reporter=text-summary --reporter=html --reporter=json", "test:browser": "karma start --single-run", "test:browser:firefox": "karma start --single-run --browsers FirefoxHeadless", "test:browser:chrome": "karma start --single-run --browsers ChromeHeadless", From e059f46849c925bd02bc41d85e7c642d7bfb62a4 Mon Sep 17 00:00:00 2001 From: FUJI Goro Date: Sun, 25 May 2025 09:24:11 +0900 Subject: [PATCH 10/10] Revert "do not send coverage report to codecova (operation timed out)" This reverts commit 35b294a289eb007e5fa80b09cf45391bce5f7e8c. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb4dd7c..e26aaa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,10 @@ jobs: - run: npm install -g nyc - run: npm ci - run: npm run test:cover + - uses: codecov/codecov-action@v5 + with: + files: coverage/coverage-final.json + token: ${{ secrets.CODECOV_TOKEN }} browser: runs-on: ubuntu-latest