Skip to content

fix: リンクの後にスペースを強制する処理が正常に動作していない不具合を修正 #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/textlint-rule-ja-space-around-link/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function reporter(context, options) {
// InlineCodeの後に文字が存在している時のみチェック
if (existAfterChar) {
if (allowAfterSpace) {
if (afterChar !== " " && isJapaneseChar(beforeChar)) {
if (afterChar !== " " && isJapaneseChar(afterChar)) {
report(
node,
new RuleError("リンクの後にスペースを入れてください。", {
Expand Down
28 changes: 28 additions & 0 deletions packages/textlint-rule-ja-space-around-link/test/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,34 @@ tester.run("Link周りのスペース", rule, {
},
],
},
{
text: "これは[README](./README.md)おかしい",
output: "これは [README](./README.md)おかしい",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textの内容を書いたらoutputの内容になるという感じにテストですね。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この場合はbefore: true なので前にスペースを入れる結果になれば正しいと思います。

options: {
before: true,
after: false,
},
errors: [
{
message: "リンクの前にスペースを入れてください。",
column: 3,
},
],
},
{
text: "これは[README](./README.md)おかしい",
output: "これは[README](./README.md) おかしい",
options: {
before: false,
after: true,
},
errors: [
{
message: "リンクの後にスペースを入れてください。",
column: 25,
},
],
},
{
text: "これは[README](./README.md)おかしい",
output: "これは [README](./README.md) おかしい",
Expand Down