From 307d18895852b047f33e9f49285b2f75d771a085 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 30 Apr 2024 13:24:22 +0200 Subject: [PATCH] Update dev-dependencies --- .github/workflows/main.yml | 6 +- index.test-d.ts | 46 +++++++------- lib/index.js | 4 +- package.json | 16 ++--- readme.md | 124 ++++++++++++++++++------------------- 5 files changed, 99 insertions(+), 97 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fb63387..8fdea18 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,13 +7,13 @@ jobs: name: ${{matrix.node}} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{matrix.node}} - run: npm install - run: npm test - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 strategy: matrix: node: diff --git a/index.test-d.ts b/index.test-d.ts index 87f9a7c..499a87b 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -150,72 +150,72 @@ if (is(mdastNode, {type: 'heading', depth: 2})) { } // TS makes this `type: string`. -const checkParagraphProps = convert({type: 'paragraph'}) -const checkParagraphPropsConst = convert({type: 'paragraph'} as const) -const checkHeading2Props = convert({type: 'heading', depth: 2}) -const checkHeading2PropsConst = convert({ +const checkParagraphProperties = convert({type: 'paragraph'}) +const checkParagraphPropertiesConst = convert({type: 'paragraph'} as const) +const checkHeading2Properties = convert({type: 'heading', depth: 2}) +const checkHeading2PropertiesConst = convert({ type: 'heading', depth: 2 } as const) -if (checkParagraphProps(mdastNode)) { +if (checkParagraphProperties(mdastNode)) { expectNotType(mdastNode) } -if (checkParagraphPropsConst(mdastNode)) { +if (checkParagraphPropertiesConst(mdastNode)) { expectType(mdastNode) } -if (checkHeading2Props(mdastNode)) { +if (checkHeading2Properties(mdastNode)) { expectType(mdastNode) expectNotType<2>(mdastNode.depth) // TS can’t narrow this normally. } -if (checkHeading2PropsConst(mdastNode)) { +if (checkHeading2PropertiesConst(mdastNode)) { expectAssignable(mdastNode) expectType<2>(mdastNode.depth) } // Function test (with explicit assertion). -const checkHeadingFn = convert(isHeading) -const checkParagraphFn = convert(isParagraph) -const checkHeading2Fn = convert(isHeading2) +const checkHeadingFunction = convert(isHeading) +const checkParagraphFunction = convert(isParagraph) +const checkHeading2Function = convert(isHeading2) -expectType(checkHeadingFn(mdastNode)) +expectType(checkHeadingFunction(mdastNode)) -if (checkHeadingFn(mdastNode)) { +if (checkHeadingFunction(mdastNode)) { expectType(mdastNode) } -if (checkParagraphFn(mdastNode)) { +if (checkParagraphFunction(mdastNode)) { expectType(mdastNode) } -if (checkParagraphFn(mdastNode)) { +if (checkParagraphFunction(mdastNode)) { expectNotType(mdastNode) } -if (checkHeading2Fn(mdastNode)) { +if (checkHeading2Function(mdastNode)) { expectAssignable(mdastNode) expectType<2>(mdastNode.depth) } // Function test (implicit assertion). -const checkHeadingLooseFn = convert(isHeadingLoose) -const checkParagraphLooseFn = convert(isParagraphLoose) -const checkHeadFn = convert(isHead) +const checkHeadingLooseFunction = convert(isHeadingLoose) +const checkParagraphLooseFunction = convert(isParagraphLoose) +const checkHeadFunction = convert(isHead) -expectType(checkHeadingLooseFn(mdastNode)) +expectType(checkHeadingLooseFunction(mdastNode)) -if (checkHeadingLooseFn(mdastNode)) { +if (checkHeadingLooseFunction(mdastNode)) { expectNotType(mdastNode) } -if (checkParagraphLooseFn(mdastNode)) { +if (checkParagraphLooseFunction(mdastNode)) { expectNotType(mdastNode) } -if (checkHeadFn(mdastNode)) { +if (checkHeadFunction(mdastNode)) { expectNotType(mdastNode) } diff --git a/lib/index.js b/lib/index.js index 7564cbf..5e920d7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -163,7 +163,7 @@ export const convert = } if (typeof test === 'object') { - return Array.isArray(test) ? anyFactory(test) : propsFactory(test) + return Array.isArray(test) ? anyFactory(test) : propertiesFactory(test) } if (typeof test === 'string') { @@ -210,7 +210,7 @@ function anyFactory(tests) { * @param {Props} check * @returns {Check} */ -function propsFactory(check) { +function propertiesFactory(check) { const checkAsRecord = /** @type {Record} */ (check) return castFactory(all) diff --git a/package.json b/package.json index 3ccd375..03574a3 100644 --- a/package.json +++ b/package.json @@ -42,19 +42,19 @@ "devDependencies": { "@types/mdast": "^4.0.0", "@types/node": "^20.0.0", - "c8": "^8.0.0", - "prettier": "^2.0.0", - "remark-cli": "^11.0.0", - "remark-preset-wooorm": "^9.0.0", - "tsd": "^0.28.0", + "c8": "^9.0.0", + "prettier": "^3.0.0", + "remark-cli": "^12.0.0", + "remark-preset-wooorm": "^10.0.0", + "tsd": "^0.31.0", "type-coverage": "^2.0.0", "typescript": "^5.0.0", - "xo": "^0.54.0" + "xo": "^0.58.0" }, "scripts": { "prepack": "npm run build && npm run format", "build": "tsc --build --clean && tsc --build && tsd && type-coverage", - "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", + "format": "remark . -qfo && prettier . -w --log-level warn && xo --fix", "test-api": "node --conditions development test/index.js", "test-coverage": "c8 --100 --reporter lcov npm run test-api", "test": "npm run build && npm run format && npm run test-coverage" @@ -91,6 +91,8 @@ "rules": { "@typescript-eslint/consistent-type-definitions": "off", "@typescript-eslint/no-unnecessary-type-arguments": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-assignment": "off", "import/no-extraneous-dependencies": "off" } } diff --git a/readme.md b/readme.md index f06dc37..9f4891b 100644 --- a/readme.md +++ b/readme.md @@ -12,23 +12,23 @@ ## Contents -* [What is this?](#what-is-this) -* [When should I use this?](#when-should-i-use-this) -* [Install](#install) -* [Use](#use) -* [API](#api) - * [`is(node[, test[, index, parent[, context]]])`](#isnode-test-index-parent-context) - * [`convert(test)`](#converttest) - * [`Check`](#check) - * [`Test`](#test) - * [`TestFunction`](#testfunction) -* [Examples](#examples) - * [Example of `convert`](#example-of-convert) -* [Types](#types) -* [Compatibility](#compatibility) -* [Related](#related) -* [Contribute](#contribute) -* [License](#license) +* [What is this?](#what-is-this) +* [When should I use this?](#when-should-i-use-this) +* [Install](#install) +* [Use](#use) +* [API](#api) + * [`is(node[, test[, index, parent[, context]]])`](#isnode-test-index-parent-context) + * [`convert(test)`](#converttest) + * [`Check`](#check) + * [`Test`](#test) + * [`TestFunction`](#testfunction) +* [Examples](#examples) + * [Example of `convert`](#example-of-convert) +* [Types](#types) +* [Compatibility](#compatibility) +* [Related](#related) +* [Contribute](#contribute) +* [License](#license) ## What is this? @@ -107,16 +107,16 @@ Check if `node` is a `Node` and whether it passes the given test. ###### Parameters -* `node` (`unknown`, optional) - — thing to check, typically [`Node`][node] -* `test` ([`Test`][api-test], optional) - — a test for a specific element -* `index` (`number`, optional) - — the node’s position in its parent -* `parent` ([`Node`][node], optional) - — the node’s parent -* `context` (`unknown`, optional) - — context object (`this`) to call `test` with +* `node` (`unknown`, optional) + — thing to check, typically [`Node`][node] +* `test` ([`Test`][api-test], optional) + — a test for a specific element +* `index` (`number`, optional) + — the node’s position in its parent +* `parent` ([`Node`][node], optional) + — the node’s parent +* `context` (`unknown`, optional) + — context object (`this`) to call `test` with ###### Returns @@ -139,8 +139,8 @@ a `node`, `index`, and `parent`. ###### Parameters -* `test` ([`Test`][api-test], optional) - — a test for a specific node +* `test` ([`Test`][api-test], optional) + — a test for a specific node ###### Returns @@ -152,14 +152,14 @@ Check that an arbitrary value is a node (TypeScript type). ###### Parameters -* `this` (`unknown`, optional) - — context object (`this`) to call `test` with -* `node` (`unknown`) - — anything (typically a node) -* `index` (`number`, optional) - — the node’s position in its parent -* `parent` ([`Node`][node], optional) - — the node’s parent +* `this` (`unknown`, optional) + — context object (`this`) to call `test` with +* `node` (`unknown`) + — anything (typically a node) +* `index` (`number`, optional) + — the node’s position in its parent +* `parent` ([`Node`][node], optional) + — the node’s parent ###### Returns @@ -183,11 +183,11 @@ type Test = Checks that the given thing is a node, and then: -* when `string`, checks that the node has that tag name -* when `function`, see [`TestFunction`][api-test-function] -* when `object`, checks that all keys in test are in node, and that they have - (strictly) equal values -* when `Array`, checks if one of the subtests pass +* when `string`, checks that the node has that tag name +* when `function`, see [`TestFunction`][api-test-function] +* when `object`, checks that all keys in test are in node, and that they have + (strictly) equal values +* when `Array`, checks if one of the subtests pass ### `TestFunction` @@ -195,12 +195,12 @@ Check if a node passes a test (TypeScript type). ###### Parameters -* `node` ([`Node`][node]) - — a node -* `index` (`number` or `undefined`) - — the node’s position in its parent -* `parent` ([`Node`][node] or `undefined`) - — the node’s parent +* `node` ([`Node`][node]) + — a node +* `index` (`number` or `undefined`) + — the node’s position in its parent +* `parent` ([`Node`][node] or `undefined`) + — the node’s parent ###### Returns @@ -255,20 +255,20 @@ compatible with Node.js 16. ## Related -* [`unist-util-find-after`](https://github.com/syntax-tree/unist-util-find-after) - — find a node after another node -* [`unist-util-find-before`](https://github.com/syntax-tree/unist-util-find-before) - — find a node before another node -* [`unist-util-find-all-after`](https://github.com/syntax-tree/unist-util-find-all-after) - — find all nodes after another node -* [`unist-util-find-all-before`](https://github.com/syntax-tree/unist-util-find-all-before) - — find all nodes before another node -* [`unist-util-find-all-between`](https://github.com/mrzmmr/unist-util-find-all-between) - — find all nodes between two nodes -* [`unist-util-filter`](https://github.com/syntax-tree/unist-util-filter) - — create a new tree with nodes that pass a check -* [`unist-util-remove`](https://github.com/syntax-tree/unist-util-remove) - — remove nodes from tree +* [`unist-util-find-after`](https://github.com/syntax-tree/unist-util-find-after) + — find a node after another node +* [`unist-util-find-before`](https://github.com/syntax-tree/unist-util-find-before) + — find a node before another node +* [`unist-util-find-all-after`](https://github.com/syntax-tree/unist-util-find-all-after) + — find all nodes after another node +* [`unist-util-find-all-before`](https://github.com/syntax-tree/unist-util-find-all-before) + — find all nodes before another node +* [`unist-util-find-all-between`](https://github.com/mrzmmr/unist-util-find-all-between) + — find all nodes between two nodes +* [`unist-util-filter`](https://github.com/syntax-tree/unist-util-filter) + — create a new tree with nodes that pass a check +* [`unist-util-remove`](https://github.com/syntax-tree/unist-util-remove) + — remove nodes from tree ## Contribute pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy