@textlint-rule/textlint-rule-no-unmatched-pair
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -9,2 +9,4 @@ "use strict"; | ||
var _textlintRuleHelper = require("textlint-rule-helper"); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -16,4 +18,6 @@ | ||
RuleError = context.RuleError; | ||
var ignoreNodeManager = new _textlintRuleHelper.IgnoreNodeManager(); | ||
return _defineProperty({}, Syntax.Paragraph, function (node) { | ||
var sentences = (0, _sentenceSplitter.splitAST)(node); | ||
ignoreNodeManager.ignoreChildrenByTypes(node, [Syntax.CodeBlock, Syntax.Code, Syntax.Link, Syntax.Strong, Syntax.Emphasis, Syntax.BlockQuote, Syntax.Comment]); | ||
sentences.children.filter(function (node) { | ||
@@ -32,2 +36,6 @@ return node.type === _sentenceSplitter.Syntax.Sentence; | ||
source.contextLocations.forEach(function (contextLocation) { | ||
if (ignoreNodeManager.isIgnoredIndex(node.range[0] + contextLocation.index)) { | ||
return; | ||
} | ||
report(node, new RuleError("Not found pair character for ".concat(contextLocation.pairMark.start, ".\n \nYou should close this sentence with ").concat(contextLocation.pairMark.end, ".\nThis pair mark is called ").concat(contextLocation.pairMark.key, "."), { | ||
@@ -37,4 +45,2 @@ index: contextLocation.index | ||
}); | ||
if (source.contextLocations.length > 0) {} | ||
}); | ||
@@ -41,0 +47,0 @@ }); |
{ | ||
"name": "@textlint-rule/textlint-rule-no-unmatched-pair", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "textlint rule that check unmatched pairs like \"(\" and \")\"", | ||
@@ -61,4 +61,5 @@ "keywords": [ | ||
"dependencies": { | ||
"sentence-splitter": "^3.0.11" | ||
"sentence-splitter": "^3.0.11", | ||
"textlint-rule-helper": "^2.0.0" | ||
} | ||
} |
@@ -5,8 +5,19 @@ // MIT © 2018 azu | ||
import { SourceCode } from "./parser/SourceCode.js"; | ||
import { IgnoreNodeManager } from "textlint-rule-helper"; | ||
const report = context => { | ||
const { Syntax, report, RuleError } = context; | ||
const ignoreNodeManager = new IgnoreNodeManager(); | ||
return { | ||
[Syntax.Paragraph](node) { | ||
const sentences = splitAST(node); | ||
ignoreNodeManager.ignoreChildrenByTypes(node, [ | ||
Syntax.CodeBlock, | ||
Syntax.Code, | ||
Syntax.Link, | ||
Syntax.Strong, | ||
Syntax.Emphasis, | ||
Syntax.BlockQuote, | ||
Syntax.Comment | ||
]); | ||
sentences.children.filter(node => node.type === SentenceSyntax.Sentence).forEach(sentence => { | ||
@@ -21,2 +32,5 @@ const source = new SourceCode(sentence.raw); | ||
source.contextLocations.forEach((contextLocation) => { | ||
if (ignoreNodeManager.isIgnoredIndex(node.range[0] + contextLocation.index)) { | ||
return; | ||
} | ||
report(node, new RuleError(`Not found pair character for ${contextLocation.pairMark.start}. | ||
@@ -29,5 +43,2 @@ | ||
}); | ||
if (source.contextLocations.length > 0) { | ||
} | ||
}); | ||
@@ -34,0 +45,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27448
388
2
+ Addedtextlint-rule-helper@^2.0.0
+ Added@textlint/ast-node-types@13.4.1(transitive)
+ Added@types/unist@2.0.11(transitive)
+ Addedboundary@2.0.0(transitive)
+ Addedstructured-source@4.0.0(transitive)
+ Addedtextlint-rule-helper@2.3.1(transitive)
+ Addedunist-util-is@4.1.0(transitive)
+ Addedunist-util-visit@2.0.3(transitive)
+ Addedunist-util-visit-parents@3.1.1(transitive)