Skip to content

Commit 55ac641

Browse files
authored
fix: support LinkReference types (#17)
* fix: support LinkReference types [title][id] [title] [title]: https://example.com [id]: https://example.com 形式を判定しないように修正 * Apply suggestions from code review
1 parent 1c04a8c commit 55ac641

File tree

6 files changed

+11
-7
lines changed
  • packages
    • textlint-rule-ja-no-space-around-parentheses
    • textlint-rule-ja-no-space-between-full-width/src
    • textlint-rule-ja-space-after-exclamation/src
    • textlint-rule-ja-space-after-question/src
    • textlint-rule-ja-space-between-half-and-full-width/src

6 files changed

+11
-7
lines changed

packages/textlint-rule-ja-no-space-around-parentheses/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function reporter(context) {
2222
const helper = new RuleHelper();
2323
return {
2424
[Syntax.Str](node){
25-
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
25+
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
2626
return;
2727
}
2828
const text = getSource(node);

packages/textlint-rule-ja-no-space-around-parentheses/test/index-test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ tester.run("かっこ類と隣接する文字の間のスペースの有無", ru
1212
そのため、特別な実装は必要なく
1313
「拡張する時は\`calculator.prototype\`の代わりに\`calculator.fn\`を拡張してください」
1414
というルールがあるだけとも言えます。
15-
`
15+
`,
16+
"[テスト 「文章」 です](https://example)", // ignore Link
17+
"[テスト 「文章」 です][]" +
18+
"\n\n" +
19+
"[テスト 「文章」 です]: https://example.com" // ignore ReferenceDef
1620
],
1721
invalid: [
1822
{

packages/textlint-rule-ja-no-space-between-full-width/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function reporter(context) {
1616
const helper = new RuleHelper();
1717
return {
1818
[Syntax.Str](node){
19-
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
19+
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
2020
return;
2121
}
2222
const text = getSource(node);

packages/textlint-rule-ja-space-after-exclamation/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function reporter(context) {
1212
const helper = new RuleHelper();
1313
return {
1414
[Syntax.Str](node){
15-
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
15+
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
1616
return;
1717
}
1818
let text = getSource(node);

packages/textlint-rule-ja-space-after-question/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function reporter(context) {
1212
const helper = new RuleHelper();
1313
return {
1414
[Syntax.Str](node){
15-
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
15+
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
1616
return;
1717
}
1818
let text = getSource(node);

packages/textlint-rule-ja-space-between-half-and-full-width/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function reporter(context, options = {}) {
7777
return {
7878
[Syntax.Str](node){
7979
const isIgnoredParentNode = helper.isChildNode(node, [
80-
Syntax.Header, Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis
80+
Syntax.Header, Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis
8181
]);
8282
if (isIgnoredParentNode) {
8383
return;
@@ -96,4 +96,4 @@ function reporter(context, options = {}) {
9696
module.exports = {
9797
linter: reporter,
9898
fixer: reporter
99-
};
99+
};

0 commit comments

Comments
 (0)