Skip to content

Commit 96e8c4f

Browse files
committed
Update dev-dependencies
1 parent 411f616 commit 96e8c4f

File tree

4 files changed

+69
-64
lines changed

4 files changed

+69
-64
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"typescript": "~4.4.0",
136136
"unist-builder": "^3.0.0",
137137
"unist-util-remove-position": "^4.0.0",
138-
"xo": "^0.46.0"
138+
"xo": "^0.47.0"
139139
},
140140
"scripts": {
141141
"build-packages": "node script/build-presets && node script/build-rules",
@@ -158,6 +158,8 @@
158158
"xo": {
159159
"prettier": true,
160160
"rules": {
161+
"capitalized-comments": "off",
162+
"unicorn/prefer-code-point": "off",
161163
"unicorn/prefer-switch": "off"
162164
},
163165
"overrides": [

packages/unified-lint-rule/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ export type Rule<Tree extends Node = Node, Settings = unknown> = (
3131
settings: Settings
3232
) => Promise<Tree | undefined | void> | Tree | undefined | void
3333

34-
export type {Severity, Label}
34+
export {Severity, Label} from './lib/index.js'

script/util/presets.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ import url from 'node:url'
1212
* @returns {Promise<Array<{name: string, packages: Record<string, unknown>}>>}
1313
*/
1414
export async function presets(base) {
15-
const files = (await fs.readdir(base)).filter((basename) =>
15+
const allFiles = await fs.readdir(base)
16+
const files = allFiles.filter((basename) =>
1617
/remark-preset-lint/.test(basename)
1718
)
1819

1920
return Promise.all(
2021
files.map(async (name) => {
2122
const href = url.pathToFileURL(path.join(base, name, 'index.js')).href
23+
// type-coverage:ignore-next-line
24+
const presetMod = await import(href)
2225
/** @type {Preset} */
2326
// type-coverage:ignore-next-line
24-
const preset = (await import(href)).default
27+
const preset = presetMod.default
2528
const plugins = preset.plugins || []
2629
/** @type {Record<string, unknown>} */
2730
const packages = {}

test.js

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -36,56 +36,48 @@ test('core', async (t) => {
3636
'# Another main heading.'
3737
].join('\n')
3838

39+
let file = await remark()
40+
.use(noHeadingPunctuation)
41+
.use(noMultipleToplevelHeadings)
42+
.use(lint)
43+
.process(toVFile({path: 'virtual.md', value: doc}))
44+
3945
t.deepEqual(
40-
asStrings(
41-
(
42-
await remark()
43-
.use(noHeadingPunctuation)
44-
.use(noMultipleToplevelHeadings)
45-
.use(lint)
46-
.process(toVFile({path: 'virtual.md', value: doc}))
47-
).messages
48-
),
46+
asStrings(file.messages),
4947
[
5048
'virtual.md:3:1-3:24: Don’t add a trailing `.` to headings',
5149
'virtual.md:3:1-3:24: Don’t use multiple top level headings (1:1)'
5250
],
5351
'should support `remark-lint` last'
5452
)
5553

54+
file = await remark()
55+
.use(lint)
56+
.use(noHeadingPunctuation)
57+
.use(noMultipleToplevelHeadings)
58+
.process(toVFile({path: 'virtual.md', value: doc}))
59+
5660
t.deepEqual(
57-
asStrings(
58-
(
59-
await remark()
60-
.use(lint)
61-
.use(noHeadingPunctuation)
62-
.use(noMultipleToplevelHeadings)
63-
.process(toVFile({path: 'virtual.md', value: doc}))
64-
).messages
65-
),
61+
asStrings(file.messages),
6662
[
6763
'virtual.md:3:1-3:24: Don’t add a trailing `.` to headings',
6864
'virtual.md:3:1-3:24: Don’t use multiple top level headings (1:1)'
6965
],
7066
'should support `remark-lint` first'
7167
)
7268

73-
t.deepEqual(
74-
asStrings((await remark().use(lint).process('.')).messages),
75-
[],
76-
'should support no rules'
77-
)
69+
file = await remark().use(lint).process('.')
7870

79-
t.deepEqual(
80-
asStrings((await remark().use(finalNewline).process('')).messages),
81-
[],
82-
'should support successful rules'
83-
)
71+
t.deepEqual(asStrings(file.messages), [], 'should support no rules')
72+
73+
file = await remark().use(finalNewline).process('')
74+
75+
t.deepEqual(asStrings(file.messages), [], 'should support successful rules')
76+
77+
file = await remark().use(finalNewline, [2]).process('.')
8478

8579
t.deepEqual(
86-
(await remark().use(finalNewline, [2]).process('.')).messages.map((d) =>
87-
JSON.parse(JSON.stringify(d))
88-
),
80+
file.messages.map((d) => JSON.parse(JSON.stringify(d))),
8981
[
9082
{
9183
name: '1:1',
@@ -106,36 +98,42 @@ test('core', async (t) => {
10698
'should support a list with a severity'
10799
)
108100

101+
file = await remark().use(finalNewline, true).process('.')
102+
109103
t.deepEqual(
110-
asStrings((await remark().use(finalNewline, true).process('.')).messages),
104+
asStrings(file.messages),
111105
['1:1: Missing newline character at end of file'],
112106
'should support a boolean (`true`)'
113107
)
114108

109+
file = await remark().use(finalNewline, false).process('.')
110+
115111
t.deepEqual(
116-
asStrings((await remark().use(finalNewline, false).process('.')).messages),
112+
asStrings(file.messages),
117113
[],
118114
'should support a boolean (`false`)'
119115
)
120116

117+
file = await remark().use(finalNewline, [true]).process('.')
118+
121119
t.deepEqual(
122-
asStrings((await remark().use(finalNewline, [true]).process('.')).messages),
120+
asStrings(file.messages),
123121
['1:1: Missing newline character at end of file'],
124122
'should support a list with a boolean severity (true, for on)'
125123
)
126124

125+
file = await remark().use(finalNewline, [false]).process('.')
126+
127127
t.deepEqual(
128-
asStrings(
129-
(await remark().use(finalNewline, [false]).process('.')).messages
130-
),
128+
asStrings(file.messages),
131129
[],
132130
'should support a list with boolean severity (false, for off)'
133131
)
134132

133+
file = await remark().use(finalNewline, ['error']).process('.')
134+
135135
t.deepEqual(
136-
(await remark().use(finalNewline, ['error']).process('.')).messages.map(
137-
(d) => JSON.parse(JSON.stringify(d))
138-
),
136+
file.messages.map((d) => JSON.parse(JSON.stringify(d))),
139137
[
140138
{
141139
name: '1:1',
@@ -156,10 +154,10 @@ test('core', async (t) => {
156154
'should support a list with string severity (`error`)'
157155
)
158156

157+
file = await remark().use(finalNewline, ['on']).process('.')
158+
159159
t.deepEqual(
160-
(await remark().use(finalNewline, ['on']).process('.')).messages.map((d) =>
161-
JSON.parse(JSON.stringify(d))
162-
),
160+
file.messages.map((d) => JSON.parse(JSON.stringify(d))),
163161
[
164162
{
165163
name: '1:1',
@@ -180,10 +178,10 @@ test('core', async (t) => {
180178
'should support a list with string severity (`on`)'
181179
)
182180

181+
file = await remark().use(finalNewline, ['warn']).process('.')
182+
183183
t.deepEqual(
184-
(await remark().use(finalNewline, ['warn']).process('.')).messages.map(
185-
(d) => JSON.parse(JSON.stringify(d))
186-
),
184+
file.messages.map((d) => JSON.parse(JSON.stringify(d))),
187185
[
188186
{
189187
name: '1:1',
@@ -204,10 +202,10 @@ test('core', async (t) => {
204202
'should support a list with string severity (`warn`)'
205203
)
206204

205+
file = await remark().use(finalNewline, ['off']).process('.')
206+
207207
t.deepEqual(
208-
asStrings(
209-
(await remark().use(finalNewline, ['off']).process('.')).messages
210-
),
208+
asStrings(file.messages),
211209
[],
212210
'should support a list with string severity (`off`)'
213211
)
@@ -228,17 +226,17 @@ test('core', async (t) => {
228226
'should fail on incorrect severities (too low)'
229227
)
230228

229+
file = await remark()
230+
.use(
231+
lintRule('test:rule', (tree, file) => {
232+
file.message('Test message')
233+
}),
234+
['warn']
235+
)
236+
.process('.')
237+
231238
t.deepEqual(
232-
(
233-
await remark()
234-
.use(
235-
lintRule('test:rule', (tree, file) => {
236-
file.message('Test message')
237-
}),
238-
['warn']
239-
)
240-
.process('.')
241-
).messages.map((d) => JSON.parse(JSON.stringify(d))),
239+
file.messages.map((d) => JSON.parse(JSON.stringify(d))),
242240
[
243241
{
244242
name: '1:1',
@@ -270,9 +268,11 @@ test('rules', async (t) => {
270268
const info = rule(base)
271269
const href = url.pathToFileURL(base).href + '/index.js'
272270

271+
// type-coverage:ignore-next-line
272+
const pluginMod = await import(href)
273273
/** @type {Plugin} */
274274
// type-coverage:ignore-next-line
275-
const fn = (await import(href)).default
275+
const fn = pluginMod.default
276276

277277
if (Object.keys(info.tests).length === 0) {
278278
t.pass(info.ruleId + ': no tests')

0 commit comments

Comments
 (0)