textlint-rule-ginger
Advanced tools
Comparing version 2.1.1 to 2.1.2
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true, | ||
}); | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _slicedToArray = (function() { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for ( | ||
var _i = arr[Symbol.iterator](), _s; | ||
!(_n = (_s = _i.next()).done); | ||
_n = true | ||
) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i['return']) _i['return'](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
return function(arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError( | ||
'Invalid attempt to destructure non-iterable instance', | ||
); | ||
} | ||
}; | ||
})(); | ||
@@ -23,8 +61,40 @@ var _textlintRuleHelper = require('textlint-rule-helper'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { default: obj }; | ||
} | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
function _asyncToGenerator(fn) { | ||
return function() { | ||
var gen = fn.apply(this, arguments); | ||
return new Promise(function(resolve, reject) { | ||
function step(key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
return Promise.resolve(value).then( | ||
function(value) { | ||
step('next', value); | ||
}, | ||
function(err) { | ||
step('throw', err); | ||
}, | ||
); | ||
} | ||
} | ||
return step('next'); | ||
}); | ||
}; | ||
} | ||
const ignoreNodeManager = new _textlintRuleHelper.IgnoreNodeManager(); | ||
const gingerbreadAsync = (0, _es6Promisify2.default)(_gingerbread2.default, { multiArgs: true }); | ||
const gingerbreadAsync = (0, _es6Promisify2.default)(_gingerbread2.default, { | ||
multiArgs: true, | ||
}); | ||
@@ -42,3 +112,10 @@ /** | ||
const helper = new _textlintRuleHelper.RuleHelper(context); | ||
if (helper.isChildNode(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote, Syntax.Emphasis])) { | ||
if ( | ||
helper.isChildNode(node, [ | ||
Syntax.Link, | ||
Syntax.Image, | ||
Syntax.BlockQuote, | ||
Syntax.Emphasis, | ||
]) | ||
) { | ||
return null; | ||
@@ -58,16 +135,14 @@ } | ||
const Syntax = context.Syntax, | ||
report = context.report, | ||
RuleError = context.RuleError, | ||
fixer = context.fixer; | ||
report = context.report, | ||
RuleError = context.RuleError, | ||
fixer = context.fixer; | ||
return { | ||
[Syntax.Paragraph](node) { | ||
return _asyncToGenerator(function* () { | ||
return _asyncToGenerator(function*() { | ||
var _ref2 = filterNode({ node, context }) || {}; | ||
const source = _ref2.source, | ||
text = _ref2.text; | ||
text = _ref2.text; | ||
if (!source || !text) { | ||
@@ -78,7 +153,7 @@ return; | ||
var _ref3 = yield gingerbreadAsync(text), | ||
_ref4 = _slicedToArray(_ref3, 3); | ||
_ref4 = _slicedToArray(_ref3, 3); | ||
const original = _ref4[0], | ||
gingered = _ref4[1], | ||
corrections = _ref4[2]; | ||
gingered = _ref4[1], | ||
corrections = _ref4[2]; | ||
@@ -91,6 +166,9 @@ // when no errors. | ||
corrections.forEach(function (correction) { | ||
corrections.forEach(function(correction) { | ||
const index = correction.start; | ||
const originalPosition = source.originalPositionFromIndex(index); | ||
const originalRange = [originalPosition.column, originalPosition.column + correction.length]; | ||
const originalRange = [ | ||
originalPosition.column, | ||
originalPosition.column + correction.length, | ||
]; | ||
@@ -105,10 +183,13 @@ // if range is ignored, skip reporting | ||
report(node, new RuleError(message, { | ||
line: originalPosition.line - 1, | ||
column: originalPosition.column, | ||
fix | ||
})); | ||
report( | ||
node, | ||
new RuleError(message, { | ||
line: originalPosition.line - 1, | ||
column: originalPosition.column, | ||
fix, | ||
}), | ||
); | ||
}); | ||
})(); | ||
} | ||
}, | ||
}; | ||
@@ -119,4 +200,4 @@ } | ||
linter: reporter, | ||
fixer: reporter | ||
fixer: reporter, | ||
}; | ||
//# sourceMappingURL=ginger.js.map | ||
//# sourceMappingURL=ginger.js.map |
{ | ||
"name": "textlint-rule-ginger", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "textlint rule to check your English grammar with Ginger Proofreading", | ||
@@ -30,5 +30,5 @@ "engines": { | ||
"license": "MIT", | ||
"bugs": "https://github.com/nodaguti/textlint-rule-ginger/issues", | ||
"homepage": "https://github.com/nodaguti/textlint-rule-ginger", | ||
"repository": "nodaguti/textlint-rule-ginger", | ||
"bugs": "https://github.com/textlint-rule/textlint-rule-ginger/issues", | ||
"homepage": "https://github.com/textlint-rule/textlint-rule-ginger", | ||
"repository": "textlint-rule/textlint-rule-ginger", | ||
"dependencies": { | ||
@@ -35,0 +35,0 @@ "es6-promisify": "^5.0.0", |
@@ -5,5 +5,5 @@ # textlint-rule-ginger | ||
[![npm](https://img.shields.io/npm/v/textlint-rule-ginger.svg)](https://www.npmjs.com/package/textlint-rule-ginger) | ||
[![Build Status](https://travis-ci.org/nodaguti/textlint-rule-ginger.svg?branch=master)](https://travis-ci.org/nodaguti/textlint-rule-ginger) | ||
[![Dependency Status](https://david-dm.org/nodaguti/textlint-rule-ginger.svg)](https://david-dm.org/nodaguti/textlint-rule-ginger) | ||
[![devDependency Status](https://david-dm.org/nodaguti/textlint-rule-ginger/dev-status.svg)](https://david-dm.org/nodaguti/textlint-rule-ginger#info=devDependencies) | ||
[![Build Status](https://travis-ci.org/textlint-rule/textlint-rule-ginger.svg?branch=master)](https://travis-ci.org/textlint-rule/textlint-rule-ginger) | ||
[![Dependency Status](https://david-dm.org/textlint-rule/textlint-rule-ginger.svg)](https://david-dm.org/textlint-rule/textlint-rule-ginger) | ||
[![devDependency Status](https://david-dm.org/textlint-rule/textlint-rule-ginger/dev-status.svg)](https://david-dm.org/textlint-rule/textlint-rule-ginger#info=devDependencies) | ||
@@ -10,0 +10,0 @@ [textlint](https://github.com/textlint/textlint) rule |
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 bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the 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 bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
15201
242