Skip to content

Commit 6433784

Browse files
authored
chore(lint): bump doc-kit (#8275)
1 parent aea78cb commit 6433784

File tree

5 files changed

+77
-14
lines changed

5 files changed

+77
-14
lines changed

packages/remark-lint/src/api.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import yamlComments from './rules/yaml/index.mjs';
1515
/**
1616
* @typedef {Object} Options
1717
* @property {Array<string>} releasedVersions The released versions, for validating the YAML
18+
* @property {Record<string, string>} typeMap The type map
1819
*/
1920

2021
/**

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,22 @@ const testCases = [
3131
input: 'This is {invalid}.',
3232
expected: ['Invalid type reference: {invalid}'],
3333
},
34+
{
35+
name: 'custom references',
36+
input: 'This is a {custom} type.',
37+
expected: [],
38+
options: {
39+
typeMap: {
40+
custom: '...',
41+
},
42+
},
43+
},
3444
];
3545

3646
describe('invalid-type-reference', () => {
37-
for (const { name, input, expected } of testCases) {
38-
it(name, () => testRule(invalidTypeReference, input, expected));
47+
for (const { name, input, expected, options } of testCases) {
48+
it(name, () =>
49+
testRule(invalidTypeReference, input, expected, {}, options)
50+
);
3951
}
4052
});

packages/remark-lint/src/rules/__tests__/utils.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import { unified } from 'unified';
77
/**
88
* Tests a markdown rule against a markdown string
99
*/
10-
export const testRule = (rule, markdown, expected, vfileOptions = {}) => {
10+
export const testRule = (
11+
rule,
12+
markdown,
13+
expected,
14+
vfileOptions = {},
15+
ruleOptions = {}
16+
) => {
1117
// Parse the markdown once
1218
const tree = unified().use(remarkParse).parse(markdown);
1319

@@ -19,7 +25,7 @@ export const testRule = (rule, markdown, expected, vfileOptions = {}) => {
1925
};
2026

2127
// Execute the rule
22-
rule()(tree, vfile, () => {});
28+
rule(ruleOptions)(tree, vfile, () => {});
2329

2430
// Assert that the expected messages were reported
2531
assert.deepEqual(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const REPLACE_RE = /\s*\|\s*/g;
88

99
/**
1010
* Ensures that all type references are valid
11-
* @type {import('unified-lint-rule').Rule}
11+
* @type {import('unified-lint-rule').Rule<, import('../api.mjs').Options>}
1212
*/
13-
const invalidTypeReference = (tree, vfile) => {
13+
const invalidTypeReference = (tree, vfile, { typeMap = {} }) => {
1414
visit(tree, createQueries.UNIST.isTextWithType, node => {
1515
const types = node.value.match(createQueries.QUERIES.normalizeTypes);
1616

@@ -36,7 +36,7 @@ const invalidTypeReference = (tree, vfile) => {
3636
node.value = node.value.replace(type, normalized);
3737
}
3838

39-
if (transformTypeToReferenceLink(type) === type) {
39+
if (transformTypeToReferenceLink(type, typeMap) === type) {
4040
vfile.message(`Invalid type reference: ${type}`, node);
4141
}
4242
});

pnpm-lock.yaml

Lines changed: 51 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)