diff --git a/.c8rc.json b/.c8rc.json
deleted file mode 100644
index 55a126bf..00000000
--- a/.c8rc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "all": true,
- "include": ["src/**/*"],
- "exclude": ["src/types/**/*"],
- "reporter": ["lcov", "text"],
- "check-coverage": false,
- "watermarks": {
- "lines": [80, 95],
- "functions": [80, 95],
- "branches": [80, 95],
- "statements": [80, 95]
- }
-}
diff --git a/.commitlintrc.cjs b/.commitlintrc.cjs
index 450a0353..3000575b 100644
--- a/.commitlintrc.cjs
+++ b/.commitlintrc.cjs
@@ -2,7 +2,7 @@ module.exports = {
extends: ["@commitlint/config-conventional"],
parserPreset: {
parserOpts: {
- headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/,
+ headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/u,
},
},
};
diff --git a/.cspell.json b/.cspell.json
deleted file mode 100644
index 9cbed4f6..00000000
--- a/.cspell.json
+++ /dev/null
@@ -1,73 +0,0 @@
-{
- "version": "0.2",
- "language": "en",
- "ignorePaths": [
- ".github/workflows/**",
- "**/*.json",
- "**/*.jsonc",
- "**/CHANGELOG.md",
- "**/coverage/**",
- "**/dist/**",
- "**/node_modules/**",
- "pnpm-lock.yaml"
- ],
- "dictionaries": [
- "en_US",
- "filetypes",
- "misc",
- "node",
- "npm",
- "softwareTerms",
- "typescript"
- ],
- "import": ["@cspell/dict-cryptocurrencies/cspell-ext.json"],
- "ignoreRegExpList": [
- "/[^\\s@]+@([^\\s@]+\\.)+[^\\s@]{2,4}/",
- "/[A-Fa-f0-9]{6}/",
- "/[A-Za-z0-9]{32,}/",
- "// @ts-.*",
- "/\\STS\\S+/",
- "/`[^`]*`/",
- "/``[\\w\\W]*?``/",
- "/```[\\w\\W]*?```/",
- "/~~~[\\w\\W]*?~~~/",
- "\\(#.+?\\)"
- ],
- "words": [
- "bar",
- "baz",
- "codesandbox",
- "corge",
- "customizer",
- "deepmerge",
- "deepmergecustomoptions",
- "deepmergets",
- "denoify",
- "foo",
- "fred",
- "garply",
- "grault",
- "HKT",
- "HKTs",
- "kinded",
- "litecoin",
- "monero",
- "plugh",
- "quux",
- "qux",
- "sonarjs",
- "thud",
- "waldo",
- "xyzzy"
- ],
- "overrides": [
- {
- "filename": "**/*.{ts,js}",
- "ignoreRegExpList": ["/@[a-z]+/", "/#(end)?region/"],
- "includeRegExpList": [
- "/\\/\\*[\\s\\S]*?\\*\\/|([^\\\\:]|^)\\/\\/.*$/",
- "/(\\/\\/[^\\n\\r]*[\\n\\r]+)/"
- ]
- }
- ]
-}
diff --git a/.eslintrc.json b/.eslintrc.json
deleted file mode 100644
index 0ef19c85..00000000
--- a/.eslintrc.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "root": true,
- "env": {
- "node": true
- },
- "plugins": ["prettier"],
- "extends": [
- "@rebeccastevens/eslint-config/modern",
- "@rebeccastevens/eslint-config/typescript",
- "@rebeccastevens/eslint-config/common-overrides",
- "plugin:prettier/recommended",
- "prettier"
- ],
- "parserOptions": {
- "project": [
- "./tsconfig.json",
- "./benchmark/tsconfig.json",
- "./tests/tsconfig.json"
- ]
- },
- "ignorePatterns": [
- "/coverage/",
- "/dist/",
- "/tests/modules/",
- "/tests/types/",
- "/types-legacy/",
- "/**/*.md"
- ],
- "overrides": [
- {
- "files": "src/**",
- "env": {
- "node": false
- }
- },
- {
- "files": ["src/deepmerge-into.ts", "src/defaults/into.ts"],
- "extends": ["plugin:functional/off"],
- "rules": {}
- },
- {
- "files": "**/*.test.ts",
- "plugins": ["ava"],
- "extends": ["plugin:ava/recommended"],
- "rules": {
- "functional/no-classes": "off"
- }
- }
- ]
-}
diff --git a/.gitattributes b/.gitattributes
index 4d690c43..b55f6cf3 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -8,6 +8,7 @@
**/tsconfig.json linguist-language=jsonc
**/tsconfig.*.json linguist-language=jsonc
/.lintstagedrc linguist-language=json
+/.markdownlint.json linguist-language=jsonc
/.vscode/*.json linguist-language=jsonc
/dist/** linguist-generated
diff --git a/.github/actions/prepare/action.yml b/.github/actions/prepare/action.yml
index 21d30c01..a9042009 100644
--- a/.github/actions/prepare/action.yml
+++ b/.github/actions/prepare/action.yml
@@ -5,7 +5,7 @@ inputs:
node-version:
required: false
description: "`node-version` passed to `actions/setup-node`."
- default: latest
+ default: "20"
runs:
using: "composite"
@@ -16,7 +16,7 @@ runs:
git config --global user.name ${GITHUB_ACTOR}
shell: bash
- uses: pnpm/action-setup@v2
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: "pnpm"
diff --git a/.github/renovate.json b/.github/renovate.json
index 7d6d2b6f..7e752fed 100644
--- a/.github/renovate.json
+++ b/.github/renovate.json
@@ -1,62 +1,62 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
+ "automergeStrategy": "rebase",
"extends": [
+ ":automergeAll",
+ ":automergePr",
":ignoreModulesAndTests",
- "replacements:all",
- "workarounds:all",
+ ":prConcurrentLimitNone",
+ ":prHourlyLimitNone",
+ ":semanticCommits",
"group:allNonMajor",
"group:monorepos",
"group:recommended",
- ":automergeAll",
- ":automergePr",
- ":semanticCommits",
- ":prHourlyLimitNone",
- ":prConcurrentLimitNone",
"helpers:disableTypesNodeMajor",
- "schedule:weekly"
+ "replacements:all",
+ "schedule:monthly",
+ "workarounds:all"
],
"labels": ["Type: Maintenance", ":blue_heart:"],
- "automergeStrategy": "rebase",
- "postUpdateOptions": ["pnpmDedupe"],
"packageRules": [
{
"matchPaths": ["+(benchmark/package.json)"],
"rangeStrategy": "bump",
- "semanticCommitType": "chore",
- "semanticCommitScope": "benchmark"
+ "semanticCommitScope": "benchmark",
+ "semanticCommitType": "chore"
},
{
- "matchManagers": ["npm"],
+ "major": {
+ "semanticCommitType": "build"
+ },
"matchDepTypes": ["dependencies"],
+ "matchManagers": ["npm"],
"rangeStrategy": "update-lockfile",
- "semanticCommitType": "chore",
"semanticCommitScope": "deps",
- "major": {
- "semanticCommitType": "build"
- }
+ "semanticCommitType": "chore"
},
{
- "matchManagers": ["npm"],
"matchDepTypes": ["devDependencies"],
+ "matchManagers": ["npm"],
"rangeStrategy": "pin",
- "semanticCommitType": "chore",
- "semanticCommitScope": "dev-deps"
+ "semanticCommitScope": "dev-deps",
+ "semanticCommitType": "chore"
},
{
- "matchManagers": ["npm"],
+ "major": {
+ "semanticCommitType": "build"
+ },
"matchDepTypes": ["peerDependencies"],
+ "matchManagers": ["npm"],
"rangeStrategy": "widen",
- "semanticCommitType": "chore",
"semanticCommitScope": "peer-deps",
- "major": {
- "semanticCommitType": "build"
- }
+ "semanticCommitType": "chore"
},
{
"matchManagers": ["github-actions"],
"rangeStrategy": "replace",
- "semanticCommitType": "ci",
- "semanticCommitScope": "dev-deps"
+ "semanticCommitScope": "dev-deps",
+ "semanticCommitType": "ci"
}
- ]
+ ],
+ "postUpdateOptions": ["pnpmDedupe"]
}
diff --git a/.github/workflows/accessibility-alt-text-bot.yml b/.github/workflows/accessibility-alt-text-bot.yml
new file mode 100644
index 00000000..a0f97409
--- /dev/null
+++ b/.github/workflows/accessibility-alt-text-bot.yml
@@ -0,0 +1,26 @@
+name: Accessibility Alt Text Bot
+
+on:
+ issue_comment:
+ types:
+ - created
+ - edited
+ issues:
+ types:
+ - edited
+ - opened
+ pull_request:
+ types:
+ - edited
+ - opened
+
+permissions:
+ issues: write
+ pull-requests: write
+
+jobs:
+ accessibility_alt_text_bot:
+ if: ${{ !endsWith(github.actor, '[bot]') }}
+ runs-on: ubuntu-latest
+ steps:
+ - uses: github/accessibility-alt-text-bot@v1.5.0
diff --git a/.github/workflows/build-node.yml b/.github/workflows/build-node.yml
index d699ad38..d670bbf5 100644
--- a/.github/workflows/build-node.yml
+++ b/.github/workflows/build-node.yml
@@ -9,6 +9,6 @@ jobs:
build_node:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run build:node
diff --git a/.github/workflows/lint-js.yml b/.github/workflows/lint-js.yml
index 430f9cfb..e1f66705 100644
--- a/.github/workflows/lint-js.yml
+++ b/.github/workflows/lint-js.yml
@@ -9,6 +9,6 @@ jobs:
lint_js:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run lint:js
diff --git a/.github/workflows/lint-knip-dev.yml b/.github/workflows/lint-knip-dev.yml
index de4bc1c3..94d5a4b5 100644
--- a/.github/workflows/lint-knip-dev.yml
+++ b/.github/workflows/lint-knip-dev.yml
@@ -9,6 +9,6 @@ jobs:
lint_knip_dev:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run lint:knip:development
diff --git a/.github/workflows/lint-knip-prod.yml b/.github/workflows/lint-knip-prod.yml
index 70c86902..8c707e92 100644
--- a/.github/workflows/lint-knip-prod.yml
+++ b/.github/workflows/lint-knip-prod.yml
@@ -9,6 +9,6 @@ jobs:
lint_knip_prod:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run lint:knip:production
diff --git a/.github/workflows/lint-markdown.yml b/.github/workflows/lint-markdown.yml
index 278f375b..cfbd02ab 100644
--- a/.github/workflows/lint-markdown.yml
+++ b/.github/workflows/lint-markdown.yml
@@ -9,6 +9,6 @@ jobs:
lint_markdown:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run lint:md
diff --git a/.github/workflows/lint-prettier.yml b/.github/workflows/lint-packages.yml
similarity index 57%
rename from .github/workflows/lint-prettier.yml
rename to .github/workflows/lint-packages.yml
index c666f1e1..9a21e8f1 100644
--- a/.github/workflows/lint-prettier.yml
+++ b/.github/workflows/lint-packages.yml
@@ -1,4 +1,4 @@
-name: Prettier
+name: Lint Packages
on:
pull_request:
@@ -6,9 +6,9 @@ on:
workflow_call:
jobs:
- lint_prettier:
+ lint_packages:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- - run: pnpm run lint:prettier
+ - run: pnpm run lint:packages
diff --git a/.github/workflows/lint-spelling.yml b/.github/workflows/lint-spelling.yml
index e877d46d..d54881b9 100644
--- a/.github/workflows/lint-spelling.yml
+++ b/.github/workflows/lint-spelling.yml
@@ -9,6 +9,6 @@ jobs:
lint_spelling:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run lint:spelling
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b3311fdf..3a184f32 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -4,7 +4,6 @@ on:
push:
branches:
- main
- - next
permissions:
contents: write
@@ -18,14 +17,16 @@ concurrency:
jobs:
lint_js:
uses: ./.github/workflows/lint-js.yml
+ lint_knip_dev:
+ uses: ./.github/workflows/lint-knip-dev.yml
lint_knip_prod:
uses: ./.github/workflows/lint-knip-prod.yml
lint_markdown:
uses: ./.github/workflows/lint-markdown.yml
+ lint_packages:
+ uses: ./.github/workflows/lint-packages.yml
lint_spelling:
uses: ./.github/workflows/lint-spelling.yml
- lint_prettier:
- uses: ./.github/workflows/lint-prettier.yml
test_js:
uses: ./.github/workflows/test-js.yml
test_types:
@@ -38,14 +39,14 @@ jobs:
- lint_js
- lint_knip_prod
- lint_markdown
+ - lint_packages
- lint_spelling
- - lint_prettier
- test_js
- test_types
- type_check
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml
index ba4e89a8..f097be0a 100644
--- a/.github/workflows/semantic-pr.yml
+++ b/.github/workflows/semantic-pr.yml
@@ -12,6 +12,6 @@ jobs:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- - uses: amannn/action-semantic-pull-request@v5.2.0
+ - uses: amannn/action-semantic-pull-request@v5.4.0
env:
GITHUB_TOKEN: ${{ github.token }}
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
index 07aba67f..b03918db 100644
--- a/.github/workflows/stale.yml
+++ b/.github/workflows/stale.yml
@@ -9,7 +9,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- - uses: actions/stale@v7
+ - uses: actions/stale@v9
with:
days-before-issue-stale: 60
days-before-issue-close: 7
diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml
index 0c290459..aac6f610 100644
--- a/.github/workflows/sync-labels.yml
+++ b/.github/workflows/sync-labels.yml
@@ -4,14 +4,21 @@ on:
push:
branches:
- main
+ paths:
+ - .github/labels.yml
workflow_dispatch:
+permissions:
+ pull-requests: write
+
jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: micnncim/action-label-syncer@v1
+ with:
+ manifest: .github/labels.yml
env:
GITHUB_TOKEN: ${{ github.token }}
diff --git a/.github/workflows/test-js.yml b/.github/workflows/test-js.yml
index 6324957d..e55a075f 100644
--- a/.github/workflows/test-js.yml
+++ b/.github/workflows/test-js.yml
@@ -9,7 +9,7 @@ jobs:
test_js:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run test:js
- - uses: codecov/codecov-action@v3
+ - uses: codecov/codecov-action@v4
diff --git a/.github/workflows/test-types.yml b/.github/workflows/test-types.yml
index b7bc7abc..2b7f5bb8 100644
--- a/.github/workflows/test-types.yml
+++ b/.github/workflows/test-types.yml
@@ -9,7 +9,7 @@ jobs:
test_js:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run test:types
- - uses: codecov/codecov-action@v3
+ - uses: codecov/codecov-action@v4
diff --git a/.github/workflows/type-check.yml b/.github/workflows/type-check.yml
index d6cba21c..a3edaaf0 100644
--- a/.github/workflows/type-check.yml
+++ b/.github/workflows/type-check.yml
@@ -9,6 +9,6 @@ jobs:
type-check:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run type-check
diff --git a/.husky/commit-msg b/.husky/commit-msg
index 61681a81..6a2e4c84 100755
--- a/.husky/commit-msg
+++ b/.husky/commit-msg
@@ -1,4 +1 @@
-#!/bin/sh
-. "$(dirname "$0")/_/husky.sh"
-
pnpm exec commitlint --edit $1
diff --git a/.husky/pre-commit b/.husky/pre-commit
index 5e592735..5ee7abd8 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1,4 +1 @@
-#!/bin/sh
-. "$(dirname "$0")/_/husky.sh"
-
pnpm exec lint-staged
diff --git a/.lintstagedrc.yml b/.lintstagedrc.yml
index a024f998..3f6d2b9f 100644
--- a/.lintstagedrc.yml
+++ b/.lintstagedrc.yml
@@ -1,12 +1,16 @@
"*.{json,yml}":
- - prettier --ignore-unknown --write
+ - eslint --fix
+ - cspell lint --no-progress --show-suggestions --show-context --no-must-find-files --dot
-"*.ts":
- - prettier --ignore-unknown --write
+"*.?([cm])[jt]s?(x)":
- eslint --fix
- - cspell
+ - cspell lint --no-progress --show-suggestions --show-context --no-must-find-files --dot
+ - tsc-files -p tsconfig.build.json --noEmit
"*.md":
- - prettier --ignore-unknown --write
+ - eslint --fix
- markdownlint --config=.markdownlint.json --ignore-path=.markdownlintignore
- - cspell
+ - cspell lint --no-progress --show-suggestions --show-context --no-must-find-files --dot
+
+pnpm-lock.yaml:
+ - "pnpm dedupe && :"
diff --git a/.markdownlint.json b/.markdownlint.json
index bfaa9566..088893f5 100644
--- a/.markdownlint.json
+++ b/.markdownlint.json
@@ -1,102 +1,292 @@
{
"default": false,
+ "extends": "markdownlint/style/prettier",
- // MD001/heading-increment/header-increment - Heading levels should only increment by one level at a time
+ // MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md001.md
"MD001": true,
- // MD003/heading-style/header-style - Heading style
- "MD003": { "style": "atx" },
- // MD004/ul-style - Unordered list style
- "MD004": { "style": "dash" },
- // MD005/list-indent - Inconsistent indentation for list items at the same level
+
+ // MD003/heading-style : Heading style : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md003.md
+ "MD003": {
+ // Heading style
+ "style": "atx"
+ },
+
+ // MD004/ul-style : Unordered list style : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md
+ "MD004": {
+ // List style
+ "style": "dash"
+ },
+
+ // MD005/list-indent : Inconsistent indentation for list items at the same level : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md005.md
"MD005": true,
- // MD007/ul-indent - Unordered list indentation
- "MD007": true,
- // MD009/no-trailing-spaces - Trailing spaces
- "MD009": true,
- // MD010/no-hard-tabs - Hard tabs
- "MD010": true,
- // MD011/no-reversed-links - Reversed link syntax
+
+ // MD007/ul-indent : Unordered list indentation : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md007.md
+ "MD007": {
+ // Spaces for indent
+ "indent": 2,
+ // Whether to indent the first level of the list
+ "start_indented": false,
+ // Spaces for first level indent (when start_indented is set)
+ "start_indent": 2
+ },
+
+ // MD009/no-trailing-spaces : Trailing spaces : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md009.md
+ "MD009": {
+ // Spaces for line break - 0 to disable
+ "br_spaces": 0,
+ // Allow spaces for empty lines in list items
+ "list_item_empty_lines": false,
+ // Include unnecessary breaks
+ "strict": false
+ },
+
+ // MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md010.md
+ "MD010": {
+ // Include code blocks
+ "code_blocks": true,
+ // Fenced code languages to ignore
+ "ignore_code_languages": [],
+ // Number of spaces for each hard tab
+ "spaces_per_tab": 2
+ },
+
+ // MD011/no-reversed-links : Reversed link syntax : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md011.md
"MD011": true,
- // MD012/no-multiple-blanks - Multiple consecutive blank lines
- "MD012": true,
- // MD013/line-length - Line length
- "MD013": { "line_length": 99999 }, // no line length
- // MD014/commands-show-output - Dollar signs used before commands without showing output
- "MD014": false,
- // MD018/no-missing-space-atx - No space after hash on atx style heading
+
+ // MD012/no-multiple-blanks : Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md012.md
+ "MD012": {
+ // Consecutive blank lines
+ "maximum": 1
+ },
+
+ // MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md013.md
+ "MD013": {
+ // Number of characters
+ "line_length": 160,
+ // Number of characters for headings
+ "heading_line_length": 160,
+ // Number of characters for code blocks
+ "code_block_line_length": 120,
+ // Include code blocks
+ "code_blocks": true,
+ // Include tables
+ "tables": false,
+ // Include headings
+ "headings": true,
+ // Strict length checking
+ "strict": false,
+ // Stern length checking
+ "stern": false
+ },
+
+ // MD014/commands-show-output : Dollar signs used before commands without showing output : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md014.md
+ // "MD014": true,
+
+ // MD018/no-missing-space-atx : No space after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md018.md
"MD018": true,
- // MD019/no-multiple-space-atx - Multiple spaces after hash on atx style heading
+
+ // MD019/no-multiple-space-atx : Multiple spaces after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md019.md
"MD019": true,
- // MD020/no-missing-space-closed-atx - No space inside hashes on closed atx style heading
- // "MD020": false,
- // MD021/no-multiple-space-closed-atx - Multiple spaces inside hashes on closed atx style heading
- // "MD021": true,
- // MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines
- "MD022": true,
- // MD023/heading-start-left/header-start-left - Headings must start at the beginning of the line
+
+ // MD020/no-missing-space-closed-atx : No space inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md020.md
+ "MD020": true,
+
+ // MD021/no-multiple-space-closed-atx : Multiple spaces inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md021.md
+ "MD021": true,
+
+ // MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md022.md
+ "MD022": {
+ // Blank lines above heading
+ "lines_above": 1,
+ // Blank lines below heading
+ "lines_below": 1
+ },
+
+ // MD023/heading-start-left : Headings must start at the beginning of the line : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md023.md
"MD023": true,
- // MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
- "MD024": { "siblings_only": true },
- // MD025/single-title/single-h1 - Multiple top level headings in the same document
+
+ // MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md024.md
+ "MD024": {
+ // Only check sibling headings
+ "siblings_only": true
+ },
+
+ // MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md025.md
"MD025": false,
- // MD026/no-trailing-punctuation - Trailing punctuation in heading
- "MD026": true,
- // MD027/no-multiple-space-blockquote - Multiple spaces after blockquote symbol
+
+ // MD026/no-trailing-punctuation : Trailing punctuation in heading : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md026.md
+ "MD026": {
+ // Punctuation characters
+ "punctuation": ".,;:!。,;:!"
+ },
+
+ // MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md027.md
"MD027": true,
- // MD028/no-blanks-blockquote - Blank line inside blockquote
+
+ // MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md028.md
"MD028": true,
- // MD029/ol-prefix - Ordered list item prefix
- "MD029": true,
- // MD030/list-marker-space - Spaces after list markers
- "MD030": true,
- // MD031/blanks-around-fences - Fenced code blocks should be surrounded by blank lines
- "MD031": true,
- // MD032/blanks-around-lists - Lists should be surrounded by blank lines
+
+ // MD029/ol-prefix : Ordered list item prefix : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md029.md
+ "MD029": {
+ // List style
+ "style": "one_or_ordered"
+ },
+
+ // MD030/list-marker-space : Spaces after list markers : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md030.md
+ "MD030": {
+ // Spaces for single-line unordered list items
+ "ul_single": 1,
+ // Spaces for single-line ordered list items
+ "ol_single": 1,
+ // Spaces for multi-line unordered list items
+ "ul_multi": 1,
+ // Spaces for multi-line ordered list items
+ "ol_multi": 1
+ },
+
+ // MD031/blanks-around-fences : Fenced code blocks should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md031.md
+ "MD031": {
+ // Include list items
+ "list_items": true
+ },
+
+ // MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md032.md
"MD032": true,
- // MD033/no-inline-html - Inline HTML
- "MD033": {
- "allowed_elements": [
- "br",
- "div",
- "img",
- "sub",
- "sup",
- "span",
- "details",
- "summary"
- ]
- },
- // MD034/no-bare-urls - Bare URL used
+
+ // MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md033.md
+ // "MD033": {
+ // // Allowed elements
+ // "allowed_elements": ["details", "summary", "sub", "sup", "img"]
+ // },
+
+ // MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md034.md
"MD034": true,
- // MD035/hr-style - Horizontal rule style
- "MD035": { "style": "---" },
- // MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading
- "MD036": true,
- // MD037/no-space-in-emphasis - Spaces inside emphasis markers
+
+ // MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md035.md
+ "MD035": {
+ // Horizontal rule style
+ "style": "---"
+ },
+
+ // MD036/no-emphasis-as-heading : Emphasis used instead of a heading : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md036.md
+ "MD036": {
+ // Punctuation characters
+ "punctuation": ".,;:!?。,;:!?"
+ },
+
+ // MD037/no-space-in-emphasis : Spaces inside emphasis markers : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md037.md
"MD037": true,
- // MD038/no-space-in-code - Spaces inside code span elements
+
+ // MD038/no-space-in-code : Spaces inside code span elements : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md038.md
"MD038": true,
- // MD039/no-space-in-links - Spaces inside link text
+
+ // MD039/no-space-in-links : Spaces inside link text : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md039.md
"MD039": true,
- // MD040/fenced-code-language - Fenced code blocks should have a language specified
- "MD040": true,
- // MD041/first-line-heading/first-line-h1 - First line in file should be a top level heading
- "MD041": false,
- // MD042/no-empty-links - No empty links
+
+ // MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md040.md
+ "MD040": {
+ // List of languages
+ "allowed_languages": [],
+ // Require language only
+ "language_only": false
+ },
+
+ // MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md041.md
+ // "MD041": {
+ // // Heading level
+ // "level": 1,
+ // // RegExp for matching title in front matter
+ // "front_matter_title": "^\\s*title\\s*[:=]"
+ // },
+
+ // MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md042.md
"MD042": true,
- // MD043/required-headings/required-headers - Required heading structure
- "MD043": false,
- // MD044/proper-names - Proper names should have the correct capitalization
+
+ // MD043/required-headings : Required heading structure : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md043.md
+ // "MD043": {
+ // // List of headings
+ // "headings": [],
+ // // Match case of headings
+ // "match_case": false
+ // },
+
+ // MD044/proper-names : Proper names should have the correct capitalization : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md044.md
// "MD044": {
- // "names": ["JavaScript", "TypeScript"],
- // "code_blocks": false
+ // // List of proper names
+ // "names": [],
+ // // Include code blocks
+ // "code_blocks": true,
+ // // Include HTML elements
+ // "html_elements": true
// },
- // MD045/no-alt-text - Images should have alternate text (alt text)
+
+ // MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md045.md
"MD045": true,
- // MD046/code-block-style - Code block style
- "MD046": { "style": "fenced" },
- // MD047/single-trailing-newline - Files should end with a single newline character
+
+ // MD046/code-block-style : Code block style : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md046.md
+ "MD046": {
+ // Block style
+ "style": "fenced"
+ },
+
+ // MD047/single-trailing-newline : Files should end with a single newline character : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md047.md
"MD047": true,
- // MD048/code-fence-style - Code fence style
- "MD048": { "style": "backtick" }
+
+ // MD048/code-fence-style : Code fence style : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md048.md
+ "MD048": {
+ // Code fence style
+ "style": "backtick"
+ },
+
+ // MD049/emphasis-style : Emphasis style : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md049.md
+ "MD049": {
+ // Emphasis style
+ "style": "underscore"
+ },
+
+ // MD050/strong-style : Strong style : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md050.md
+ "MD050": {
+ // Strong style
+ "style": "asterisk"
+ },
+
+ // MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md051.md
+ "MD051": true,
+
+ // MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md052.md
+ "MD052": {
+ // Include shortcut syntax
+ "shortcut_syntax": false
+ },
+
+ // MD053/link-image-reference-definitions : Link and image reference definitions should be needed : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md053.md
+ "MD053": {
+ // Ignored definitions
+ "ignored_definitions": ["//"]
+ },
+
+ // MD054/link-image-style : Link and image style : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md054.md
+ "MD054": {
+ // Allow autolinks
+ "autolink": true,
+ // Allow inline links and images
+ "inline": true,
+ // Allow full reference links and images
+ "full": true,
+ // Allow collapsed reference links and images
+ "collapsed": true,
+ // Allow shortcut reference links and images
+ "shortcut": true,
+ // Allow URLs as inline links
+ "url_inline": true
+ },
+
+ // MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md055.md
+ "MD055": {
+ // Table pipe style
+ "style": "leading_and_trailing"
+ },
+
+ // MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md056.md
+ "MD056": true
}
diff --git a/.markdownlintignore b/.markdownlintignore
index e7becf85..06a1096d 100644
--- a/.markdownlintignore
+++ b/.markdownlintignore
@@ -1,2 +1,3 @@
-node_modules
+dist/
+node_modules/
CHANGELOG.md
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 00000000..d8dc75d1
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1,4 @@
+save-prefix=""
+shamefully-hoist=true
+strict-peer-dependencies=false
+shell-emulator=true
diff --git a/.nvmrc b/.nvmrc
index 6d80269a..2b9cabc0 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1 @@
-18.16.0
+20.12.0
diff --git a/.prettierignore b/.prettierignore
deleted file mode 100644
index f46d3c5c..00000000
--- a/.prettierignore
+++ /dev/null
@@ -1,6 +0,0 @@
-/benchmark/data.json
-/CHANGELOG.md
-/coverage
-/dist/
-/types-legacy/
-pnpm-lock.yaml
diff --git a/.prettierrc.yml b/.prettierrc.yml
index 24ae692a..ca544b67 100644
--- a/.prettierrc.yml
+++ b/.prettierrc.yml
@@ -3,4 +3,12 @@
plugins:
- prettier-plugin-packagejson
-embeddedLanguageFormatting: "off"
+trailingComma: "all"
+
+overrides:
+ - files: "*.md"
+ options:
+ embeddedLanguageFormatting: "off"
+ - files: ".nvmrc"
+ options:
+ parser: "yaml"
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 17fab0c0..876c534b 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,7 +1,9 @@
{
"recommendations": [
+ "DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
- "esbenp.prettier-vscode"
+ "esbenp.prettier-vscode",
+ "streetsidesoftware.code-spell-checker"
]
}
diff --git a/.vscode/settings.json b/.vscode/settings.json
index e855c934..d49a6aa1 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,32 +1,59 @@
{
- "files.exclude": {
- "coverage/": true,
- "build/": true,
- "dist/": true
+ // Enable the ESlint flat config support
+ "eslint.experimental.useFlatConfig": true,
+
+ // Disable the default formatter, use eslint instead
+ "prettier.enable": false,
+ "editor.formatOnSave": false,
+ "editor.codeActionsOnSave": {
+ "source.fixAll": "explicit"
},
"files.trimTrailingWhitespace": true,
- "search.exclude": {
- "**/.git/": true,
- ".nyc_output/": true,
- ".vscode/": true,
- "dist/": true,
- "pnpm-lock.yaml": true
- },
- "typescript.tsdk": "./node_modules/typescript/lib",
- "files.associations": {
- ".markdownlint.json": "jsonc",
- ".markdownlintignore": "ignore"
- },
- "[json]": {
- "editor.defaultFormatter": "esbenp.prettier-vscode",
- "editor.formatOnSave": true
- },
- "[jsonc]": {
- "editor.defaultFormatter": "esbenp.prettier-vscode",
- "editor.formatOnSave": true
- },
- "[typescript]": {
- "editor.defaultFormatter": "esbenp.prettier-vscode",
- "editor.formatOnSave": true
+
+ // Silent the stylistic rules in you IDE, but still auto fix them
+ "eslint.rules.customizations": [
+ { "rule": "style/*", "severity": "off" },
+ { "rule": "*-indent", "severity": "off" },
+ { "rule": "*-spacing", "severity": "off" },
+ { "rule": "*-spaces", "severity": "off" },
+ { "rule": "*-order", "severity": "off" },
+ { "rule": "*-dangle", "severity": "off" },
+ { "rule": "*-newline", "severity": "off" },
+ { "rule": "*quotes", "severity": "off" },
+ { "rule": "*semi", "severity": "off" }
+ ],
+
+ // Enable eslint for all supported languages
+ "eslint.validate": [
+ "javascript",
+ "javascriptreact",
+ "typescript",
+ "typescriptreact",
+ "vue",
+ "html",
+ "markdown",
+ "json",
+ "jsonc",
+ "yaml"
+ ],
+
+ "editor.rulers": [80],
+ "typescript.tsdk": "node_modules/typescript/lib",
+ "json.schemas": [
+ {
+ "fileMatch": [
+ "*.jsonc",
+ "tsconfig.json",
+ "tsconfig.*.json",
+ ".vscode/*.json"
+ ],
+ "schema": {
+ "allowTrailingCommas": true
+ }
+ }
+ ],
+
+ "[markdown]": {
+ "editor.rulers": [120]
}
}
diff --git a/DONATIONS.md b/DONATIONS.md
index 9258a292..e4fa4978 100644
--- a/DONATIONS.md
+++ b/DONATIONS.md
@@ -2,32 +2,36 @@
Any donations would be much appreciated. 😄
+## Enterprise Users
+
+`deepmerge-ts` is available as part of the [Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-deepmerge-ts).
+
## Real money
-[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/K3K2ALYW6)
+[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/rebeccastevens)
## Cryptocurrencies
- Bitcoin
+ Bitcoin
-![bitcoin address QR code](https://github.com/RebeccaStevens/RebeccaStevens/blob/main/assets/cryptocurrencies/wallets/bitcoin.png)\
+![bitcoin address QR code](https://raw.githubusercontent.com/RebeccaStevens/RebeccaStevens/main/assets/cryptocurrencies/wallets/bitcoin.png)\
bc1qgr2xwvkpztsaq9kplud84r3dfz4g3e7d5c5lxm
- Ethereum
+ Ethereum
-![ethereum address QR code](https://github.com/RebeccaStevens/RebeccaStevens/blob/main/assets/cryptocurrencies/wallets/ethereum.png)\
+![ethereum address QR code](https://raw.githubusercontent.com/RebeccaStevens/RebeccaStevens/main/assets/cryptocurrencies/wallets/ethereum.png)\
0x643769d1DD2Cb912656dAA27C1b97e5A81EF9fd2
- Litecoin
+ Litecoin
-![litecoin address QR code](https://github.com/RebeccaStevens/RebeccaStevens/blob/main/assets/cryptocurrencies/wallets/litecoin.png)\
+![litecoin address QR code](https://raw.githubusercontent.com/RebeccaStevens/RebeccaStevens/main/assets/cryptocurrencies/wallets/litecoin.png)\
ltc1qxr7p6z4hrh87g9mjjk67chyduwrh2nfrpxksjv
diff --git a/README.md b/README.md
index 2e8a5f80..33f70909 100644
--- a/README.md
+++ b/README.md
@@ -50,8 +50,8 @@ yarn add deepmerge-ts
// import_map.json
{
"imports": {
- "deepmerge-ts": "https://deno.land/x/deepmergets@__version__/dist/deno/index.ts"
- }
+ "deepmerge-ts": "https://deno.land/x/deepmergets@__version__/dist/deno/index.ts",
+ },
}
```
diff --git a/ava.config.mjs b/ava.config.mjs
deleted file mode 100644
index 9710b619..00000000
--- a/ava.config.mjs
+++ /dev/null
@@ -1,14 +0,0 @@
-const avaConfig = {
- files: ["tests/**/*.test.*"],
- timeout: "5m",
- extensions: {
- ts: "module",
- },
- nodeArguments: [
- "--no-warnings",
- "--loader=ts-paths-esm-loader/transpile-only",
- "--experimental-specifier-resolution=node",
- ],
-};
-
-export default avaConfig;
diff --git a/benchmark/run.ts b/benchmark/run.ts
index 6b470860..700403ae 100644
--- a/benchmark/run.ts
+++ b/benchmark/run.ts
@@ -1,13 +1,12 @@
-import Benchmark from "benchmark";
-
-import { constants as fsConstants, promises as fs } from "node:fs";
+import { promises as fs, constants as fsConstants } from "node:fs";
import * as path from "node:path";
-import { deepmerge as deepmergeTs } from "deepmerge-ts";
+import Benchmark from "benchmark";
import { all as deepmerge } from "deepmerge";
+import { deepmerge as deepmergeTs } from "deepmerge-ts";
+import { merge as lodashMerge } from "lodash";
import { merge as mergeAnything } from "merge-anything";
import { Accumulator as ObjectAccumulator } from "object-accumulator";
-import { merge as lodashMerge } from "lodash";
const benchmarkDataFile = path.join(__dirname, "data.json");
@@ -18,7 +17,7 @@ const benchmarkDataSets: any[][] = await fs
const data = await fs.readFile(benchmarkDataFile, { encoding: "utf8" });
return JSON.parse(data);
})
- .catch(async (error) => {
+ .catch(async (error: unknown) => {
if (error?.code !== "ENOENT") {
throw error;
}
@@ -43,7 +42,7 @@ for (let m_i = 0; m_i < benchmarkDataSets.length; m_i++) {
console.log(
`\nRunning benchmarks for data set ${m_i + 1} of ${
benchmarkDataSets.length
- }:\n`
+ }:\n`,
);
// add tests
@@ -69,13 +68,13 @@ for (let m_i = 0; m_i < benchmarkDataSets.length; m_i++) {
// eslint-disable-next-line func-names
.on("complete", function () {
// @ts-expect-error When need to access the "this" value
- // eslint-disable-next-line unicorn/no-this-assignment, @typescript-eslint/no-this-alias, no-invalid-this
+ // eslint-disable-next-line unicorn/no-this-assignment, ts/no-this-alias
const results = this;
console.log(
`\nFastest is ${results.filter("fastest").map("name")} for data set ${
m_i + 1
- } of ${benchmarkDataSets.length}`
+ } of ${benchmarkDataSets.length}`,
);
})
.run({ async: false });
@@ -98,8 +97,8 @@ function generateBenchmarkDataItem(maxProperties, depth, currentDepth = 0) {
const propertiesOptions = shuffle(
Array.from({ length: maxProperties }, (_, i) =>
- String.fromCodePoint(i + 65)
- )
+ String.fromCodePoint(i + 65),
+ ),
);
for (let m_i = 0; m_i < properties; m_i++) {
diff --git a/cspell.config.yml b/cspell.config.yml
new file mode 100644
index 00000000..3d86c053
--- /dev/null
+++ b/cspell.config.yml
@@ -0,0 +1,66 @@
+$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json
+version: "0.2"
+
+language: en-US
+
+dictionaryDefinitions:
+ - name: project-dictionary
+ path: ./project-dictionary.txt
+ addWords: true
+
+allowCompoundWords: true
+caseSensitive: false
+useGitignore: true
+
+dictionaries:
+ - en_US
+ - bash
+ - filetypes
+ - fonts
+ - html
+ - misc
+ - node
+ - npm
+ - softwareTerms
+ - typescript
+ - project-dictionary
+
+import:
+ - "@cspell/dict-cryptocurrencies/cspell-ext.json"
+
+ignorePaths:
+ - .eslintrc.json
+ - .git
+ - .gitattributes
+ - .gitignore
+ - .husky
+ - .lintstagedrc.yml
+ - .markdownlint.json
+ - .npmrc
+ - .prettierignore
+ - .prettierrc.yml
+ - .vscode
+ - CHANGELOG.md
+ - coverage
+ - cspell.config.yml
+ - dist
+ - node_modules
+ - package.json
+ - patches
+ - pnpm-lock.yaml
+ - project-dictionary.txt
+
+ignoreRegExpList:
+ - /\b[a-f0-9]{6}\b/ui # ignore hex color codes
+ - /\b[a-z0-9]{32,}\b/ui # ignore long string of hex characters
+ - /`[^`]*`/u # ignore things in `...`
+ - /```[\w\W]*?```/u # ignore things in ```...```
+
+overrides:
+ - filename: "**/*.yml"
+ ignoreRegExpList:
+ - /^\s*(?:[a-z0-9]|-|_|\"|')+:/ui # ignore keys
+
+ - filename: ".github/(actions|workflows)/*.yml"
+ ignoreRegExpList:
+ - /\b(?:[A-Za-z0-9\-_])+\/(?:[A-Za-z0-9\-_])+@v\d+(?:\.\d+){0,2}\b/ui # ignore action
diff --git a/docs/deepmergeCustom.md b/docs/deepmergeCustom.md
index ead13c9e..6c443a03 100644
--- a/docs/deepmergeCustom.md
+++ b/docs/deepmergeCustom.md
@@ -83,7 +83,7 @@ For example, the following `customizedDeepmerge` function is equivalent to the t
```ts
const customizedDeepmerge = deepmergeCustom({
- enableImplicitDefaultMerging: true, // enable implicit default merging
+ enableImplicitDefaultMerging: true, // enable implicit default merging
mergeOthers: (value, utils) => {
if (someCondition) {
return someCustomValue;
@@ -104,9 +104,8 @@ To use HKTs, we alias the type to a string type (a URI) and simply refer to that
Here's a simple example that creates a custom deepmerge function that does not merge arrays.
-```js
-import type { DeepMergeLeafURI } from "deepmerge-ts";
-import { deepmergeCustom } from "deepmerge-ts";
+```ts
+import { type DeepMergeLeafURI, deepmergeCustom } from "deepmerge-ts";
const customDeepmerge = deepmergeCustom<{
DeepMergeArraysURI: DeepMergeLeafURI; // <-- Needed for correct output type.
@@ -128,7 +127,11 @@ This can be done using [Declaration Merging](https://www.typescriptlang.org/docs
```ts
declare module "deepmerge-ts" {
- interface DeepMergeMergeFunctionURItoKind, MF extends DeepMergeMergeFunctionsURIs, M> {
+ interface DeepMergeMergeFunctionURItoKind<
+ Ts extends ReadonlyArray,
+ MF extends DeepMergeMergeFunctionsURIs,
+ M,
+ > {
readonly MyCustomMergeURI: MyValue;
}
}
@@ -137,8 +140,12 @@ declare module "deepmerge-ts" {
Here's an example of creating a custom deepmerge function that amalgamates dates into an array.
```ts
-import type { DeepMergeLeaf, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunctionsURIs } from "deepmerge-ts";
-import { deepmergeCustom } from "deepmerge-ts";
+import {
+ type DeepMergeLeaf,
+ type DeepMergeMergeFunctionURItoKind,
+ type DeepMergeMergeFunctionsURIs,
+ deepmergeCustom,
+} from "deepmerge-ts";
const customizedDeepmerge = deepmergeCustom<{
DeepMergeOthersURI: "MyDeepMergeDatesURI"; // <-- Needed for correct output type.
@@ -163,13 +170,18 @@ declare module "deepmerge-ts" {
interface DeepMergeMergeFunctionURItoKind<
Ts extends ReadonlyArray,
MF extends DeepMergeMergeFunctionsURIs,
- M
+ M,
> {
- readonly MyDeepMergeDatesURI: EveryIsDate extends true ? Ts : DeepMergeLeaf;
+ readonly MyDeepMergeDatesURI: EveryIsDate extends true
+ ? Ts
+ : DeepMergeLeaf;
}
}
-type EveryIsDate> = Ts extends readonly [infer Head, ...infer Rest]
+type EveryIsDate> = Ts extends readonly [
+ infer Head,
+ ...infer Rest,
+]
? Head extends Date
? EveryIsDate
: false
@@ -185,8 +197,12 @@ We provide a simple object of meta data that states the key that the values bein
Here's an example that creates a custom deepmerge function that merges numbers differently based on the key they were under.
```ts
-import type { DeepMergeLeaf, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunctionsURIs } from "deepmerge-ts";
-import { deepmergeCustom } from "deepmerge-ts";
+import {
+ type DeepMergeLeaf,
+ type DeepMergeMergeFunctionURItoKind,
+ type DeepMergeMergeFunctionsURIs,
+ deepmergeCustom,
+} from "deepmerge-ts";
const customizedDeepmerge = deepmergeCustom({
mergeOthers: (values, utils, meta) => {
@@ -209,7 +225,9 @@ const customizedDeepmerge = deepmergeCustom({
},
});
-function areAllNumbers(values: ReadonlyArray): values is ReadonlyArray {
+function areAllNumbers(
+ values: ReadonlyArray,
+): values is ReadonlyArray {
return values.every((value) => typeof value === "number");
}
@@ -228,8 +246,12 @@ You can customize the meta data that is passed to the merge functions by providi
Here's an example that uses custom metadata that accumulates the full key path.
```ts
-import type { DeepMergeLeaf, DeepMergeMergeFunctionURItoKind, DeepMergeMergeFunctionsURIs } from "deepmerge-ts";
-import { deepmergeCustom } from "deepmerge-ts";
+import {
+ type DeepMergeLeaf,
+ type DeepMergeMergeFunctionURItoKind,
+ type DeepMergeMergeFunctionsURIs,
+ deepmergeCustom,
+} from "deepmerge-ts";
const customizedDeepmerge = deepmergeCustom<
// Change the return type of `mergeOthers`.
@@ -262,8 +284,8 @@ const customizedDeepmerge = deepmergeCustom<
if (
meta !== undefined &&
meta.keyPath.length >= 2 &&
- meta.keyPath[meta.keyPath.length - 2] === "bar" &&
- meta.keyPath[meta.keyPath.length - 1] === "baz"
+ meta.keyPath.at(-2) === "bar" &&
+ meta.keyPath.at(-1) === "baz"
) {
return "special merge";
}
@@ -283,11 +305,11 @@ const y = {
customizedDeepmerge(x, y); // => { foo: { bar: { baz: "special merge", bar: { baz: 6, qux: 7 }, qux: 2 } }, bar: { baz: "special merge", qux: 9 }, }
-declare module "../src/types" {
+declare module "deepmerge-ts" {
interface DeepMergeMergeFunctionURItoKind<
Ts extends Readonly>,
MF extends DeepMergeMergeFunctionsURIs,
- M // This is the meta data type
+ M, // This is the meta data type
> {
readonly KeyPathBasedMerge: Ts[number] extends number
? Ts[number] | string
@@ -310,7 +332,12 @@ But there are some differences to be aware of.
The signature of merging functions for `deepmergeIntoCustom` looks like this:
```ts
-(target: DeepMergeValueReference, values: Ts, utils: U, meta: M | undefined) => void | symbol;
+(
+ target: DeepMergeValueReference,
+ values: Ts,
+ utils: U,
+ meta: M | undefined,
+) => undefined | symbol;
```
Instead of returning a value like with `deepmergeCustom`'s merge functions, mutations should be made to `target.value`.\
@@ -342,7 +369,7 @@ Here's an example:
```ts
type CustomizedDeepmergeInto = <
Target extends object,
- Ts extends ReadonlyArray