Skip to content

Commit 0748a35

Browse files
authored
fix: fix isIgnored work (#23)
Previously, it does not work correctly.
1 parent de58ec4 commit 0748a35

File tree

4 files changed

+129
-80
lines changed

4 files changed

+129
-80
lines changed

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
"watch": "tsc -p . --watch"
2626
},
2727
"dependencies": {
28-
"@textlint/ast-node-types": "^13.2.0",
28+
"@textlint/ast-node-types": "^13.4.1",
2929
"structured-source": "^4.0.0",
3030
"unist-util-visit": "^2.0.3"
3131
},
3232
"devDependencies": {
33-
"@textlint/kernel": "^13.2.0",
34-
"@textlint/textlint-plugin-markdown": "^13.2.0",
35-
"@textlint/types": "^13.2.0",
36-
"@types/mocha": "^10.0.1",
37-
"@types/node": "^18.13.0",
33+
"@textlint/kernel": "^13.4.1",
34+
"@textlint/textlint-plugin-markdown": "^13.4.1",
35+
"@textlint/types": "^13.4.1",
36+
"@types/mocha": "^10.0.6",
37+
"@types/node": "^20.10.0",
3838
"markdown-to-ast": "^6.0.3",
3939
"mocha": "^10.2.0",
4040
"ts-node": "^10.9.1",
4141
"ts-node-test-register": "^10.0.0",
42-
"typescript": "^4.9.5"
42+
"typescript": "^5.3.2"
4343
}
4444
}

src/IgnoreNodeManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ export default class IgnoreNodeManager {
5757
* @returns {boolean}
5858
*/
5959
isIgnored(node: TxtNode | TxtParentNode) {
60-
const index = node.index;
61-
return this.isIgnoredIndex(index);
60+
return this.isIgnoredRange(node.range);
6261
}
6362

6463
/**

test/IgnoreNodeManager-test.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,53 @@
11
// LICENSE : MIT
22
import assert from 'assert'
33
import { IgnoreNodeManager } from "../src/index";
4-
import { TxtNodeType, TxtParentNode } from "@textlint/ast-node-types";
4+
import { TxtNode, TxtNodeType, TxtParentNode } from "@textlint/ast-node-types";
55
import { TextlintKernel, TextlintRuleModule } from "@textlint/kernel"
66
import { builtInPlugins } from "./textlint-helper";
77

88
describe("IgnoreNodeManager", function () {
9+
describe("#isIgnored()", () => {
10+
it("should ignore multiple nodes", () => {
11+
const ignoreManager = new IgnoreNodeManager();
12+
const outerNode: TxtNode = {
13+
type: "Str",
14+
range: [0, 1],
15+
loc: {
16+
start: {
17+
line: 1,
18+
column: 1
19+
},
20+
end: {
21+
line: 1,
22+
column: 2
23+
}
24+
},
25+
raw: "t",
26+
}
27+
const testNode: TxtNode = {
28+
type: "Str",
29+
range: [2, 5],
30+
loc: {
31+
start: {
32+
line: 1,
33+
column: 3
34+
},
35+
end: {
36+
line: 1,
37+
column: 6
38+
}
39+
},
40+
raw: "test",
41+
}
42+
// 0 1 2 3 4 5 6 7 8 9
43+
// ^ ^ ^
44+
// 5(endIndex) is not included
45+
ignoreManager.ignoreRange(testNode.range);
46+
// Should ignore:
47+
assert.ok(ignoreManager.isIgnored(testNode));
48+
assert.ok(ignoreManager.isIgnored(outerNode) === false);
49+
});
50+
});
951
describe("#isIgnoredRange()", () => {
1052
it("should ignore multiple nodes", () => {
1153
const ignoreManager = new IgnoreNodeManager();
@@ -130,4 +172,5 @@ This is **ignored**.
130172
});
131173
});
132174
});
133-
});
175+
})
176+
;

yarn.lock

Lines changed: 76 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -48,58 +48,58 @@
4848
"@jridgewell/resolve-uri" "^3.0.3"
4949
"@jridgewell/sourcemap-codec" "^1.4.10"
5050

51-
"@textlint/ast-node-types@^13.2.0":
52-
version "13.2.0"
53-
resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-13.2.0.tgz#9210439c88bc61664f8534a19cb7794dcc2061ed"
54-
integrity sha512-P76rGK9SoN/f40yVW2Dep3QkXQOkAYTzEZjV0yBf/W9N0c81HUDJPS//aRbS3ml0Yb7TNgkXYm/ChTsL79RcAg==
51+
"@textlint/ast-node-types@^13.4.1":
52+
version "13.4.1"
53+
resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-13.4.1.tgz#00424f7b9bc6fe15cf6a78468ffe1e5d1adce5b2"
54+
integrity sha512-qrZyhCh8Ekk6nwArx3BROybm9BnX6vF7VcZbijetV/OM3yfS4rTYhoMWISmhVEP2H2re0CtWEyMl/XF+WdvVLQ==
5555

5656
"@textlint/ast-node-types@^4.0.0":
5757
version "4.4.3"
5858
resolved "https://registry.yarnpkg.com/@textlint/ast-node-types/-/ast-node-types-4.4.3.tgz#fdba16e8126cddc50f45433ce7f6c55e7829566c"
5959
integrity sha512-qi2jjgO6Tn3KNPGnm6B7p6QTEPvY95NFsIAaJuwbulur8iJUEenp1OnoUfiDaC/g2WPPEFkcfXpmnu8XEMFo2A==
6060

61-
"@textlint/ast-tester@^13.2.0":
62-
version "13.2.0"
63-
resolved "https://registry.yarnpkg.com/@textlint/ast-tester/-/ast-tester-13.2.0.tgz#6938b1c4ccf59df4fe278dd898fe0c7e1bcb8c8c"
64-
integrity sha512-4UHmeT1J2FGm1rfTAIjWw3LWEZPMuHCA2hdAiXVZXZbIOQYE/kmMvUgUeFAxEj0Wg7ozCoOMsTr7T0VF/8CZlA==
61+
"@textlint/ast-tester@^13.4.1":
62+
version "13.4.1"
63+
resolved "https://registry.yarnpkg.com/@textlint/ast-tester/-/ast-tester-13.4.1.tgz#74a704b582fe7cd3caf1d3ae1c65fa0d7f1f6fec"
64+
integrity sha512-YSHUR1qDgMPGF5+nvrquEhif6zRJ667xUnfP/9rTNtThIhoTQINvczr5/7xa43F1PDWplL6Curw+2jrE1qHwGQ==
6565
dependencies:
66-
"@textlint/ast-node-types" "^13.2.0"
66+
"@textlint/ast-node-types" "^13.4.1"
6767
debug "^4.3.4"
6868

69-
"@textlint/ast-traverse@^13.2.0":
70-
version "13.2.0"
71-
resolved "https://registry.yarnpkg.com/@textlint/ast-traverse/-/ast-traverse-13.2.0.tgz#a607aee37d297b46f255ea36b3461bd43fd17316"
72-
integrity sha512-aqGLu8Yiex/CJGkKXF2p7k3OfzqGBjUp4Of3hPFWb/oARQsUKIeMfQB0bNi5rqcIeOVQhMVTcMzHiW2LPOjDSw==
73-
dependencies:
74-
"@textlint/ast-node-types" "^13.2.0"
75-
76-
"@textlint/feature-flag@^13.2.0":
77-
version "13.2.0"
78-
resolved "https://registry.yarnpkg.com/@textlint/feature-flag/-/feature-flag-13.2.0.tgz#0b702bb5dde83b04fabbf02696296371e387ddbd"
79-
integrity sha512-HJaz2wT4DDywn5s5r+9N3rEw6GhOB5/IVVVO4HfgALAIrO4K9cSlR1lTFFYgr15uWf0wMnGE8lu43RR9LtDXHw==
80-
81-
"@textlint/kernel@^13.2.0":
82-
version "13.2.0"
83-
resolved "https://registry.yarnpkg.com/@textlint/kernel/-/kernel-13.2.0.tgz#d374c1c3da239b5e728eec56c71c42a719779d65"
84-
integrity sha512-RUKRax9EhRQDLr9YLv6qxnCnTIre3NouZHyjXR2jB1F6zdOPU+mhI3IC1c7k+iOQVajTi6wWq63POU+ffbpvzA==
85-
dependencies:
86-
"@textlint/ast-node-types" "^13.2.0"
87-
"@textlint/ast-tester" "^13.2.0"
88-
"@textlint/ast-traverse" "^13.2.0"
89-
"@textlint/feature-flag" "^13.2.0"
90-
"@textlint/source-code-fixer" "^13.2.0"
91-
"@textlint/types" "^13.2.0"
92-
"@textlint/utils" "^13.2.0"
69+
"@textlint/ast-traverse@^13.4.1":
70+
version "13.4.1"
71+
resolved "https://registry.yarnpkg.com/@textlint/ast-traverse/-/ast-traverse-13.4.1.tgz#1f35f15a54542c76aef71ce1e4f4a83723016d45"
72+
integrity sha512-uucuC7+NHWkXx2TX5vuyreuHeb+GFiA83V65I+FnYP5EC4dAMOQ86rTSPrZmCwLz+qIWgfDgihGzPccpj3EZGg==
73+
dependencies:
74+
"@textlint/ast-node-types" "^13.4.1"
75+
76+
"@textlint/feature-flag@^13.4.1":
77+
version "13.4.1"
78+
resolved "https://registry.yarnpkg.com/@textlint/feature-flag/-/feature-flag-13.4.1.tgz#79d27b099baa54166ca4cdd1da80336e7b08192d"
79+
integrity sha512-qY8gKUf30XtzWMTkwYeKytCo6KPx6milpz8YZhuRsEPjT/5iNdakJp5USWDQWDrwbQf7RbRncQdU+LX5JbM9YA==
80+
81+
"@textlint/kernel@^13.4.1":
82+
version "13.4.1"
83+
resolved "https://registry.yarnpkg.com/@textlint/kernel/-/kernel-13.4.1.tgz#b98f6c501b73db8b8ec46cd1aac70937ee73efa8"
84+
integrity sha512-r2sUhjPysFjl2Ax37x9AfWkJM8jgKN0bL4SX3xRzOukdcj69Dst5On5qBZtULaVMX1LDkwkdxA6ZEADmq27qQA==
85+
dependencies:
86+
"@textlint/ast-node-types" "^13.4.1"
87+
"@textlint/ast-tester" "^13.4.1"
88+
"@textlint/ast-traverse" "^13.4.1"
89+
"@textlint/feature-flag" "^13.4.1"
90+
"@textlint/source-code-fixer" "^13.4.1"
91+
"@textlint/types" "^13.4.1"
92+
"@textlint/utils" "^13.4.1"
9393
debug "^4.3.4"
9494
fast-equals "^4.0.3"
9595
structured-source "^4.0.0"
9696

97-
"@textlint/markdown-to-ast@^13.2.0":
98-
version "13.2.0"
99-
resolved "https://registry.yarnpkg.com/@textlint/markdown-to-ast/-/markdown-to-ast-13.2.0.tgz#301d032b36c87418c6518a7c58b5092c3c733223"
100-
integrity sha512-eYd1XgbzirQk/fDKnNAsT3QKTtEz+CSpBiGIzvaD1kYEzA1aSWtWEJoyZU6DwFJgFs+6scAdcYT2O264IVDRyg==
97+
"@textlint/markdown-to-ast@^13.4.1":
98+
version "13.4.1"
99+
resolved "https://registry.yarnpkg.com/@textlint/markdown-to-ast/-/markdown-to-ast-13.4.1.tgz#63f1f87fb059c083c13a434f7117aca786867835"
100+
integrity sha512-jUa5bTNmxjEgfCXW4xfn7eSJqzUXyNKiIDWLKtI4MUKRNhT3adEaa/NuQl0Mii3Hu3HraZR7hYhRHLh+eeM43w==
101101
dependencies:
102-
"@textlint/ast-node-types" "^13.2.0"
102+
"@textlint/ast-node-types" "^13.4.1"
103103
debug "^4.3.4"
104104
mdast-util-gfm-autolink-literal "^0.1.3"
105105
remark-footnotes "^3.0.0"
@@ -109,32 +109,32 @@
109109
traverse "^0.6.7"
110110
unified "^9.2.2"
111111

112-
"@textlint/source-code-fixer@^13.2.0":
113-
version "13.2.0"
114-
resolved "https://registry.yarnpkg.com/@textlint/source-code-fixer/-/source-code-fixer-13.2.0.tgz#fe9a7235ad431ce916b99857e3eaf163f340befd"
115-
integrity sha512-t8J4kgVQp+G/s5c4DcmAuE8WR2+7Ovf++SQgeRaUoEGoZP+trrF/JaIzlNaH+5MDk6vQ2Z1+WZc2VL+oM5uNnA==
112+
"@textlint/source-code-fixer@^13.4.1":
113+
version "13.4.1"
114+
resolved "https://registry.yarnpkg.com/@textlint/source-code-fixer/-/source-code-fixer-13.4.1.tgz#2408e6209be0290c58b92750375cff4e976f415a"
115+
integrity sha512-Sl29f3Tpimp0uVE3ysyJBjxaFTVYLOXiJX14eWCQ/kC5ZhIXGosEbStzkP1n8Urso1rs1W4p/2UemVAm3NH2ng==
116116
dependencies:
117-
"@textlint/types" "^13.2.0"
117+
"@textlint/types" "^13.4.1"
118118
debug "^4.3.4"
119119

120-
"@textlint/textlint-plugin-markdown@^13.2.0":
121-
version "13.2.0"
122-
resolved "https://registry.yarnpkg.com/@textlint/textlint-plugin-markdown/-/textlint-plugin-markdown-13.2.0.tgz#1bed77e177fdff0db651f248c18048b242df03e1"
123-
integrity sha512-oLvCp9RqydnfxUacBienhsliTLIsH5zXHeQpQyaDrQtL3syweBgtYFyOoZq1X6jZOU0QLnCCkn1RofMumRBfxA==
120+
"@textlint/textlint-plugin-markdown@^13.4.1":
121+
version "13.4.1"
122+
resolved "https://registry.yarnpkg.com/@textlint/textlint-plugin-markdown/-/textlint-plugin-markdown-13.4.1.tgz#8e1c78c4b5b501bf7e2def6c7d1cbd12a3a8436f"
123+
integrity sha512-OcLkFKYmbYeGJ0kj2487qcicCYTiE2vJLwfPcUDJrNoMYak5JtvHJfWffck8gON2mEM00DPkHH0UdxZpFjDfeg==
124124
dependencies:
125-
"@textlint/markdown-to-ast" "^13.2.0"
125+
"@textlint/markdown-to-ast" "^13.4.1"
126126

127-
"@textlint/types@^13.2.0":
128-
version "13.2.0"
129-
resolved "https://registry.yarnpkg.com/@textlint/types/-/types-13.2.0.tgz#20c83f589b2cb7f9f72b4d1e741c83411a043b81"
130-
integrity sha512-65kCcyym3zQFVU10tzGHGl7awyNDK43HtLTuJo/YUWxSpaQJRM3INk1ePVzfj+M+Uru4chnl+MPYQwd/X3z2hw==
127+
"@textlint/types@^13.4.1":
128+
version "13.4.1"
129+
resolved "https://registry.yarnpkg.com/@textlint/types/-/types-13.4.1.tgz#612818525e25331cd7ee315cfbadc38ad070edee"
130+
integrity sha512-1ApwQa31sFmiJeJ5yTNFqjbb2D1ICZvIDW0tFSM0OtmQCSDFNcKD3YrrwDBgSokZ6gWQq/FpNjlhi6iETUWt0Q==
131131
dependencies:
132-
"@textlint/ast-node-types" "^13.2.0"
132+
"@textlint/ast-node-types" "^13.4.1"
133133

134-
"@textlint/utils@^13.2.0":
135-
version "13.2.0"
136-
resolved "https://registry.yarnpkg.com/@textlint/utils/-/utils-13.2.0.tgz#60be68b39c158b9d89d50cb197cf7596780c3f0f"
137-
integrity sha512-3DtR5AYbltOH+4GOhjmB4x3aF5xJhoDGfgOZ4Is9uoXeqC+1eyVCG6NeZ6QyuIuHZKy5p8S48t7JgWb8LM47aA==
134+
"@textlint/utils@^13.4.1":
135+
version "13.4.1"
136+
resolved "https://registry.yarnpkg.com/@textlint/utils/-/utils-13.4.1.tgz#721b6c4c83a152f23a70ef0bbbdc7d1c635b5014"
137+
integrity sha512-wX8RT1ejHAPTDmqlzngf0zI5kYoe3QvGDcj+skoTxSv+m/wOs/NyEr92d+ahCP32YqFYzXlqU7aDx2FkULKT+g==
138138

139139
"@tsconfig/node10@^1.0.7":
140140
version "1.0.9"
@@ -163,15 +163,17 @@
163163
dependencies:
164164
"@types/unist" "*"
165165

166-
"@types/mocha@^10.0.1":
167-
version "10.0.1"
168-
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.1.tgz#2f4f65bb08bc368ac39c96da7b2f09140b26851b"
169-
integrity sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==
166+
"@types/mocha@^10.0.6":
167+
version "10.0.6"
168+
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.6.tgz#818551d39113081048bdddbef96701b4e8bb9d1b"
169+
integrity sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==
170170

171-
"@types/node@^18.13.0":
172-
version "18.13.0"
173-
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.13.0.tgz#0400d1e6ce87e9d3032c19eb6c58205b0d3f7850"
174-
integrity sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==
171+
"@types/node@^20.10.0":
172+
version "20.10.0"
173+
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.0.tgz#16ddf9c0a72b832ec4fcce35b8249cf149214617"
174+
integrity sha512-D0WfRmU9TQ8I9PFx9Yc+EBHw+vSpIub4IDvQivcp26PtPrdMGAq5SDcpXEo/epqa/DXotVpekHiLNTg3iaKXBQ==
175+
dependencies:
176+
undici-types "~5.26.4"
175177

176178
"@types/normalize-package-data@^2.4.0":
177179
version "2.4.1"
@@ -1379,10 +1381,15 @@ type-fest@^0.6.0:
13791381
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b"
13801382
integrity sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==
13811383

1382-
typescript@^4.9.5:
1383-
version "4.9.5"
1384-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
1385-
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
1384+
typescript@^5.3.2:
1385+
version "5.3.2"
1386+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.2.tgz#00d1c7c1c46928c5845c1ee8d0cc2791031d4c43"
1387+
integrity sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==
1388+
1389+
undici-types@~5.26.4:
1390+
version "5.26.5"
1391+
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
1392+
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
13861393

13871394
unherit@^1.0.4:
13881395
version "1.1.3"

0 commit comments

Comments
 (0)