Skip to content

Commit 68ddb10

Browse files
authored
chore(remark-lint): better invalid type regex (#8673)
1 parent ade0bad commit 68ddb10

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

packages/remark-lint/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@node-core/remark-lint",
33
"type": "module",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"exports": {
66
".": "./src/index.mjs",
77
"./api": "./src/api.mjs"

packages/remark-lint/src/rules/__tests__/invalid-type-reference.test.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ const testCases = [
2626
'Type reference should be separated by "|", without spaces; saw "{string | boolean}"',
2727
],
2828
},
29+
{
30+
name: 'newline, multiple references',
31+
input: 'Psst, are you a {string|\nboolean}',
32+
expected: [],
33+
},
2934
{
3035
name: 'invalid references',
3136
input: 'This is {invalid}.',

packages/remark-lint/src/rules/invalid-type-reference.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import createQueries from '@nodejs/doc-kit/src/utils/queries/index.mjs';
33
import { lintRule } from 'unified-lint-rule';
44
import { visit } from 'unist-util-visit';
55

6-
const MATCH_RE = /\s\||\|\s/g;
7-
const REPLACE_RE = /\s*\|\s*/g;
6+
const MATCH_RE = /\s\||\| /g;
7+
const REPLACE_RE = /\s*\| */g;
88

99
/**
1010
* Ensures that all type references are valid

0 commit comments

Comments
 (0)