Skip to content

Commit b91ea4d

Browse files
azunodaguti
authored andcommitted
test(no-dead-link): Add local file test (#95)
- Update to [email protected] and tester 4.0.0
1 parent a4b11d2 commit b91ea4d

File tree

4 files changed

+118
-90
lines changed

4 files changed

+118
-90
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"mocha": "^4.0.1",
4646
"npm-run-all": "^4.1.2",
4747
"prettier": "^1.9.2",
48-
"textlint": "^9.1.1",
49-
"textlint-tester": "^3.0.3"
48+
"textlint": "^10.0.0",
49+
"textlint-tester": "4.0.0"
5050
}
5151
}

src/no-dead-link.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { RuleHelper } from 'textlint-rule-helper';
22
import fetch from 'isomorphic-fetch';
33
import URL from 'url';
4-
import path from 'path';
54
import fs from 'fs-extra';
65

76
const DEFAULT_OPTIONS = {
8-
checkRelative: false, // `true` enables availability checks for relative URIs.
97
baseURI: null, // {String|null} a base URI to resolve relative URIs.
108
ignore: [], // {Array<String>} URIs to be skipped from availability checks.
119
};
@@ -133,8 +131,7 @@ function reporter(context, options = {}) {
133131

134132
if (isRelative(uri)) {
135133
const filePath = getFilePath();
136-
const base = opts.baseURI || (filePath && path.dirname(filePath));
137-
134+
const base = opts.baseURI || filePath;
138135
if (!base) {
139136
const message =
140137
'Unable to resolve the relative URI. Please check if the base URI is correctly specified.';

test/no-dead-link.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ tester.run('no-dead-link', rule, {
4242
baseURI: path.join(__dirname, 'fixtures/'),
4343
},
4444
},
45+
{
46+
inputPath: path.join(__dirname, 'fixtures/a.md'),
47+
options: {
48+
baseURI: path.join(__dirname, 'fixtures/'),
49+
},
50+
},
51+
{
52+
inputPath: path.join(__dirname, 'fixtures/a.md'),
53+
},
4554
],
4655
invalid: [
4756
{
@@ -126,5 +135,22 @@ tester.run('no-dead-link', rule, {
126135
},
127136
],
128137
},
138+
{
139+
inputPath: path.join(__dirname, 'fixtures/b.md'),
140+
errors: [
141+
{
142+
line: 1,
143+
column: 14,
144+
},
145+
{
146+
line: 2,
147+
column: 14,
148+
},
149+
{
150+
line: 3,
151+
column: 14,
152+
},
153+
],
154+
},
129155
],
130156
});

yarn.lock

Lines changed: 89 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,31 @@
1212
dependencies:
1313
"@azu/format-text" "^1.0.1"
1414

15-
"@textlint/ast-node-types@^2.0.0":
16-
version "2.0.0"
17-
resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-2.0.0.tgz#b927557ecab55fbb8360140b7b6f1de0c160583f"
15+
"@textlint/ast-node-types@^3.0.0":
16+
version "3.0.0"
17+
resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-3.0.0.tgz#bdf67d85adad6c2caaada0e5cc953b7f9016376b"
1818

19-
"@textlint/feature-flag@^2.0.0":
20-
version "2.0.0"
21-
resolved "https://registry.yarnpkg.com/@textlint/feature-flag/-/feature-flag-2.0.0.tgz#817cd022291f3a8e2cd0580fb9799a9714f3c530"
19+
"@textlint/feature-flag@^3.0.0":
20+
version "3.0.0"
21+
resolved "https://registry.yarnpkg.com/@textlint/feature-flag/-/feature-flag-3.0.0.tgz#1f28f67de58f8e2287f8a2bd1812f1891a8b0ed1"
2222
dependencies:
2323
map-like "^1.1.2"
2424

25-
"@textlint/kernel@^1.0.3":
26-
version "1.0.3"
27-
resolved "https://registry.yarnpkg.com/@textlint/kernel/-/kernel-1.0.3.tgz#b3c9ff2977a40b357986775fe3afa79aa114a766"
25+
"@textlint/kernel@^2.0.0":
26+
version "2.0.0"
27+
resolved "https://registry.yarnpkg.com/@textlint/kernel/-/kernel-2.0.0.tgz#6d29dbe5b1c758f823eb9cce351b4973eb83d265"
2828
dependencies:
29-
"@textlint/ast-node-types" "^2.0.0"
30-
"@textlint/feature-flag" "^2.0.0"
31-
"@types/bluebird" "^3.5.11"
32-
bluebird "^3.5.0"
33-
carrack "^0.5.0"
29+
"@textlint/ast-node-types" "^3.0.0"
30+
"@textlint/feature-flag" "^3.0.0"
31+
"@types/bluebird" "^3.5.18"
32+
bluebird "^3.5.1"
3433
debug "^2.6.6"
3534
deep-equal "^1.0.1"
36-
is-my-json-valid "^2.16.0"
37-
map-like "^1.1.2"
3835
object-assign "^4.1.1"
3936
structured-source "^3.0.2"
40-
txt-ast-traverse "^1.2.1"
37+
txt-ast-traverse "^2.0.0"
4138

42-
"@types/bluebird@^3.5.11":
39+
"@types/bluebird@^3.5.18":
4340
version "3.5.18"
4441
resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.18.tgz#6a60435d4663e290f3709898a4f75014f279c4d6"
4542

@@ -734,14 +731,14 @@ block-stream@*:
734731
dependencies:
735732
inherits "~2.0.0"
736733

737-
bluebird@^3.0.1, bluebird@^3.5.0:
738-
version "3.5.1"
739-
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"
740-
741734
bluebird@^3.0.5:
742735
version "3.4.7"
743736
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3"
744737

738+
bluebird@^3.5.1:
739+
version "3.5.1"
740+
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"
741+
745742
746743
version "2.10.1"
747744
resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f"
@@ -800,13 +797,6 @@ caniuse-lite@^1.0.30000780:
800797
version "1.0.30000783"
801798
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000783.tgz#9b5499fb1b503d2345d12aa6b8612852f4276ffd"
802799

803-
carrack@^0.5.0:
804-
version "0.5.0"
805-
resolved "https://registry.yarnpkg.com/carrack/-/carrack-0.5.0.tgz#d8ce373a5d89d55dc22dc10213b74e219b9ecee9"
806-
dependencies:
807-
bluebird "^3.0.1"
808-
throat "^2.0.2"
809-
810800
caseless@~0.11.0:
811801
version "0.11.0"
812802
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7"
@@ -1848,7 +1838,7 @@ is-hexadecimal@^1.0.0:
18481838
version "1.0.0"
18491839
resolved "https://registry.yarnpkg.com/is-hexadecimal/-/is-hexadecimal-1.0.0.tgz#5c459771d2af9a2e3952781fd54fcb1bcfe4113c"
18501840

1851-
is-my-json-valid@^2.12.4, is-my-json-valid@^2.16.0:
1841+
is-my-json-valid@^2.12.4:
18521842
version "2.16.1"
18531843
resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.1.tgz#5a846777e2c2620d1e69104e5d3a03b1f6088f11"
18541844
dependencies:
@@ -2235,14 +2225,14 @@ lru-cache@^4.0.1:
22352225
pseudomap "^1.0.1"
22362226
yallist "^2.0.0"
22372227

2238-
map-like@^1.0.1:
2239-
version "1.0.3"
2240-
resolved "https://registry.yarnpkg.com/map-like/-/map-like-1.0.3.tgz#1bda42b0510116730c878366de9e7ef8cc375131"
2241-
22422228
map-like@^1.1.2:
22432229
version "1.1.3"
22442230
resolved "https://registry.yarnpkg.com/map-like/-/map-like-1.1.3.tgz#6faaca5339e0cc6567a3a55dd281fd871a39e5da"
22452231

2232+
map-like@^2.0.0:
2233+
version "2.0.0"
2234+
resolved "https://registry.yarnpkg.com/map-like/-/map-like-2.0.0.tgz#94496d49ad333c0dc3234b27adbbd1e8535953b4"
2235+
22462236
map-stream@~0.1.0:
22472237
version "0.1.0"
22482238
resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194"
@@ -2255,11 +2245,11 @@ markdown-table@^1.1.0:
22552245
version "1.1.1"
22562246
resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.1.tgz#4b3dd3a133d1518b8ef0dbc709bf2a1b4824bc8c"
22572247

2258-
markdown-to-ast@^5.0.0:
2259-
version "5.0.0"
2260-
resolved "https://registry.yarnpkg.com/markdown-to-ast/-/markdown-to-ast-5.0.0.tgz#c5848dd5ddc69f81499eabafb3a420b6ed4af142"
2248+
markdown-to-ast@^6.0.0:
2249+
version "6.0.0"
2250+
resolved "https://registry.yarnpkg.com/markdown-to-ast/-/markdown-to-ast-6.0.0.tgz#dff3d970c07c95b162ac337b0e5aede93e1d6f0f"
22612251
dependencies:
2262-
"@textlint/ast-node-types" "^2.0.0"
2252+
"@textlint/ast-node-types" "^3.0.0"
22632253
debug "^2.1.3"
22642254
remark "^7.0.1"
22652255
structured-source "^3.0.2"
@@ -2735,7 +2725,7 @@ randomatic@^1.1.3:
27352725
is-number "^2.0.2"
27362726
kind-of "^3.0.2"
27372727

2738-
rc-config-loader@^2.0.0:
2728+
rc-config-loader@^2.0.1:
27392729
version "2.0.1"
27402730
resolved "https://registry.yarnpkg.com/rc-config-loader/-/rc-config-loader-2.0.1.tgz#8c8452f59bdd10d448a67762dccf7c1b247db860"
27412731
dependencies:
@@ -2763,6 +2753,13 @@ read-pkg-up@^2.0.0:
27632753
find-up "^2.0.0"
27642754
read-pkg "^2.0.0"
27652755

2756+
read-pkg-up@^3.0.0:
2757+
version "3.0.0"
2758+
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07"
2759+
dependencies:
2760+
find-up "^2.0.0"
2761+
read-pkg "^3.0.0"
2762+
27662763
read-pkg@^1.1.0:
27672764
version "1.1.0"
27682765
resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28"
@@ -2971,7 +2968,7 @@ resolve-from@^1.0.0:
29712968
version "1.0.1"
29722969
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"
29732970

2974-
resolve@^1.2.0, resolve@^1.4.0:
2971+
resolve@^1.2.0:
29752972
version "1.5.0"
29762973
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"
29772974
dependencies:
@@ -3313,9 +3310,23 @@ text-table@^0.2.0, text-table@~0.2.0:
33133310
version "0.2.0"
33143311
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
33153312

3316-
textlint-formatter@^1.7.3:
3317-
version "1.8.0"
3318-
resolved "https://registry.yarnpkg.com/textlint-formatter/-/textlint-formatter-1.8.0.tgz#3254e9bd7d4c8cf031b74778bf21bc086faff3eb"
3313+
textlint-fixer-formatter@^2.0.0:
3314+
version "2.0.0"
3315+
resolved "https://registry.yarnpkg.com/textlint-fixer-formatter/-/textlint-fixer-formatter-2.0.0.tgz#708fd72f0d1acfe99bb5250d19975214d65369d9"
3316+
dependencies:
3317+
"@textlint/kernel" "^2.0.0"
3318+
chalk "^1.1.3"
3319+
debug "^2.1.0"
3320+
diff "^2.2.2"
3321+
interop-require "^1.0.0"
3322+
is-file "^1.0.0"
3323+
string-width "^1.0.1"
3324+
text-table "^0.2.0"
3325+
try-resolve "^1.0.1"
3326+
3327+
textlint-formatter@^2.0.0:
3328+
version "2.0.0"
3329+
resolved "https://registry.yarnpkg.com/textlint-formatter/-/textlint-formatter-2.0.0.tgz#6c36fadf814851fc77845c34a9ddadc2332c6bde"
33193330
dependencies:
33203331
"@azu/format-text" "^1.0.1"
33213332
"@azu/style-format" "^1.0.0"
@@ -3332,72 +3343,66 @@ textlint-formatter@^1.7.3:
33323343
try-resolve "^1.0.1"
33333344
xml-escape "^1.0.0"
33343345

3335-
textlint-plugin-markdown@^3.0.3:
3336-
version "3.0.3"
3337-
resolved "https://registry.yarnpkg.com/textlint-plugin-markdown/-/textlint-plugin-markdown-3.0.3.tgz#37962181ca42e83f71d982ecdf22c789a18e2bde"
3346+
textlint-plugin-markdown@^4.0.0:
3347+
version "4.0.0"
3348+
resolved "https://registry.yarnpkg.com/textlint-plugin-markdown/-/textlint-plugin-markdown-4.0.0.tgz#4e9dc0e69448faf2beb068622b4183d28b2471b6"
33383349
dependencies:
3339-
markdown-to-ast "^5.0.0"
3350+
markdown-to-ast "^6.0.0"
33403351

3341-
textlint-plugin-text@^2.0.3:
3342-
version "2.0.3"
3343-
resolved "https://registry.yarnpkg.com/textlint-plugin-text/-/textlint-plugin-text-2.0.3.tgz#a66dfc277dce20de533979add04a6820a9855010"
3352+
textlint-plugin-text@^3.0.0:
3353+
version "3.0.0"
3354+
resolved "https://registry.yarnpkg.com/textlint-plugin-text/-/textlint-plugin-text-3.0.0.tgz#80284ef9161aa24f9067c03caa189b7e45c93683"
33443355
dependencies:
3345-
txt-to-ast "^2.0.0"
3356+
txt-to-ast "^3.0.0"
33463357

33473358
textlint-rule-helper@^2.0.0:
33483359
version "2.0.0"
33493360
resolved "https://registry.yarnpkg.com/textlint-rule-helper/-/textlint-rule-helper-2.0.0.tgz#95cb4696c95c4258d2e3389e9e64b849f9721382"
33503361
dependencies:
33513362
unist-util-visit "^1.1.0"
33523363

3353-
textlint-tester@^3.0.3:
3354-
version "3.0.3"
3355-
resolved "https://registry.yarnpkg.com/textlint-tester/-/textlint-tester-3.0.3.tgz#7c3c9c01844ce7d3013886418f0bce3f02dc948b"
3364+
textlint-tester@4.0.0:
3365+
version "4.0.0"
3366+
resolved "https://registry.yarnpkg.com/textlint-tester/-/textlint-tester-4.0.0.tgz#9b29d736133d7d8de35c117e0c20b36b58071981"
33563367
dependencies:
3357-
"@textlint/feature-flag" "^2.0.0"
3358-
textlint "^9.1.1"
3368+
"@textlint/feature-flag" "^3.0.0"
3369+
textlint "^10.0.0"
33593370

3360-
textlint@^9.1.1:
3361-
version "9.1.1"
3362-
resolved "https://registry.yarnpkg.com/textlint/-/textlint-9.1.1.tgz#8dc24e348f1e5e328089934f37fb0c71d9c4dfb9"
3371+
textlint@^10.0.0:
3372+
version "10.0.0"
3373+
resolved "https://registry.yarnpkg.com/textlint/-/textlint-10.0.0.tgz#d0fa372ba90c3bae1a5440c9c6a94a16477c0fee"
33633374
dependencies:
3364-
"@textlint/ast-node-types" "^2.0.0"
3365-
"@textlint/feature-flag" "^2.0.0"
3366-
"@textlint/kernel" "^1.0.3"
3375+
"@textlint/ast-node-types" "^3.0.0"
3376+
"@textlint/feature-flag" "^3.0.0"
3377+
"@textlint/kernel" "^2.0.0"
3378+
"@types/bluebird" "^3.5.18"
33673379
bluebird "^3.0.5"
3368-
chalk "^1.1.1"
33693380
debug "^2.1.0"
33703381
deep-equal "^1.0.1"
3371-
diff "^2.2.2"
33723382
file-entry-cache "^2.0.0"
33733383
get-stdin "^5.0.1"
33743384
glob "^7.1.1"
33753385
interop-require "^1.0.0"
33763386
is-file "^1.0.0"
33773387
log-symbols "^1.0.2"
3378-
map-like "^1.0.1"
3388+
map-like "^2.0.0"
33793389
md5 "^2.2.1"
33803390
mkdirp "^0.5.0"
33813391
object-assign "^4.0.1"
33823392
optionator "^0.8.0"
33833393
path-to-glob-pattern "^1.0.2"
3384-
rc-config-loader "^2.0.0"
3394+
rc-config-loader "^2.0.1"
33853395
read-pkg "^1.1.0"
3386-
resolve "^1.4.0"
3387-
string-width "^1.0.1"
3396+
read-pkg-up "^3.0.0"
33883397
structured-source "^3.0.2"
3389-
text-table "^0.2.0"
3390-
textlint-formatter "^1.7.3"
3391-
textlint-plugin-markdown "^3.0.3"
3392-
textlint-plugin-text "^2.0.3"
3398+
textlint-fixer-formatter "^2.0.0"
3399+
textlint-formatter "^2.0.0"
3400+
textlint-plugin-markdown "^4.0.0"
3401+
textlint-plugin-text "^3.0.0"
33933402
try-resolve "^1.0.1"
3394-
txt-ast-traverse "^1.2.0"
3403+
txt-ast-traverse "^2.0.0"
33953404
unique-concat "^0.2.2"
33963405

3397-
throat@^2.0.2:
3398-
version "2.0.2"
3399-
resolved "https://registry.yarnpkg.com/throat/-/throat-2.0.2.tgz#a9fce808b69e133a632590780f342c30a6249b02"
3400-
34013406
through@2, through@^2.3.6, through@~2.3, through@~2.3.1:
34023407
version "2.3.8"
34033408
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
@@ -3454,15 +3459,15 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:
34543459
version "0.14.5"
34553460
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
34563461

3457-
txt-ast-traverse@^1.2.0, txt-ast-traverse@^1.2.1:
3458-
version "1.2.1"
3459-
resolved "https://registry.yarnpkg.com/txt-ast-traverse/-/txt-ast-traverse-1.2.1.tgz#58e3fe43ddb5db5ca8b51142943b0d1b970def41"
3460-
3461-
txt-to-ast@^2.0.0:
3462+
txt-ast-traverse@^2.0.0:
34623463
version "2.0.0"
3463-
resolved "https://registry.yarnpkg.com/txt-to-ast/-/txt-to-ast-2.0.0.tgz#6a00142d594235a1b169b72026c0f18cd69a3105"
3464+
resolved "https://registry.yarnpkg.com/txt-ast-traverse/-/txt-ast-traverse-2.0.0.tgz#ce4463e0a12f860400b0d7b9c1342aa21d135ed2"
3465+
3466+
txt-to-ast@^3.0.0:
3467+
version "3.0.0"
3468+
resolved "https://registry.yarnpkg.com/txt-to-ast/-/txt-to-ast-3.0.0.tgz#742eff758176ceab9cfe43bf6466dea344220fc7"
34643469
dependencies:
3465-
"@textlint/ast-node-types" "^2.0.0"
3470+
"@textlint/ast-node-types" "^3.0.0"
34663471

34673472
type-check@~0.3.2:
34683473
version "0.3.2"

0 commit comments

Comments
 (0)