@markdoc/markdoc 0.5.13 → 0.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +11 -0
  2. package/dist/index.d.ts +4 -4
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +467 -462
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.mjs +467 -462
  7. package/dist/index.mjs.map +4 -4
  8. package/dist/react.js +1 -1
  9. package/dist/react.js.map +2 -2
  10. package/dist/src/ast/base.d.ts +1 -1
  11. package/dist/src/ast/base.d.ts.map +1 -1
  12. package/dist/src/ast/function.d.ts +1 -1
  13. package/dist/src/ast/function.d.ts.map +1 -1
  14. package/dist/src/ast/index.d.ts +2 -2
  15. package/dist/src/ast/index.d.ts.map +1 -1
  16. package/dist/src/ast/node.d.ts.map +1 -1
  17. package/dist/src/ast/variable.d.ts +1 -1
  18. package/dist/src/ast/variable.d.ts.map +1 -1
  19. package/dist/src/formatter.d.ts.map +1 -1
  20. package/dist/src/functions/index.d.ts.map +1 -1
  21. package/dist/src/parser.d.ts.map +1 -1
  22. package/dist/src/renderers/html.d.ts.map +1 -1
  23. package/dist/src/renderers/react/react.d.ts +2 -2
  24. package/dist/src/renderers/react/react.d.ts.map +1 -1
  25. package/dist/src/renderers/react/static.d.ts +1 -1
  26. package/dist/src/renderers/react/static.d.ts.map +1 -1
  27. package/dist/src/schema-types/class.d.ts +1 -1
  28. package/dist/src/schema-types/class.d.ts.map +1 -1
  29. package/dist/src/schema-types/conditional.d.ts +1 -1
  30. package/dist/src/schema-types/conditional.d.ts.map +1 -1
  31. package/dist/src/schema.d.ts.map +1 -1
  32. package/dist/src/tags/conditional.d.ts +1 -1
  33. package/dist/src/tags/conditional.d.ts.map +1 -1
  34. package/dist/src/tokenizer/index.d.ts.map +1 -1
  35. package/dist/src/tokenizer/plugins/annotations.d.ts.map +1 -1
  36. package/dist/src/transformer.d.ts.map +1 -1
  37. package/dist/src/validator.d.ts +1 -1
  38. package/dist/src/validator.d.ts.map +1 -1
  39. package/index.ts +21 -22
  40. package/package.json +7 -13
  41. package/spec/support/matchers.d.ts +6 -4
  42. package/src/ast/base.ts +2 -2
  43. package/src/ast/function.ts +1 -1
  44. package/src/ast/index.ts +3 -4
  45. package/src/ast/node.test.ts +60 -46
  46. package/src/ast/node.ts +3 -3
  47. package/src/ast/variable.test.ts +5 -4
  48. package/src/ast/variable.ts +1 -1
  49. package/src/formatter.test.ts +4 -3
  50. package/src/formatter.ts +11 -11
  51. package/src/functions/index.test.ts +8 -7
  52. package/src/functions/index.ts +1 -1
  53. package/src/grammar/tag.d.ts +1 -1
  54. package/src/grammar/tag.js +208 -285
  55. package/src/grammar/tag.pegjs +4 -4
  56. package/src/grammar/tag.test.ts +56 -52
  57. package/src/parser.test.ts +93 -70
  58. package/src/parser.ts +19 -6
  59. package/src/renderers/html.test.ts +56 -16
  60. package/src/renderers/html.ts +10 -2
  61. package/src/renderers/react/react.test.ts +29 -28
  62. package/src/renderers/react/react.ts +7 -8
  63. package/src/renderers/react/static.ts +5 -6
  64. package/src/schema-types/class.ts +1 -1
  65. package/src/schema-types/conditional.ts +1 -1
  66. package/src/schema.ts +9 -4
  67. package/src/tag.test.ts +2 -1
  68. package/src/tag.ts +1 -1
  69. package/src/tags/conditional.ts +4 -4
  70. package/src/tags/index.ts +2 -2
  71. package/src/tags/partial.ts +1 -1
  72. package/src/tokenizer/index.ts +6 -5
  73. package/src/tokenizer/plugins/annotations.test.ts +29 -28
  74. package/src/tokenizer/plugins/annotations.ts +12 -12
  75. package/src/tokenizer/plugins/comments.test.ts +11 -10
  76. package/src/tokenizer/plugins/comments.ts +2 -2
  77. package/src/tokenizer/plugins/frontmatter.test.ts +7 -6
  78. package/src/tokenizer/plugins/frontmatter.ts +2 -2
  79. package/src/tokenizer/plugins/link.test.ts +14 -13
  80. package/src/transformer.ts +7 -5
  81. package/src/transforms/table.test.ts +18 -17
  82. package/src/transforms/table.ts +1 -1
  83. package/src/utils.test.ts +23 -22
  84. package/src/utils.ts +3 -3
  85. package/src/validator.test.ts +60 -59
  86. package/src/validator.ts +13 -11
@@ -1,11 +1,12 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import Markdoc from '../../index';
2
3
 
3
4
  function validate(string: string, config = {}) {
4
5
  return Markdoc.validate(Markdoc.parse(string), config);
5
6
  }
6
7
 
7
- describe('table transform validation', function () {
8
- it('produces an error for non-row content at the row level of a table', function () {
8
+ describe('table transform validation', () => {
9
+ it('produces an error for non-row content at the row level of a table', () => {
9
10
  const input = `{% table %}
10
11
  * Heading 1
11
12
  * Heading 2
@@ -20,7 +21,7 @@ This is invalid non-conditional content at the row level.
20
21
 
21
22
  const errors = validate(input);
22
23
  const tableSyntaxErrors = errors.filter(
23
- (e) => e.error.id === 'table-syntax'
24
+ (e) => e.error.id === 'table-syntax',
24
25
  );
25
26
 
26
27
  // One error for the paragraph inside the conditional,
@@ -34,10 +35,10 @@ This is invalid non-conditional content at the row level.
34
35
 
35
36
  // Errors should point to the actual invalid content, not the table
36
37
  const conditionalError = tableSyntaxErrors.find(
37
- (e) => e.location?.start.line === 7
38
+ (e) => e.location?.start.line === 7,
38
39
  );
39
40
  const rowLevelError = tableSyntaxErrors.find(
40
- (e) => e.location?.start.line === 9
41
+ (e) => e.location?.start.line === 9,
41
42
  );
42
43
  expect(conditionalError).toBeDefined();
43
44
  expect(conditionalError?.location?.start.line).toBe(7);
@@ -49,7 +50,7 @@ This is invalid non-conditional content at the row level.
49
50
  expect(rowLevelError?.lines).toEqual([9, 10]);
50
51
  });
51
52
 
52
- it('does not produce errors for valid conditional rows', function () {
53
+ it('does not produce errors for valid conditional rows', () => {
53
54
  const input = `{% table %}
54
55
  * Heading 1
55
56
  * Heading 2
@@ -70,13 +71,13 @@ This is invalid non-conditional content at the row level.
70
71
 
71
72
  const errors = validate(input);
72
73
  const tableSyntaxErrors = errors.filter(
73
- (e) => e.error.id === 'table-syntax'
74
+ (e) => e.error.id === 'table-syntax',
74
75
  );
75
76
 
76
77
  expect(tableSyntaxErrors).toEqual([]);
77
78
  });
78
79
 
79
- it('does not produce errors for valid conditionals within a cell', function () {
80
+ it('does not produce errors for valid conditionals within a cell', () => {
80
81
  const input = `{% table %}
81
82
  * Heading 1
82
83
  * Heading 2
@@ -92,13 +93,13 @@ This is invalid non-conditional content at the row level.
92
93
 
93
94
  const errors = validate(input);
94
95
  const tableSyntaxErrors = errors.filter(
95
- (e) => e.error.id === 'table-syntax'
96
+ (e) => e.error.id === 'table-syntax',
96
97
  );
97
98
 
98
99
  expect(tableSyntaxErrors).toEqual([]);
99
100
  });
100
101
 
101
- it('does not produce errors for valid conditional with multiple rows and hr separators', function () {
102
+ it('does not produce errors for valid conditional with multiple rows and hr separators', () => {
102
103
  const input = `{% table %}
103
104
  * Heading 1
104
105
  * Heading 2
@@ -114,13 +115,13 @@ This is invalid non-conditional content at the row level.
114
115
 
115
116
  const errors = validate(input);
116
117
  const tableSyntaxErrors = errors.filter(
117
- (e) => e.error.id === 'table-syntax'
118
+ (e) => e.error.id === 'table-syntax',
118
119
  );
119
120
 
120
121
  expect(tableSyntaxErrors).toEqual([]);
121
122
  });
122
123
 
123
- it('does not produce errors for comments in a table', function () {
124
+ it('does not produce errors for comments in a table', () => {
124
125
  function validateWithComments(string: string, config = {}) {
125
126
  const tokenizer = new Markdoc.Tokenizer({ allowComments: true });
126
127
  const tokens = tokenizer.tokenize(string);
@@ -147,13 +148,13 @@ comment inside conditional
147
148
 
148
149
  const errors = validateWithComments(input);
149
150
  const tableSyntaxErrors = errors.filter(
150
- (e) => e.error.id === 'table-syntax'
151
+ (e) => e.error.id === 'table-syntax',
151
152
  );
152
153
 
153
154
  expect(tableSyntaxErrors).toEqual([]);
154
155
  });
155
156
 
156
- it('produces an error for invalid tags inside a table conditional', function () {
157
+ it('produces an error for invalid tags inside a table conditional', () => {
157
158
  const input = `{% table %}
158
159
  * Heading 1
159
160
  * Heading 2
@@ -171,7 +172,7 @@ This is not a valid row
171
172
 
172
173
  const errors = validate(input, config);
173
174
  const tableSyntaxErrors = errors.filter(
174
- (e) => e.error.id === 'table-syntax'
175
+ (e) => e.error.id === 'table-syntax',
175
176
  );
176
177
 
177
178
  expect(tableSyntaxErrors.length).toBe(1);
@@ -183,7 +184,7 @@ This is not a valid row
183
184
  expect(tableSyntaxErrors[0].lines).toEqual([5, 6]);
184
185
  });
185
186
 
186
- it('produces an error for non-conditional tags at the row level of a table', function () {
187
+ it('produces an error for non-conditional tags at the row level of a table', () => {
187
188
  const input = `{% table %}
188
189
  * Heading 1
189
190
  * Heading 2
@@ -199,7 +200,7 @@ This is not a valid row
199
200
 
200
201
  const errors = validate(input, config);
201
202
  const tableSyntaxErrors = errors.filter(
202
- (e) => e.error.id === 'table-syntax'
203
+ (e) => e.error.id === 'table-syntax',
203
204
  );
204
205
 
205
206
  expect(tableSyntaxErrors.length).toBe(1);
@@ -36,7 +36,7 @@ function unexpectedNodeError(node: Node): ValidationError {
36
36
 
37
37
  export default function transform(
38
38
  document: Node,
39
- conditionalTags: string[] = ['if']
39
+ conditionalTags: string[] = ['if'],
40
40
  ) {
41
41
  for (const node of document.walk()) {
42
42
  if (node.type !== 'tag' || node.tag !== 'table') continue;
package/src/utils.test.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import { findTagEnd, parseTags } from '../src/utils';
2
3
 
3
- describe('Templating', function () {
4
- describe('parseTags', function () {
5
- it('simple example', function () {
4
+ describe('Templating', () => {
5
+ describe('parseTags', () => {
6
+ it('simple example', () => {
6
7
  const example =
7
8
  'this is a {% foo blah="asdf" %}test{% /foo %} of template parsing';
8
9
  const output = parseTags(example);
@@ -35,59 +36,59 @@ describe('Templating', function () {
35
36
  });
36
37
  });
37
38
 
38
- describe('findTagEnd', function () {
39
- describe('inline tags', function () {
40
- it('in a heading', function () {
39
+ describe('findTagEnd', () => {
40
+ describe('inline tags', () => {
41
+ it('in a heading', () => {
41
42
  const example = `# Testing {% #foo.bar baz=1 %}`;
42
43
  const end = findTagEnd(example, 0);
43
44
  expect(end).toEqual(28);
44
45
  expect(example[end]).toEqual('%');
45
46
  });
46
47
 
47
- it('with string', function () {
48
+ it('with string', () => {
48
49
  const example = `# Testing {% #foo.bar baz="example" test=true %}`;
49
50
  const end = findTagEnd(example, 0);
50
51
  expect(end).toEqual(46);
51
52
  expect(example[end]).toEqual('%');
52
53
  });
53
54
 
54
- it('with object literal attribute value', function () {
55
+ it('with object literal attribute value', () => {
55
56
  const example = `# Testing {% #foo.bar baz={test: 1, foo: {test: "asdf{"}} %}`;
56
57
  const end = findTagEnd(example, 0);
57
58
  expect(end).toEqual(58);
58
59
  expect(example[end]).toEqual('%');
59
60
  });
60
61
 
61
- it('in a simple container', function () {
62
+ it('in a simple container', () => {
62
63
  const end = findTagEnd('{% foo %}');
63
64
  expect(end).toEqual(7);
64
65
  });
65
66
 
66
- it('in a container with shortcuts', function () {
67
+ it('in a container with shortcuts', () => {
67
68
  const end = findTagEnd('{% foo .bar.baz#test %}');
68
69
  expect(end).toEqual(21);
69
70
  });
70
71
 
71
- it('in a container with a string attribute', function () {
72
+ it('in a container with a string attribute', () => {
72
73
  const end = findTagEnd('{% foo test="this is a test" %}');
73
74
  expect(end).toEqual(29);
74
75
  });
75
76
 
76
- it('for an invalid container', function () {
77
+ it('for an invalid container', () => {
77
78
  const end = findTagEnd('{% foo .bar#baz');
78
79
  expect(end).toBeNull();
79
80
  });
80
81
 
81
- it('in a complex container', function () {
82
+ it('in a complex container', () => {
82
83
  const end = findTagEnd(
83
- '{% #foo .bar .baz test="this} is \\"{test}\\" a test" %} this is a test'
84
+ '{% #foo .bar .baz test="this} is \\"{test}\\" a test" %} this is a test',
84
85
  );
85
86
  expect(end).toEqual(52);
86
87
  });
87
88
  });
88
89
 
89
- describe('multiline tags', function () {
90
- it('simple', function () {
90
+ describe('multiline tags', () => {
91
+ it('simple', () => {
91
92
  const example = `
92
93
  {% test #foo.bar
93
94
  baz=1 %}
@@ -98,7 +99,7 @@ describe('Templating', function () {
98
99
  expect(example[end]).toEqual('%');
99
100
  });
100
101
 
101
- it('with string', function () {
102
+ it('with string', () => {
102
103
  const example = `
103
104
  {% test #foo.bar
104
105
  baz="this is a test"
@@ -110,7 +111,7 @@ describe('Templating', function () {
110
111
  expect(example[end]).toEqual('%');
111
112
  });
112
113
 
113
- it('with string and escaped quote', function () {
114
+ it('with string and escaped quote', () => {
114
115
  const example = `
115
116
  {% test #foo.bar
116
117
  baz="this \\"is a test"
@@ -122,7 +123,7 @@ describe('Templating', function () {
122
123
  expect(example[end]).toEqual('%');
123
124
  });
124
125
 
125
- it('with string that has an opening brace', function () {
126
+ it('with string that has an opening brace', () => {
126
127
  const example = `
127
128
  {% test #foo.bar
128
129
  baz="this {is a test"
@@ -134,7 +135,7 @@ describe('Templating', function () {
134
135
  expect(example[end]).toEqual('%');
135
136
  });
136
137
 
137
- it('with string that has escapes and braces', function () {
138
+ it('with string that has escapes and braces', () => {
138
139
  const example = `
139
140
  {% test #foo.bar
140
141
  baz="th\\"is {is a \\\\te\\"st"
@@ -146,7 +147,7 @@ describe('Templating', function () {
146
147
  expect(example[end]).toEqual('%');
147
148
  });
148
149
 
149
- it('with an object literal attribute value', function () {
150
+ it('with an object literal attribute value', () => {
150
151
  const example = `
151
152
  {% test #foo.bar
152
153
  foo={testing: "this } is a test", bar: {baz: 1}}
@@ -158,7 +159,7 @@ describe('Templating', function () {
158
159
  expect(example[end]).toEqual('%');
159
160
  });
160
161
 
161
- it('with an invalid object literal attribute value', function () {
162
+ it('with an invalid object literal attribute value', () => {
162
163
  const example = `
163
164
  {test #foo.bar
164
165
  foo={testing: "this } is a test", bar: {baz: 1}
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { parse, SyntaxError } from './grammar/tag';
2
- import Variable from './ast/variable';
3
1
  import Function from './ast/function';
2
+ import Variable from './ast/variable';
3
+ import { parse, SyntaxError } from './grammar/tag';
4
4
 
5
5
  import type { Token } from './types';
6
6
 
@@ -53,7 +53,7 @@ export function findTagEnd(content: string, start = 0) {
53
53
 
54
54
  export function containsMarkdocTagInUrl(
55
55
  content: string,
56
- allowedProtocols: string[]
56
+ allowedProtocols: string[],
57
57
  ) {
58
58
  for (let pos = 0; pos < content.length; pos++) {
59
59
  if (!content.startsWith(OPEN, pos)) continue;
@@ -1,14 +1,15 @@
1
- import Markdoc, { Node, Tag, nodes } from '../index';
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import Markdoc, { Node, nodes, Tag } from '../index';
2
3
  import type { Config, ValidationError } from './types';
3
4
 
4
5
  function validate(string, config) {
5
6
  return Markdoc.validate(Markdoc.parse(string), config);
6
7
  }
7
8
 
8
- describe('validate', function () {
9
- describe('prototype-safe attributes', function () {
9
+ describe('validate', () => {
10
+ describe('prototype-safe attributes', () => {
10
11
  let config: Config;
11
- let customValidate: jasmine.Spy;
12
+ let customValidate: ReturnType<typeof vi.fn>;
12
13
  const unsafe = 'javascript:alert(1)';
13
14
  const trusted = 'https://trusted.example/embed';
14
15
  const React = {
@@ -18,8 +19,8 @@ describe('validate', function () {
18
19
  },
19
20
  };
20
21
 
21
- beforeEach(function () {
22
- customValidate = jasmine.createSpy('validate').and.callFake((value) =>
22
+ beforeEach(() => {
23
+ customValidate = vi.fn((value) =>
23
24
  value === trusted
24
25
  ? []
25
26
  : [
@@ -28,7 +29,7 @@ describe('validate', function () {
28
29
  level: 'critical',
29
30
  message: 'Untrusted URL',
30
31
  },
31
- ]
32
+ ],
32
33
  );
33
34
  config = {
34
35
  tags: {
@@ -49,7 +50,7 @@ describe('validate', function () {
49
50
  };
50
51
  });
51
52
 
52
- it('validates direct values with the pattern and custom validator', function () {
53
+ it('validates direct values with the pattern and custom validator', () => {
53
54
  const ast = Markdoc.parse(`{% embed src="${unsafe}" /%}`);
54
55
  expect(Markdoc.validate(ast, config)).toDeepEqualSubset([
55
56
  { error: { id: 'attribute-value-invalid', level: 'critical' } },
@@ -57,19 +58,19 @@ describe('validate', function () {
57
58
  ]);
58
59
  expect(customValidate).toHaveBeenCalledWith(
59
60
  unsafe,
60
- jasmine.anything(),
61
- 'src'
61
+ expect.anything(),
62
+ 'src',
62
63
  );
63
64
  });
64
65
 
65
- it('enforces the URL schema when only errors and critical findings block rendering', function () {
66
+ it('enforces the URL schema when only errors and critical findings block rendering', () => {
66
67
  delete config.tags!.embed.attributes!.src.validate;
67
68
  const render = (source: string) => {
68
69
  const ast = Markdoc.parse(source);
69
70
  const findings = Markdoc.validate(ast, config);
70
71
  if (
71
72
  findings.some(({ error }) =>
72
- ['error', 'critical'].includes(error.level)
73
+ ['error', 'critical'].includes(error.level),
73
74
  )
74
75
  )
75
76
  return null;
@@ -79,11 +80,11 @@ describe('validate', function () {
79
80
  expect(render(`{% embed src="${unsafe}" /%}`)).toBeNull();
80
81
  expect(render(`{% embed __proto__={src:"${unsafe}"} /%}`)).toBeNull();
81
82
  expect(render(`{% embed src="${trusted}" /%}`)).toBe(
82
- `<article><iframe src="${trusted}"></iframe></article>`
83
+ `<article><iframe src="${trusted}"></iframe></article>`,
83
84
  );
84
85
  });
85
86
 
86
- it('blocks prototype attribute smuggling before rendering', function () {
87
+ it('blocks prototype attribute smuggling before rendering', () => {
87
88
  const ast = Markdoc.parse(`{% embed __proto__={src:"${unsafe}"} /%}`);
88
89
  expect(Markdoc.validate(ast, config)).toDeepEqualSubset([
89
90
  { error: { id: 'attribute-name-invalid', level: 'critical' } },
@@ -100,7 +101,7 @@ describe('validate', function () {
100
101
  });
101
102
  });
102
103
 
103
- it('still applies type validation to own values', function () {
104
+ it('still applies type validation to own values', () => {
104
105
  const ast = Markdoc.parse('{% embed src=42 /%}');
105
106
  expect(Markdoc.validate(ast, config)).toDeepEqualSubset([
106
107
  { error: { id: 'attribute-type-invalid', level: 'critical' } },
@@ -109,9 +110,9 @@ describe('validate', function () {
109
110
  ]);
110
111
  });
111
112
 
112
- it('validates an unsafe own value despite a smuggling attempt', function () {
113
+ it('validates an unsafe own value despite a smuggling attempt', () => {
113
114
  const ast = Markdoc.parse(
114
- `{% embed __proto__={src:"${trusted}"} src="${unsafe}" /%}`
115
+ `{% embed __proto__={src:"${trusted}"} src="${unsafe}" /%}`,
115
116
  );
116
117
  expect(Markdoc.validate(ast, config)).toDeepEqualSubset([
117
118
  { error: { id: 'attribute-name-invalid', level: 'critical' } },
@@ -120,29 +121,29 @@ describe('validate', function () {
120
121
  ]);
121
122
  expect(customValidate).toHaveBeenCalledWith(
122
123
  unsafe,
123
- jasmine.anything(),
124
- 'src'
124
+ expect.anything(),
125
+ 'src',
125
126
  );
126
127
  });
127
128
 
128
- it('validates and renders an own value despite a smuggling attempt', function () {
129
+ it('validates and renders an own value despite a smuggling attempt', () => {
129
130
  const ast = Markdoc.parse(
130
- `{% embed __proto__={src:"${unsafe}"} src="${trusted}" /%}`
131
+ `{% embed __proto__={src:"${unsafe}"} src="${trusted}" /%}`,
131
132
  );
132
133
  expect(Markdoc.validate(ast, config)).toDeepEqualSubset([
133
134
  { error: { id: 'attribute-name-invalid', level: 'critical' } },
134
135
  ]);
135
136
  expect(customValidate).toHaveBeenCalledWith(
136
137
  trusted,
137
- jasmine.anything(),
138
- 'src'
138
+ expect.anything(),
139
+ 'src',
139
140
  );
140
141
  expect(
141
- Markdoc.renderers.html(Markdoc.transform(ast.children[0], config))
142
+ Markdoc.renderers.html(Markdoc.transform(ast.children[0], config)),
142
143
  ).toBe(`<iframe src="${trusted}"></iframe>`);
143
144
  });
144
145
 
145
- it('ignores inherited attributes on a programmatically modified node', function () {
146
+ it('ignores inherited attributes on a programmatically modified node', () => {
146
147
  const node = new Node('tag', {}, [], 'embed');
147
148
  node.attributes = Object.create({ src: unsafe });
148
149
  expect(Markdoc.validate(node, config)).toDeepEqualSubset([
@@ -150,18 +151,18 @@ describe('validate', function () {
150
151
  ]);
151
152
  expect(node.transformAttributes(config).src).toBeUndefined();
152
153
  expect(Markdoc.renderers.html(Markdoc.transform(node, config))).toBe(
153
- '<iframe></iframe>'
154
+ '<iframe></iframe>',
154
155
  );
155
156
  });
156
157
 
157
- it('applies defaults instead of inherited values', function () {
158
+ it('applies defaults instead of inherited values', () => {
158
159
  config.tags!.embed.attributes!.src.default = trusted;
159
160
  const node = new Node('tag', {}, [], 'embed');
160
161
  node.attributes = Object.create({ src: unsafe });
161
162
  expect(node.transformAttributes(config).src).toBe(trusted);
162
163
  });
163
164
 
164
- it('rejects undeclared attributes whose names exist on Object.prototype', function () {
165
+ it('rejects undeclared attributes whose names exist on Object.prototype', () => {
165
166
  const ast = Markdoc.parse('{% embed toString="value" /%}');
166
167
  expect(Markdoc.validate(ast, config)).toDeepEqualSubset([
167
168
  { error: { id: 'attribute-undefined', level: 'error' } },
@@ -169,18 +170,18 @@ describe('validate', function () {
169
170
  ]);
170
171
  });
171
172
 
172
- it('resolves variables in prototype-free attribute dictionaries', function () {
173
+ it('resolves variables in prototype-free attribute dictionaries', () => {
173
174
  config.variables = { url: trusted };
174
175
  const ast = Markdoc.parse('{% embed src=$url /%}');
175
176
  expect(Markdoc.validate(ast.resolve(config), config)).toEqual([]);
176
177
  expect(Markdoc.transform(ast.children[0], config)).toDeepEqual(
177
- new Tag('iframe', { src: trusted })
178
+ new Tag('iframe', { src: trusted }),
178
179
  );
179
180
  });
180
181
  });
181
182
 
182
- describe('function validation', function () {
183
- it('ensures that function exists', function () {
183
+ describe('function validation', () => {
184
+ it('ensures that function exists', () => {
184
185
  const example = '{% foo bar=baz() /%}';
185
186
  const output = validate(example, {
186
187
  validation: { validateFunctions: true },
@@ -203,7 +204,7 @@ describe('validate', function () {
203
204
  ]);
204
205
  });
205
206
 
206
- describe('return type checking', function () {
207
+ describe('return type checking', () => {
207
208
  const example = '{% foo bar=baz() /%}';
208
209
  const schema = {
209
210
  validation: { validateFunctions: true },
@@ -242,7 +243,7 @@ describe('validate', function () {
242
243
  },
243
244
  };
244
245
 
245
- it('correctly handles union types', function () {
246
+ it('correctly handles union types', () => {
246
247
  const example = '{% union-tag-1 foo=withUnion() bar=withUnion() /%}';
247
248
  expect(validate(example, schema)).toEqual([]);
248
249
 
@@ -258,7 +259,7 @@ describe('validate', function () {
258
259
  ]);
259
260
  });
260
261
 
261
- it('correctly handles return types for nested function calls', function () {
262
+ it('correctly handles return types for nested function calls', () => {
262
263
  const example = '{% foo bar=nested(baz(), number()) /%}';
263
264
  expect(validate(example, schema)).toEqual([]);
264
265
 
@@ -279,11 +280,11 @@ describe('validate', function () {
279
280
  ]);
280
281
  });
281
282
 
282
- it('accepts a correct return type', function () {
283
+ it('accepts a correct return type', () => {
283
284
  expect(validate(example, schema)).toEqual([]);
284
285
  });
285
286
 
286
- it('correctly handles no return type', function () {
287
+ it('correctly handles no return type', () => {
287
288
  const modifiedSchema = {
288
289
  ...schema,
289
290
  functions: { baz: {} },
@@ -292,7 +293,7 @@ describe('validate', function () {
292
293
  expect(validate(example, modifiedSchema)).toEqual([]);
293
294
  });
294
295
 
295
- it('identifies an incorrect return type', function () {
296
+ it('identifies an incorrect return type', () => {
296
297
  const modifiedSchema = {
297
298
  ...schema,
298
299
  functions: { baz: { returns: Number } },
@@ -303,7 +304,7 @@ describe('validate', function () {
303
304
  });
304
305
  });
305
306
 
306
- describe('checks parameters', function () {
307
+ describe('checks parameters', () => {
307
308
  const schema = {
308
309
  validation: { validateFunctions: true },
309
310
  functions: {
@@ -335,13 +336,13 @@ describe('validate', function () {
335
336
  },
336
337
  };
337
338
 
338
- it('with a missing optional parameter', function () {
339
+ it('with a missing optional parameter', () => {
339
340
  expect(validate('{% foo bar=qux() /%}', schema)).toEqual([]);
340
341
  });
341
342
 
342
- it('with a missing required parameter', function () {
343
+ it('with a missing required parameter', () => {
343
344
  expect(
344
- validate('{% foo bar=requiredParam() /%}', schema)
345
+ validate('{% foo bar=requiredParam() /%}', schema),
345
346
  ).toDeepEqualSubset([
346
347
  {
347
348
  error: {
@@ -352,20 +353,20 @@ describe('validate', function () {
352
353
  ]);
353
354
  });
354
355
 
355
- describe('accepts defined parameters', function () {
356
- it('with keyed parameter', function () {
356
+ describe('accepts defined parameters', () => {
357
+ it('with keyed parameter', () => {
357
358
  expect(
358
- validate('{% foo bar=qux(test="example") /%}', schema)
359
+ validate('{% foo bar=qux(test="example") /%}', schema),
359
360
  ).toEqual([]);
360
361
  });
361
362
  });
362
363
 
363
- it('ignores parameters when there is no typing', function () {
364
+ it('ignores parameters when there is no typing', () => {
364
365
  expect(validate('{% foo bar=noTyping(foo=1) /%}', schema)).toEqual([]);
365
366
  });
366
367
 
367
- describe('rejects undeclared parameters', function () {
368
- it('with a keyed parameter', function () {
368
+ describe('rejects undeclared parameters', () => {
369
+ it('with a keyed parameter', () => {
369
370
  const output = validate('{% foo bar=baz(foo=1) /%}', schema);
370
371
  expect(output).toDeepEqualSubset([
371
372
  {
@@ -378,7 +379,7 @@ describe('validate', function () {
378
379
  ]);
379
380
  });
380
381
 
381
- it('with a positional parameter', function () {
382
+ it('with a positional parameter', () => {
382
383
  expect(validate('{% foo bar=baz(1) /%}', schema)).toDeepEqualSubset([
383
384
  {
384
385
  type: 'tag',
@@ -390,7 +391,7 @@ describe('validate', function () {
390
391
  ]);
391
392
 
392
393
  expect(
393
- validate('{% foo bar=baz(1, test=2) /%}', schema)
394
+ validate('{% foo bar=baz(1, test=2) /%}', schema),
394
395
  ).toDeepEqualSubset([
395
396
  {
396
397
  type: 'tag',
@@ -424,7 +425,7 @@ describe('validate', function () {
424
425
  bar
425
426
  {% /baz %}
426
427
  `,
427
- config
428
+ config,
428
429
  );
429
430
  expect(block).toEqual([]);
430
431
  });
@@ -439,7 +440,7 @@ bar
439
440
  bar
440
441
  {% /foo %}
441
442
  `,
442
- config
443
+ config,
443
444
  );
444
445
  expect(wrong[0]?.error.id).toEqual('tag-placement-invalid');
445
446
  expect(wrong[0]?.error.message).toContain('should be inline');
@@ -452,7 +453,7 @@ bar
452
453
  bar
453
454
  {% /bar %}
454
455
  `,
455
- config
456
+ config,
456
457
  );
457
458
  expect(correct).toEqual([]);
458
459
  const wrong = validate(`this is inline {% bar %}bar{% /bar %}`, config);
@@ -722,7 +723,7 @@ bar
722
723
  it('simple case', () => {
723
724
  const example = `{% foo bar={baz: 3} /%}`;
724
725
 
725
- function validator(value, config, name) {
726
+ function validator(value, _config, name) {
726
727
  return value.baz < 5
727
728
  ? [
728
729
  {
@@ -753,7 +754,7 @@ bar
753
754
 
754
755
  const errs = validate(example, config);
755
756
  expect(errs[0].error.message).toEqual(
756
- "The value of 'bar.baz' must be less than five"
757
+ "The value of 'bar.baz' must be less than five",
757
758
  );
758
759
  });
759
760
 
@@ -761,7 +762,7 @@ bar
761
762
  const example = `{% foo bar={baz: 3} /%}`;
762
763
 
763
764
  class CustomType {
764
- validate(value, config, name) {
765
+ validate(value, _config, name) {
765
766
  return value.baz < 5
766
767
  ? [
767
768
  {
@@ -791,7 +792,7 @@ bar
791
792
 
792
793
  const errs = validate(example, config);
793
794
  expect(errs[0].error.message).toEqual(
794
- "The value of 'bar.baz' must be less than five"
795
+ "The value of 'bar.baz' must be less than five",
795
796
  );
796
797
  });
797
798
  });
@@ -830,7 +831,7 @@ bar
830
831
  nodes: {
831
832
  heading: {
832
833
  ...Markdoc.nodes.heading,
833
- validate(node, config) {
834
+ validate(_node, config) {
834
835
  if (config.validation.parents.find((p) => p.tag === 'foo'))
835
836
  return [
836
837
  {
@@ -864,7 +865,7 @@ bar
864
865
  tags: {
865
866
  foo: {},
866
867
  bar: {
867
- validate(node, config) {
868
+ validate(_node, config) {
868
869
  const parents = config?.validation?.parents?.map((p) => p.type);
869
870
  expect(parents).toDeepEqual([
870
871
  'document',