Skip to content

Commit

Permalink
fix: support LinkReference types (#17)
Browse files Browse the repository at this point in the history
* fix: support LinkReference types

[title][id]
[title]

[title]: https://example.com
[id]: https://example.com

形式を判定しないように修正

* Apply suggestions from code review
  • Loading branch information
azu authored Sep 9, 2020
1 parent 1c04a8c commit 55ac641
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function reporter(context) {
const helper = new RuleHelper();
return {
[Syntax.Str](node){
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
return;
}
const text = getSource(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ tester.run("かっこ類と隣接する文字の間のスペースの有無", ru
そのため、特別な実装は必要なく
「拡張する時は\`calculator.prototype\`の代わりに\`calculator.fn\`を拡張してください」
というルールがあるだけとも言えます。
`
`,
"[テスト 「文章」 です](https://example)", // ignore Link
"[テスト 「文章」 です][]" +
"\n\n" +
"[テスト 「文章」 です]: https://example.com" // ignore ReferenceDef
],
invalid: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function reporter(context) {
const helper = new RuleHelper();
return {
[Syntax.Str](node){
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
return;
}
const text = getSource(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function reporter(context) {
const helper = new RuleHelper();
return {
[Syntax.Str](node){
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
return;
}
let text = getSource(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function reporter(context) {
const helper = new RuleHelper();
return {
[Syntax.Str](node){
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
if (helper.isChildNode(node, [Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) {
return;
}
let text = getSource(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function reporter(context, options = {}) {
return {
[Syntax.Str](node){
const isIgnoredParentNode = helper.isChildNode(node, [
Syntax.Header, Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis
Syntax.Header, Syntax.Link, "LinkReference", Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis
]);
if (isIgnoredParentNode) {
return;
Expand All @@ -96,4 +96,4 @@ function reporter(context, options = {}) {
module.exports = {
linter: reporter,
fixer: reporter
};
};

0 comments on commit 55ac641

Please sign in to comment.