git.iko.soy/typeable/remark-validate-links
on main help sign in
Update for changes in remark@5.0.0

And faster performance, improved tests, dependency updates.

commit72c5aa250bc96b3f16bb2a5e0c30ffea9c02ebb6 authorTitus Wormer <tituswormer@gmail.com> dateMon 13 Jun 2016, 14:55 (10 years ago) parent4d88bc6
5 files changed+228−333
.gitignore+1 .jscs.json+10−4 index.js+73−106 package.json+19−12 test/index.js+125−211
.gitignore+1
@@ -1,4 +1,5 @@
11.DS_Store
22*.log
3+.nyc_output/
34coverage/
45node_modules/
.jscs.json+10−4
@@ -3,16 +3,22 @@
33 "coverage/",
44 "node_modules/"
55 ],
6− "preset": "yandex",
7− "requireQuotedKeysInObjects": true,
8− "disallowQuotedKeysInObjects": false,
6+ "preset": "crockford",
7+ "requireMultipleVarDecl": false,
8+ "requireVarDeclFirst": false,
9+ "disallowDanglingUnderscores": false,
910 "maximumLineLength": {
1011 "value": 79,
1112 "allExcept": [
1213 "regex",
13− "urlComments"
14+ "urlComments",
15+ "require"
1416 ]
1517 },
18+ "requireQuotedKeysInObjects": true,
19+ "disallowKeywords": [
20+ "with"
21+ ],
1622 "jsDoc": {
1723 "checkAnnotations": "jsdoc3",
1824 "checkParamExistence": true,
index.js+73−106
@@ -23,6 +23,7 @@ var definitions = require('mdast-util-definitions');
2323var gh = require('github-url-to-object');
2424var urljoin = require('urljoin');
2525var slug = require('remark-slug');
26+var xtend = require('xtend');
2627
2728/*
2829 * Methods.
@@ -31,6 +32,12 @@ var slug = require('remark-slug');
3132var exists = fs.existsSync;
3233var parse = url.parse;
3334
35+/*
36+ * Constants.
37+ */
38+
39+var NS = 'remark-validate-links';
40+
3441/**
3542 * Get the `pathname` of `uri`, if applicable.
3643 *
@@ -110,25 +117,24 @@ function warnAll(file, nodes, warning) {
110117 * to be one or more nodes.
111118 *
112119 * @example
113− * gatherReferences(new File(), {});
120+ * gatherReferences(new File(), {type: 'root'}, {});
114121 *
115122 * @param {File} file - Set of virtual files.
123+ * @param {Node} tree - Syntax tree.
116124 * @param {Object.<string, string>} project - GitHub
117125 * project, with a `user` and `repo` property
118126 * (optional).
119127 * @return {Object.<string, Array.<Node>>} exposed - Map of
120128 * file-paths (and anchors) which are referenced.
121129 */
122−function gatherReferences(file, project) {
130+function gatherReferences(file, tree, project) {
123131 var cache = {};
124132 var filePath = file.filePath();
125133 var directory = file.directory;
126− var space = file.namespace('mdast');
127134 var getDefinition;
128135 var prefix = '';
129− var ast = space.tree || /* istanbul ignore next */ space.ast;
130136
131− getDefinition = definitions(ast);
137+ getDefinition = definitions(tree);
132138
133139 if (project.user && project.repo) {
134140 prefix = '/' + project.user + '/' + project.repo + '/blob/';
@@ -185,10 +191,17 @@ function gatherReferences(file, project) {
185191 link = filePath + uri.hash;
186192 uri = parse(link);
187193 } else {
188− link = urljoin(directory, link) + (uri.hash || '');
194+ // var a = link;
195+ link = urljoin(directory || './', link);
196+ if (uri.hash) {
197+ // console.error('a: ', a, link, '\n\n');
198+ link += uri.hash;
199+ }
189200 uri = parse(link);
201+ // console.error(['a', directory, link, a]);
190202 }
191203 }
204+ // console.error(['b', link]);
192205
193206 /*
194207 * Handle full links.
@@ -254,64 +267,12 @@ function gatherReferences(file, project) {
254267 }
255268 }
256269
257− visit(ast, 'link', onlink);
258− visit(ast, 'linkReference', onlink);
270+ visit(tree, 'link', onlink);
271+ visit(tree, 'linkReference', onlink);
259272
260273 return cache;
261274}
262275
263−/**
264− * Factory to store all markdown files, and headings.
265− *
266− * @example
267− * var gather = gatherExposedFactory();
268− * var file = new File('# foo');
269− *
270− * gather(file).done() // {}
271− *
272− * @return {Function} - Gatherer.
273− */
274−function gatherExposedFactory() {
275− var cache = {};
276−
277− /**
278− * Find headings in `file`.
279− *
280− * @property {Object} cache - Found links.
281− * @param {File} file - Virtual file.
282− * @returns {Function} - Itself.
283− */
284− function gather(file) {
285− var filePath = file.filePath();
286− var space = file.namespace('mdast');
287− var ast = space.tree || space.ast;
288−
289− /*
290− * Ignore files without AST or filename.
291− */
292−
293− if (filePath && ast) {
294− cache[filePath] = true;
295−
296− visit(ast, function (node) {
297− var data = node.data || {};
298− var attrs = data.htmlAttributes || {};
299− var id = attrs.name || attrs.id || data.id;
300−
301− if (id) {
302− cache[filePath + '#' + id] = true;
303− }
304− });
305− }
306−
307− return gather;
308− }
309−
310− gather.cache = cache;
311−
312− return gather;
313−}
314−
315276/**
316277 * Check if `file` references headings or files not in
317278 * `exposed`. If `project` is given, normalizes GitHub blob
@@ -323,14 +284,9 @@ function gatherExposedFactory() {
323284 * @param {Object.<string, boolean?>} exposed - Map of
324285 * file-paths (and anchors) which can be references to.
325286 * @param {File} file - Set of virtual files.
326− * @param {Object.<string, string>} project - GitHub
327− * project, with a `user` and `repo` property
328− * (optional).
329287 */
330−function validate(exposed, file, project) {
331− var space = file.namespace('mdast');
332− var ast = space.tree || space.ast;
333− var references = ast ? gatherReferences(file, project) : {};
288+function validate(exposed, file) {
289+ var references = file.namespace(NS).references;
334290 var filePath = file.filePath();
335291 var reference;
336292 var nodes;
@@ -345,6 +301,10 @@ function validate(exposed, file, project) {
345301 real = exposed[reference];
346302 hash = getHash(reference);
347303
304+ // if (hash) {
305+ // console.error(['hash', reference, hash]);
306+ // }
307+
348308 /*
349309 * Check if files without `hash` can be linked to.
350310 * Because there’s no need to inspect those files
@@ -383,50 +343,40 @@ function validate(exposed, file, project) {
383343}
384344
385345/**
386− * Factory to create a new completer.
346+ * Completer.
387347 *
388348 * @example
389− * var completer = completerFactory({
390− * 'user': 'foo',
391− * 'repo': 'bar'
392− * });
349+ * completer(new FileSet(), console.log)
393350 *
394− * @param {Object} project - GitHub project, if applicable.
395− * @return {Function} - `completer`, bound to `project`.
351+ * @property {*} pluginId - Unique ID so completers by
352+ * this plug-in are not added multiple times to a single
353+ * file-set pipeline.
354+ * @param {FileSet} set - Virtual file-set.
355+ * @param {function(err?)} done - Callback.
396356 */
397−function completerFactory(project) {
398− /**
399− * Completer.
400− *
401− * @example
402− * completer(new FileSet(), console.log)
403− *
404− * @property {*} pluginId - Unique ID so completers by
405− * this plug-in are not added multiple times to a single
406− * file-set pipeline.
407− * @param {FileSet} set - Virtual file-set.
408− * @param {function(err?)} done - Callback.
409− */
410− function completer(set, done) {
411− var gatherExposed = gatherExposedFactory();
357+function completer(set, done) {
358+ var exposed = {};
412359
413− set.valueOf().forEach(gatherExposed);
414−
415− set.valueOf().forEach(function (file) {
416− /* istanbul ignore else - stdin */
417− if (file.filePath()) {
418− validate(gatherExposed.cache, file, project);
419− }
420− });
360+ set.valueOf().forEach(function (file) {
361+ var landmarks = file.namespace(NS).landmarks;
421362
422− done();
423− }
363+ if (landmarks) {
364+ exposed = xtend(exposed, landmarks);
365+ }
366+ });
424367
425− completer.pluginId = 'remark-validate-links';
368+ set.valueOf().forEach(function (file) {
369+ /* istanbul ignore else - stdin */
370+ if (file.filePath()) {
371+ validate(exposed, file);
372+ }
373+ });
426374
427− return completer;
375+ done();
428376}
429377
378+completer.pluginId = 'remark-validate-links';
379+
430380/**
431381 * Factory to create a transformer based on the given
432382 * project and set.
@@ -451,19 +401,22 @@ function transformerFactory(project, fileSet) {
451401 * @param {File} file - Virtual file.
452402 */
453403 function transformer(ast, file) {
404+ var filePath = file.filePath();
405+ var space = file.namespace(NS);
454406 var links = [];
407+ var landmarks = {};
455408 var references;
456409 var current;
457410 var link;
458411 var pathname;
459412
460413 /* istanbul ignore if - stdin */
461− if (!file.filePath()) {
414+ if (!filePath) {
462415 return;
463416 }
464417
465− references = gatherReferences(file, project);
466− current = getPathname(file.filePath());
418+ references = gatherReferences(file, ast, project);
419+ current = getPathname(filePath);
467420
468421 for (link in references) {
469422 pathname = getPathname(link);
@@ -474,10 +427,24 @@ function transformerFactory(project, fileSet) {
474427 links.indexOf(pathname) === -1
475428 ) {
476429 links.push(pathname);
477−
478430 fileSet.add(pathname);
479431 }
480432 }
433+
434+ landmarks[filePath] = true;
435+
436+ visit(ast, function (node) {
437+ var data = node.data || {};
438+ var attrs = data.htmlAttributes || {};
439+ var id = attrs.name || attrs.id || data.id;
440+
441+ if (id) {
442+ landmarks[filePath + '#' + id] = true;
443+ }
444+ });
445+
446+ space.references = references;
447+ space.landmarks = landmarks;
481448 }
482449
483450 return transformer;
@@ -534,7 +501,7 @@ function attacher(remark, options, fileSet) {
534501 * Attach a `completer`.
535502 */
536503
537− fileSet.use(completerFactory(repo));
504+ fileSet.use(completer);
538505
539506 /*
540507 * Attach `slug`.
package.json+19−12
@@ -13,11 +13,12 @@
1313 ],
1414 "dependencies": {
1515 "github-url-to-object": "^2.1.0",
16− "remark-slug": "^4.1.0",
1716 "mdast-util-definitions": "^1.0.0",
18− "unist-util-visit": "^1.0.0",
1917 "propose": "0.0.5",
20− "urljoin": "^0.1.5"
18+ "remark-slug": "^4.1.0",
19+ "unist-util-visit": "^1.0.0",
20+ "urljoin": "^0.1.5",
21+ "xtend": "^4.0.1"
2122 },
2223 "repository": {
2324 "type": "git",
@@ -33,17 +34,24 @@
3334 ],
3435 "devDependencies": {
3536 "eslint": "^2.0.0",
36− "hook-std": "^0.2.0",
37+ "execa": "^0.4.0",
3738 "istanbul": "^0.4.0",
38− "jscs": "^2.0.0",
39− "jscs-jsdoc": "^1.0.0",
40− "remark": "^4.0.0-alpha.1",
41− "remark-comment-config": "^3.0.0",
42− "remark-github": "^4.0.1",
43− "remark-lint": "^3.0.0",
39+ "jscs": "^3.0.0",
40+ "jscs-jsdoc": "^2.0.0",
41+ "remark": "^5.0.0",
42+ "remark-cli": "^1.0.0",
43+ "remark-comment-config": "^4.0.0",
44+ "remark-github": "^5.0.0-alpha.1",
45+ "remark-lint": "^4.0.0",
4446 "remark-toc": "^3.0.0",
4547 "tape": "^4.0.0"
4648 },
49+ "nyc": {
50+ "check-coverage": true,
51+ "lines": 100,
52+ "functions": 100,
53+ "branches": 100
54+ },
4755 "scripts": {
4856 "build-md": "remark . --quiet --frail",
4957 "build": "npm run build-md",
@@ -51,8 +59,7 @@
5159 "lint-style": "jscs --reporter inline .",
5260 "lint": "npm run lint-api && npm run lint-style",
5361 "test-api": "node test/index.js",
54− "test-coverage": "istanbul cover test/index.js",
55− "test-travis": "npm run test-coverage",
62+ "test-coverage": "nyc --reporter lcov tape test/index.js",
5663 "test": "npm run build && npm run lint && npm run test-coverage"
5764 }
5865}
test/index.js+125−211
@@ -9,64 +9,29 @@
99'use strict';
1010
1111/* eslint-env node */
12+/* jscs:disable jsDoc */
13+/* jscs:disable maximumLineLength */
1214
13−/*
14− * Dependencies.
15− */
16−
15+/* Dependencies. */
1716var fs = require('fs');
1817var path = require('path');
1918var test = require('tape');
20−var hook = require('hook-std');
19+var execa = require('execa');
2120var remark = require('remark');
22−var cli = require('remark/lib/cli');
2321var links = require('..');
2422
25−/**
26− * Test the cli.
27− *
28− * @param {Object} config - Configuration.
29− * @param {Function} callback - Completion handler.
30− */
31−function assertion(config, callback) {
32− var stdout = [];
33− var stderr = [];
34− var opts = {};
35− var unhookStdout;
36− var unhookStderr;
37−
38− opts.silent = true;
39−
40− unhookStdout = hook.stdout(opts, [].push.bind(stdout));
41− unhookStderr = hook.stderr(opts, [].push.bind(stderr));
42−
43− cli(config, function (err) {
44− unhookStdout();
45− unhookStderr();
46−
47− if (err) {
48− return callback(err);
49− }
50−
51− return callback(null, {
52− 'stdout': stdout.join(''),
53− 'stderr': stderr.join('')
54− });
55− });
56−}
57−
58−/*
59− * Tests.
60− */
61−
23+/* Constants. */
6224process.chdir(path.resolve(process.cwd(), 'test', 'fixtures'));
6325
6426test.onFinish(function () {
6527 process.chdir(path.resolve(process.cwd(), '..', '..'));
6628});
6729
30+var bin = path.join('..', '..', 'node_modules', '.bin', 'remark');
31+
32+/* Tests. */
6833test('remark-validate-links', function (t) {
69− // t.plan(1);
34+ t.plan(8);
7035
7136 t.throws(
7237 function () {
@@ -77,21 +42,19 @@ test('remark-validate-links', function (t) {
7742 );
7843
7944 t.test('should ignore unfound files', function (st) {
80− assertion({
81− 'files': ['definitions.md', 'FOOOO'],
82− 'color': false,
83− 'detectRC': false,
84− 'detectIgnore': false,
85− 'plugins': [
86− '../../../index.js'
87− ]
88− }, function (err, res) {
89− st.ifErr(err);
90−
91− st.equal(res.stdout, '');
92−
45+ st.plan(2);
46+
47+ execa.stderr(bin, [
48+ '--no-config',
49+ '--no-ignore',
50+ '--use',
51+ '.',
52+ 'definitions.md',
53+ 'FOOOO'
54+ ]).catch(function (err) {
55+ st.equal(err.code, 1, 'should exit with `1`');
9356 st.equal(
94− res.stderr,
57+ err.stderr,
9558 [
9659 'FOOOO',
9760 ' 1:1 error No such file or directory',
@@ -101,94 +64,67 @@ test('remark-validate-links', function (t) {
10164 '',
10265 '2 messages (✖ 1 error, ⚠ 1 warning)',
10366 ''
104− ].join('\n')
67+ ].join('\n'),
68+ 'should report'
10569 );
106−
107− st.end();
10870 });
10971 });
11072
11173 t.test('should work when not all files are given', function (st) {
112− assertion({
113− 'files': 'example.md',
114− 'color': false,
115− 'detectRC': false,
116− 'detectIgnore': false,
117− 'plugins': [
118− '../../../index.js'
119− ]
120− }, function (err, res) {
121− st.ifErr(err);
122−
74+ st.plan(1);
75+
76+ execa.stderr(bin, [
77+ '--no-config',
78+ '--no-ignore',
79+ '--use',
80+ '.',
81+ 'example.md'
82+ ]).then(function (stderr) {
12383 st.equal(
124− res.stderr,
84+ stderr,
12585 [
12686 'example.md',
12787 ' 5:37-5:51 warning Link to unknown heading: `world`',
128− ' 23:10-23:37 warning Link to unknown file: ' +
129− '`examples/world.md`',
130− ' 25:10-25:35 warning Link to unknown file: ' +
131− '`examples/world.md`',
132− ' 37:10-37:42 warning Link to unknown heading in ' +
133− '`examples/example.md`: `world`',
134− ' 39:10-39:40 warning Link to unknown heading in ' +
135− '`examples/example.md`: `world`',
136− ' 45:10-45:40 warning Link to unknown file: ' +
137− '`examples/world.md`',
138− ' 45:10-45:40 warning Link to unknown heading in ' +
139− '`examples/world.md`: `hello`',
140− ' 47:10-47:38 warning Link to unknown file: ' +
141− '`examples/world.md`',
142− ' 47:10-47:38 warning Link to unknown heading in ' +
143− '`examples/world.md`: `hello`',
88+ ' 23:10-23:37 warning Link to unknown file: `examples/world.md`',
89+ ' 25:10-25:35 warning Link to unknown file: `examples/world.md`',
90+ ' 37:10-37:42 warning Link to unknown heading in `examples/example.md`: `world`',
91+ ' 39:10-39:40 warning Link to unknown heading in `examples/example.md`: `world`',
92+ ' 45:10-45:40 warning Link to unknown file: `examples/world.md`',
93+ ' 45:10-45:40 warning Link to unknown heading in `examples/world.md`: `hello`',
94+ ' 47:10-47:38 warning Link to unknown file: `examples/world.md`',
95+ ' 47:10-47:38 warning Link to unknown heading in `examples/world.md`: `hello`',
14496 '',
145− '⚠ 9 warnings',
146− ''
147− ].join('\n')
97+ '⚠ 9 warnings'
98+ ].join('\n'),
99+ 'should report'
148100 );
149−
150− st.end();
151101 });
152102 });
153103
154104 t.test('should work when all files are given', function (st) {
155− assertion({
156− 'files': [
157− 'example.md',
158− 'examples/example.md'
159− ],
160− 'color': false,
161− 'detectRC': false,
162− 'detectIgnore': false,
163− 'plugins': [
164− '../../../index.js'
165− ]
166− }, function (err, res) {
167− st.ifErr(err);
168−
169− st.equal(res.stdout, '');
170−
105+ st.plan(1);
106+
107+ execa.stderr(bin, [
108+ '--no-config',
109+ '--no-ignore',
110+ '--use',
111+ '.',
112+ 'example.md',
113+ 'examples/example.md'
114+ ]).then(function (stderr) {
171115 st.equal(
172− res.stderr,
116+ stderr,
173117 [
174118 'example.md',
175119 ' 5:37-5:51 warning Link to unknown heading: `world`',
176− ' 23:10-23:37 warning Link to unknown file: ' +
177− '`examples/world.md`',
178− ' 25:10-25:35 warning Link to unknown file: ' +
179− '`examples/world.md`',
180− ' 37:10-37:42 warning Link to unknown heading in ' +
181− '`examples/example.md`: `world`',
182− ' 39:10-39:40 warning Link to unknown heading in ' +
183− '`examples/example.md`: `world`',
184− ' 45:10-45:40 warning Link to unknown file: ' +
185− '`examples/world.md`',
186− ' 45:10-45:40 warning Link to unknown heading in ' +
187− '`examples/world.md`: `hello`',
188− ' 47:10-47:38 warning Link to unknown file: ' +
189− '`examples/world.md`',
190− ' 47:10-47:38 warning Link to unknown heading in ' +
191− '`examples/world.md`: `hello`',
120+ ' 23:10-23:37 warning Link to unknown file: `examples/world.md`',
121+ ' 25:10-25:35 warning Link to unknown file: `examples/world.md`',
122+ ' 37:10-37:42 warning Link to unknown heading in `examples/example.md`: `world`',
123+ ' 39:10-39:40 warning Link to unknown heading in `examples/example.md`: `world`',
124+ ' 45:10-45:40 warning Link to unknown file: `examples/world.md`',
125+ ' 45:10-45:40 warning Link to unknown heading in `examples/world.md`: `hello`',
126+ ' 47:10-47:38 warning Link to unknown file: `examples/world.md`',
127+ ' 47:10-47:38 warning Link to unknown heading in `examples/world.md`: `hello`',
192128 '',
193129 'examples/example.md',
194130 ' 5:37-5:51 warning Link to unknown heading: ' +
@@ -202,63 +138,49 @@ test('remark-validate-links', function (t) {
202138 ' 35:10-35:32 warning Link to unknown heading in ' +
203139 '`world.md`: `hello`',
204140 '',
205− '⚠ 14 warnings',
206− ''
207− ].join('\n')
141+ '⚠ 14 warnings'
142+ ].join('\n'),
143+ 'should report'
208144 );
209−
210− st.end();
211145 });
212146 });
213147
214148 t.test('should work with definitions', function (st) {
215− assertion({
216− 'files': 'definitions.md',
217− 'color': false,
218− 'detectRC': false,
219− 'detectIgnore': false,
220− 'plugins': [
221− '../../../index.js'
222− ]
223− }, function (err, res) {
224− st.ifErr(err);
225−
149+ st.plan(1);
150+
151+ execa.stderr(bin, [
152+ '--no-config',
153+ '--no-ignore',
154+ '--use',
155+ '.',
156+ 'definitions.md'
157+ ]).then(function (stderr) {
226158 st.equal(
227− res.stderr,
159+ stderr,
228160 [
229161 'definitions.md',
230162 ' 5:12-5:21 warning Link to unknown heading: `world`',
231163 '',
232− '⚠ 1 warning',
233− ''
234− ].join('\n')
164+ '⚠ 1 warning'
165+ ].join('\n'),
166+ 'should report'
235167 );
236−
237− st.end();
238168 });
239169 });
240170
241171 t.test('should work on GitHub URLs when given a repo', function (st) {
242− assertion({
243− 'files': [
244− 'example.md',
245− 'examples/example.md'
246− ],
247− 'color': false,
248− 'detectRC': false,
249− 'detectIgnore': false,
250− 'plugins': {
251− '../../../index.js': {
252− 'repository': 'wooorm/test'
253− }
254− }
255− }, function (err, res) {
256− st.ifErr(err);
257−
258− st.equal(res.stdout, '');
259−
172+ st.plan(1);
173+
174+ execa.stderr(bin, [
175+ '--no-config',
176+ '--no-ignore',
177+ '--use',
178+ '.=repository:"wooorm/test"',
179+ 'example.md',
180+ 'examples/example.md'
181+ ]).then(function (stderr) {
260182 st.equal(
261− res.stderr,
183+ stderr,
262184 [
263185 'example.md',
264186 ' 5:37-5:51 warning Link to unknown heading: ' +
@@ -324,38 +246,36 @@ test('remark-validate-links', function (t) {
324246 ' 39:10-39:73 warning Link to unknown file: ' +
325247 '`world.md`',
326248 '',
327− '⚠ 30 warnings',
328− ''
329− ].join('\n')
249+ '⚠ 30 warnings'
250+ ].join('\n'),
251+ 'should report'
330252 );
331−
332− st.end();
333253 });
334254 });
335255
336256 t.test('should work on GitHub URLs when with package.json', function (st) {
257+ st.plan(1);
258+
259+ /* cwd is moved to `test/fixtures`. */
337260 fs.writeFileSync('./package.json', JSON.stringify({
338261 'repository': 'wooorm/test'
339262 }, 0, 2));
340263
341− assertion({
342− 'files': [
343− 'example.md',
344− 'examples/example.md'
345− ],
346− 'color': false,
347− 'detectRC': false,
348− 'detectIgnore': false,
349− 'plugins': [
350− '../../../index.js'
351− ]
352− }, function (err, res) {
264+ function clean() {
353265 fs.unlinkSync('./package.json');
266+ }
354267
355− st.ifErr(err);
356−
268+ execa.stderr(bin, [
269+ '--no-config',
270+ '--no-ignore',
271+ '--use',
272+ '../..',
273+ 'example.md',
274+ 'examples/example.md'
275+ ]).then(function (stderr) {
276+ clean();
357277 st.equal(
358− res.stderr,
278+ stderr,
359279 [
360280 'example.md',
361281 ' 5:37-5:51 warning Link to unknown heading: ' +
@@ -421,29 +341,25 @@ test('remark-validate-links', function (t) {
421341 ' 39:10-39:73 warning Link to unknown file: ' +
422342 '`world.md`',
423343 '',
424− '⚠ 30 warnings',
425− ''
426− ].join('\n')
344+ '⚠ 30 warnings'
345+ ].join('\n'),
346+ 'should report'
427347 );
428−
429− st.end();
430− });
348+ }, clean);
431349 });
432350
433351 t.test('should suggest similar links', function (st) {
434− assertion({
435− 'files': ['suggestions.md'],
436− 'color': false,
437− 'detectRC': false,
438− 'detectIgnore': false,
439− 'plugins': [
440− '../../../index.js'
441− ]
442− }, function (err, res) {
443− st.ifErr(err);
444−
352+ st.plan(1);
353+
354+ execa.stderr(bin, [
355+ '--no-config',
356+ '--no-ignore',
357+ '--use',
358+ '.',
359+ 'suggestions.md'
360+ ]).then(function (stderr) {
445361 st.equal(
446− res.stderr,
362+ stderr,
447363 [
448364 'suggestions.md',
449365 ' 3:22-3:37 warning Link to unknown heading: ' +
@@ -451,12 +367,10 @@ test('remark-validate-links', function (t) {
451367 ' 7:17-7:40 warning Link to unknown heading in ' +
452368 '`example.md`: `fiiiles`. Did you mean `files`',
453369 '',
454− '⚠ 2 warnings',
455− ''
456− ].join('\n')
370+ '⚠ 2 warnings'
371+ ].join('\n'),
372+ 'should report'
457373 );
458−
459− st.end();
460374 });
461375 });
462376});