textlint-rule-ginger
Advanced tools
Comparing version 0.1.6 to 2.0.0
@@ -23,6 +23,2 @@ 'use strict'; | ||
var _unistUtilMap = require('unist-util-map'); | ||
var _unistUtilMap2 = _interopRequireDefault(_unistUtilMap); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -32,3 +28,4 @@ | ||
var gingerbreadAsync = (0, _es6Promisify2.default)(_gingerbread2.default); | ||
var ignoreNodeManager = new _textlintRuleHelper.IgnoreNodeManger(); | ||
var gingerbreadAsync = (0, _es6Promisify2.default)(_gingerbread2.default, { multiArgs: true }); | ||
@@ -48,3 +45,2 @@ /** | ||
var helper = new _textlintRuleHelper.RuleHelper(context); | ||
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) { | ||
@@ -54,11 +50,6 @@ return null; | ||
var filteredNode = (0, _unistUtilMap2.default)(node, function (n) { | ||
// Replace the value of inline code with a dummy text. | ||
if (n.type === Syntax.Code) { | ||
return Object.assign({}, n, { value: 'code' }); | ||
} | ||
return n; | ||
}); | ||
// ignore Code type node | ||
ignoreNodeManager.ignoreChildrenByTypes(node, [Syntax.Code]); | ||
var source = new _textlintUtilToString2.default(filteredNode); | ||
var source = new _textlintUtilToString2.default(node); | ||
var text = source.toString(); | ||
@@ -104,2 +95,8 @@ | ||
var originalRange = [originalPosition.column, originalPosition.column + correction.length]; | ||
// if range is ignored, not report | ||
if (ignoreNodeManager.isIgnoredRange(originalRange)) { | ||
return; | ||
} | ||
var fix = fixer.replaceTextRange(originalRange, correction.correct); | ||
@@ -106,0 +103,0 @@ var message = correction.text + ' -> ' + correction.correct; |
{ | ||
"name": "textlint-rule-ginger", | ||
"version": "0.1.6", | ||
"version": "2.0.0", | ||
"description": "textlint rule to check your English grammar with Ginger Proofreading", | ||
@@ -29,23 +29,23 @@ "main": "lib/ginger.js", | ||
"dependencies": { | ||
"es6-promisify": "^3.0.0", | ||
"es6-promisify": "^4.1.0", | ||
"gingerbread": "^0.5.0", | ||
"textlint-rule-helper": "^1.1.5", | ||
"textlint-util-to-string": "^1.2.0", | ||
"unist-util-map": "^1.0.1" | ||
"textlint-rule-helper": "^1.2.0", | ||
"textlint-util-to-string": "^1.2.1" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.6.5", | ||
"babel-core": "^6.7.4", | ||
"babel-eslint": "^6.0.0", | ||
"babel-plugin-async-to-promises": "^1.0.4", | ||
"babel-plugin-espower": "^2.1.2", | ||
"babel-preset-es2015": "^6.6.0", | ||
"eslint": "^2.5.1", | ||
"eslint-config-airbnb": "^6.2.0", | ||
"mocha": "^2.4.5", | ||
"npm-run-all": "^1.6.0", | ||
"power-assert": "^1.3.1", | ||
"textlint": "^6.0.3", | ||
"babel-cli": "^6.10.1", | ||
"babel-core": "^6.9.1", | ||
"babel-eslint": "^6.0.4", | ||
"babel-plugin-async-to-promises": "^1.0.5", | ||
"babel-plugin-espower": "^2.2.0", | ||
"babel-preset-es2015": "^6.9.0", | ||
"eslint": "^2.12.0", | ||
"eslint-config-airbnb": "^9.0.1", | ||
"eslint-plugin-import": "^1.8.1", | ||
"mocha": "^2.5.3", | ||
"npm-run-all": "^2.1.2", | ||
"power-assert": "^1.4.1", | ||
"textlint": "^6.11.1", | ||
"textlint-tester": "^1.2.0" | ||
} | ||
} |
@@ -1,9 +0,8 @@ | ||
import { RuleHelper } from 'textlint-rule-helper'; | ||
import { RuleHelper, IgnoreNodeManger } from 'textlint-rule-helper'; | ||
import gingerbread from 'gingerbread'; | ||
import promisify from 'es6-promisify'; | ||
import StringSource from 'textlint-util-to-string'; | ||
import map from 'unist-util-map'; | ||
const ignoreNodeManager = new IgnoreNodeManger(); | ||
const gingerbreadAsync = promisify(gingerbread, { multiArgs: true }); | ||
const gingerbreadAsync = promisify(gingerbread); | ||
/** | ||
@@ -19,3 +18,2 @@ * Exclude inappropriate parts of text from linting, | ||
const helper = new RuleHelper(context); | ||
if (helper.isChildNode(node, [ | ||
@@ -30,11 +28,6 @@ Syntax.Link, | ||
const filteredNode = map(node, (n) => { | ||
// Replace the value of inline code with a dummy text. | ||
if (n.type === Syntax.Code) { | ||
return Object.assign({}, n, { value: 'code' }); | ||
} | ||
return n; | ||
}); | ||
// ignore Code type node | ||
ignoreNodeManager.ignoreChildrenByTypes(node, [Syntax.Code]); | ||
const source = new StringSource(filteredNode); | ||
const source = new StringSource(node); | ||
const text = source.toString(); | ||
@@ -80,2 +73,8 @@ | ||
]; | ||
// if range is ignored, not report | ||
if (ignoreNodeManager.isIgnoredRange(originalRange)) { | ||
return; | ||
} | ||
const fix = fixer.replaceTextRange(originalRange, correction.correct); | ||
@@ -82,0 +81,0 @@ const message = `${correction.text} -> ${correction.correct}`; |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4
0
12474
14
4
169
2
0
+ Addedes6-promisify@4.1.0(transitive)
- Removedunist-util-map@^1.0.1
- Removedes6-promisify@3.0.0(transitive)
- Removedunist-util-map@1.0.5(transitive)
Updatedes6-promisify@^4.1.0
Updatedtextlint-rule-helper@^1.2.0